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
Optimize mqtt device cleanup #111170
Optimize mqtt device cleanup #111170
Conversation
Hey there @emontnemery, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@@ -1347,15 +1347,12 @@ def async_removed_from_device( | |||
config_entry_id: str, | |||
) -> bool: | |||
"""Check if the passed event indicates MQTT was removed from a device.""" | |||
if event.data["action"] not in ("remove", "update"): |
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.
Due to recent optimizations only remove
or update
actions are generated. This code seems unreachable now.
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'm not sure how it was possible to get add events in the first place because its subscribing by device_id which couldn't exist if it wasn't added
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.
Fyi The tests handle removing entities from a device with multiple entities in several ways. E.g. remove the device from the UI, or remove the device when there are no more associated entities.
device_entry := device_registry.async_get(event.data["device_id"]) | ||
device_entry := device_registry.async_get(mqtt_device_id) |
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 already have a device_id, so no need to look it up.
Proposed change
Optimize mqtt device cleanup
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: