-
-
Notifications
You must be signed in to change notification settings - Fork 28.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add madvr envy integration #120382
base: dev
Are you sure you want to change the base?
Add madvr envy integration #120382
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c932b66
to
9453240
Compare
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Changes:
Not sure what you mean. The library handles receiving push data from the device. This integration reads self.madvr_client.msg_dict Power state is read directly from the device via the library in self.madvr_client.is_on Otherwise, it sends commands to the device. This works perfectly fine I have been testing this integration for 3 weeks now and the library itself has been used by many people for about a year now. I used most of this code in a custom component for over a year too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its good to take a step back at this point. How does the data work in the integration? What does the state of the data look like?
Some things don't make sense and I think we better take a step back and increase the shared knowledge before we send you in a direction that does not work. Because you are creating a MadVR client in the __init__.py
, and then you are actually closing the connection the moment the remote is removed from hass (in async_will_remove_from_hass
) even though this also happens when someone disabled that entity. So this would lead to unwanted side effects.
I also think that we should explore putting the whole queue mechanism into the library, as I think that is a device/connection specific detail.
I still really don't understand this comment. The integration literally reads a dict in the library which is written by the library when the device pushes data through the connection, like a websocket. This is how the device is designed.
I think what doesn't make sense is the HA dev docs. It is frustratingly hard to understand "the right way" to do something. All the guidance given in this PR is not found in the docs and I have just been following the docs to create this integration. Those functions don't have explanations like that So are you saying to handle connection closing in async_unload_entry? You need to understand I don't have the institutional knowledge you have. I only have access to the docs. And the docs say that async_will_remove_from_hass is used to "disconnect from the server" The docs also say async_unload_entry is used to "close all connections" so which one do I use? The functions seem to do the exact same thing.
This is fair I will move this to the library |
I did not know this. I could only assume and since in this case I was confused with all the things happening with tasks and stuff I just asked the quest to be sure :)
In the past, a lot of integrations just had 1 entity which contained a lot of data. In the recent times we've seen a move towards more entities instead of more data in 1 entity, as the first one is more user friendly. But the docs haven't really grown with that. So yea, in the past it was more common to disconnect at that place, since with YAML there was no way of unloading. So yes, use And please don't forget, I am not here to call you out on stuff you did wrong, I am trying to point you at the relevant things that could increase the code quality and enhancing best practices :). I am currently looking into how we can word best practices and present them as a guide to enhance the steps to create a new integration. |
Thats fine actually I don't mind being corrected because I want to do it the right way. I do think that, with complex systems, there is a "right way" and I would love for HA to be more opinionated with that. HA should prescribe ways to do this with patterns rather than documenting functions. For example, in my case I am using a push method, so there should be one way to do this. Having documentation that points to existing code bases which are exemplars of this would be a good start. This is the feedback I see anyway, that people need to dive into core and just blindly copy existing integrations. e.g in the getting started docs, have a section with common patterns: Is your library pushing data to the integration? Here is how you set that up and here is an exemplar integration Anyway, I pushed a change which moves more things into the coordinator and redid the unload stuff. Hopefully that is right. I am working on moving the queue stuff into the library |
I mentioned it before but I can add this to comments in the code if that will help. The tasks are used to process things in real time
Thats fine actually I don't mind being corrected because I want to do it the right way. I do think that, with complex systems, there is a "right way" and I would love for HA to be more opinionated with that. HA should prescribe ways to do this with patterns rather than documenting functions. For example, in my case I am using a push method, so there should be one way to do this. Having documentation that points to existing code bases which are exemplars of this would be a good start. This is the feedback I see anyway, that people need to dive into core and just blindly copy existing integrations. e.g in the getting started docs, have a section with common patterns: Is your library pushing data to the integration? Here is how you set that up and here is an exemplar integration Anyway, I pushed a change which moves more things into the coordinator and redid the unload stuff. Hopefully that is right. I am working on moving the queue stuff into the library |
Awesome! I mean if you have a lot of passion for docs, feel free to contact me on discord so I have someone new ish who I can throw it to, to check if its understandable :P Let me know when stuff is done, then we can take a look at it again :) |
Yes I would definitely like to help out. I would like to be involved in HA development more so this is a good first step. I can ping you on discord I pushed some updates
I tested this locally and on my prod instance, everything works as expected (attributes, push updates, tasks, reload & disabling integration, etc) Just a heads up once this is merged, I plan on opening the PR to add the binary_sensors and sensor platforms back in (those are also all working as expected but I can't add them because of the bot) |
|
Proposed change
This adds an integration for the madvr envy http://madvrenvy.com
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: