Update device registry of MQTT Switch#19540
Conversation
6cce869 to
13a9721
Compare
There was a problem hiding this comment.
This line can be removed after this
There was a problem hiding this comment.
Why is it ok to remove the device_info function?
There was a problem hiding this comment.
Not all of it. But everything except for identifiers/connections can be removed as now that's handled above.
There was a problem hiding this comment.
OK, I think it's fixed now.
There was a problem hiding this comment.
There was a problem hiding this comment.
Yes, but the code is now no longer duplicated in MqttEntityDeviceInfo.device_info_discovery_update(), so shouldn't be removed from MqttEntityDeviceInfo.device_info().
There was a problem hiding this comment.
Check if self._config_entry is None before. If the user tries to configure the device registry through YAML, this line will raise an AttributeError
There was a problem hiding this comment.
I thought device registry only works through discovery as documented: https://www.home-assistant.io/components/switch.mqtt/#device
Can you give an example of when this errors so I can test and verify your suggestion?
There was a problem hiding this comment.
Example is in previous comment.
Previously, this would not do anything in the case of yaml config. But now this will raise an attributeerror. We can do better than that. Let's print a proper warning/error
There was a problem hiding this comment.
But function device_info_discovery_update is only called if mqtt discovery message is received again after the switch had been discovered, how can this happen for a device configured trough yaml? An example of exactly what yaml triggers an error would be helpful.
There was a problem hiding this comment.
I think this is fixed/clearer now that the duplicated code has been removed.
|
@OttoWinter Do you think this is OK to merge now after the duplicated code was removed? |
50e220e to
519d3b0
Compare
50e220e to
5c65c56
Compare
|
I can't see anything indicating it, but I'm not really comfortable with the entity registry, so just to make sure: |
|
@thomasloven That's absolutely not the intention. The purpose of this PR is to allow the device registry to be updated without a restart of Hass. A typical use case would firmware version to be correctly shown in Hass UI. |
|
Thank you for the clarification. |
e445db9 to
b5233b7
Compare
Description:
Support update of device registry so Hass doesn't need to be restarted to, for example, show updated firmware version of the device.
Checklist:
tox. Your PR cannot be merged unless tests passIf the code does not interact with devices: