INNER CODE UNIT · Python
update_listener
dummylabs/thewatchman · custom_components/watchman/__init__.py:177
async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Reload integration when options changed."""
set_obfuscation_config(entry.data.get(CONF_LOG_OBFUSCATE, True))
if hasattr(entry, "runtime_data") and entry.runtime_data:
_LOGGER.debug("Invalidating FilterContext cache due to update Watchman config_entry data")
entry.runtime_data.coordinator.invalidate_filter_context()
await hass.config_entries.async_reload(entry.entry_id)
async def async_unload_entry(hass: HomeAssistant, config_entry: WMConfigEntry) -> bool: # pylint: disable=unused-argument
"""Handle integration unload."""
if hasattr(config_entry, "runtime_data") and config_entry.runtime_data:
await config_entry.runtime_data.coordinator.async_shutdown()
if hass.services.has_service(DOMAIN, REPORT_SERVICE_NAME):
hass.services.async_remove(DOMAIN, REPORT_SERVICE_NAME)
unload_ok = await hass.config_entries.async_unload_platforms(