Migrate rfxtrx to use run_immediately=True for the device registry listener (#115165)

This commit is contained in:
J. Nick Koston 2024-04-08 08:29:27 -10:00 committed by GitHub
parent 2fc0d8494d
commit 266e4f0c8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -281,7 +281,7 @@ async def async_setup_internal(hass: HomeAssistant, entry: ConfigEntry) -> None:
entry.async_on_unload(
hass.bus.async_listen(
dr.EVENT_DEVICE_REGISTRY_UPDATED, _updated_device, run_immediately=False
dr.EVENT_DEVICE_REGISTRY_UPDATED, _updated_device, run_immediately=True
)
)

View file

@ -486,7 +486,10 @@ class RfxtrxOptionsFlow(OptionsFlow):
if devices:
for event_code, options in devices.items():
if options is None:
entry_data[CONF_DEVICES].pop(event_code)
# If the config entry is setup, the device registry
# listener will remove the device from the config
# entry before we get here
entry_data[CONF_DEVICES].pop(event_code, None)
else:
entry_data[CONF_DEVICES][event_code] = options
self.hass.config_entries.async_update_entry(self._config_entry, data=entry_data)