mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Ensure konnected unsubscribes during entry unloads (#34291)
This commit is contained in:
parent
0d60d40512
commit
ab352c3bc9
@ -58,6 +58,7 @@ 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,
|
||||||
@ -254,7 +255,7 @@ async def async_setup(hass: HomeAssistant, config: dict):
|
|||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
||||||
"""Set up panel from a config entry."""
|
"""Set up panel from a config entry."""
|
||||||
client = AlarmPanel(hass, entry)
|
client = AlarmPanel(hass, entry)
|
||||||
# create a data store in hass.data[DOMAIN][CONF_DEVICES]
|
# creates a panel data store in hass.data[DOMAIN][CONF_DEVICES]
|
||||||
await client.async_save_data()
|
await client.async_save_data()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -267,7 +268,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
hass.async_create_task(
|
hass.async_create_task(
|
||||||
hass.config_entries.async_forward_entry_setup(entry, component)
|
hass.config_entries.async_forward_entry_setup(entry, component)
|
||||||
)
|
)
|
||||||
entry.add_update_listener(async_entry_updated)
|
|
||||||
|
# config entry specific data to enable unload
|
||||||
|
hass.data[DOMAIN][entry.entry_id] = {
|
||||||
|
UNDO_UPDATE_LISTENER: entry.add_update_listener(async_entry_updated)
|
||||||
|
}
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@ -281,8 +286,12 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
@ -47,3 +47,5 @@ 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