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
Filter rfxtrx configure devices option flow on existing config entry #40975
Filter rfxtrx configure devices option flow on existing config entry #40975
Conversation
Hey there @Danielhiversen, @elupus, mind taking a look at this pull request as its been labeled with an integration ( |
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.
We probably should have a test for this case. It's easy to miss supporting.
Also, any call to get_rfx_object should really check the return value. It can be Null if the event code was not parsable. |
I noticed something else. Here device_id returned from
|
I though about that but it's not straightforward. We need to mock a situation where a device is added but not in config entry, which cannot happen anymore so it needs some creativity.
I did that initially in the options flow PR, and threw an error when not parsable, and got the comment how that could happen and how the user can prevent that. Based on that I removed it, because it cannot happen except when the user enters an event code. In this case return value is checked. In all other cases, the get_rfx_object already succeeded before because otherwise it can't end up in the config entry data. |
About the device id, I need to recheck. I think we can get rid of the whole dispatcher thing and refactor this a bit. When replacing the device, we directly remove entities from the entity register, which also calls async_remove on the entity, so I think we should do the same here and perhaps make a function remove_device which does it. |
Refactoring the dispatcher should be done in a different PR. I'm still not sure about adding a test. I can't get a test working which asserts on a See previous comments about the rfx object check. |
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.
Okey. I might have a go, but I don't think we need to block this pull.
Shouldn't we clean up devices with incorrect data state automatically? |
I thought about that, but I worry it'll be frustrating for users. The devices for which this happens have entities which are |
Do note also that for devices which can receive (data or command) it will be automatically fixed. It will be detected that the event code is not in the ConfigEntry data and it will be added. We also risk if the user launches the options flow too soon that we cleanup devices for which data is only received sporadically and config can still be fixed. |
Ok. |
…ome-assistant#40975) * Prompt only configure devices when device is in config entry * Fix copy
Breaking change
Proposed change
In some exceptional cases a device can be present in the device registry but there could be a missing config entry key for that device. In that case, when selecting the device and trying to configure options, the option flow will throw an exception.
This PR will not present devices in the list with devices to configure unless it has a config entry key.
The way to solve it when a device misses an entry key (one of the options will work):
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast 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
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: