mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Simplify update_listener in konnected (#147172)
This commit is contained in:
parent
8c1e43c07c
commit
fde36d5034
@ -58,7 +58,6 @@ from .const import (
|
|||||||
PIN_TO_ZONE,
|
PIN_TO_ZONE,
|
||||||
STATE_HIGH,
|
STATE_HIGH,
|
||||||
STATE_LOW,
|
STATE_LOW,
|
||||||
UNDO_UPDATE_LISTENER,
|
|
||||||
UPDATE_ENDPOINT,
|
UPDATE_ENDPOINT,
|
||||||
ZONE_TO_PIN,
|
ZONE_TO_PIN,
|
||||||
ZONES,
|
ZONES,
|
||||||
@ -261,10 +260,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
# config entry specific data to enable unload
|
entry.async_on_unload(entry.add_update_listener(async_entry_updated))
|
||||||
hass.data[DOMAIN][entry.entry_id] = {
|
|
||||||
UNDO_UPDATE_LISTENER: entry.add_update_listener(async_entry_updated)
|
|
||||||
}
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -272,11 +268,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
"""Unload a config entry."""
|
"""Unload a config entry."""
|
||||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id][UNDO_UPDATE_LISTENER]()
|
|
||||||
|
|
||||||
if unload_ok:
|
if unload_ok:
|
||||||
hass.data[DOMAIN][CONF_DEVICES].pop(entry.data[CONF_ID])
|
hass.data[DOMAIN][CONF_DEVICES].pop(entry.data[CONF_ID])
|
||||||
hass.data[DOMAIN].pop(entry.entry_id)
|
|
||||||
|
|
||||||
return unload_ok
|
return unload_ok
|
||||||
|
|
||||||
|
@ -44,5 +44,3 @@ ZONE_TO_PIN = {zone: pin for pin, zone in PIN_TO_ZONE.items()}
|
|||||||
ENDPOINT_ROOT = "/api/konnected"
|
ENDPOINT_ROOT = "/api/konnected"
|
||||||
UPDATE_ENDPOINT = ENDPOINT_ROOT + r"/device/{device_id:[a-zA-Z0-9]+}"
|
UPDATE_ENDPOINT = ENDPOINT_ROOT + r"/device/{device_id:[a-zA-Z0-9]+}"
|
||||||
SIGNAL_DS18B20_NEW = "konnected.ds18b20.new"
|
SIGNAL_DS18B20_NEW = "konnected.ds18b20.new"
|
||||||
|
|
||||||
UNDO_UPDATE_LISTENER = "undo_update_listener"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user