Simplify update_listener in kmtronic (#147184)

This commit is contained in:
epenet 2025-06-20 10:27:07 +02:00 committed by GitHub
parent 8f661fc5cf
commit 32314dbb13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 7 deletions

View File

@ -8,7 +8,7 @@ from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME, Platfor
from homeassistant.core import HomeAssistant
from homeassistant.helpers import aiohttp_client
from .const import DATA_COORDINATOR, DATA_HUB, DOMAIN, UPDATE_LISTENER
from .const import DATA_COORDINATOR, DATA_HUB, DOMAIN
from .coordinator import KMtronicCoordinator
PLATFORMS = [Platform.SWITCH]
@ -35,8 +35,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
update_listener = entry.add_update_listener(async_update_options)
hass.data[DOMAIN][entry.entry_id][UPDATE_LISTENER] = update_listener
entry.async_on_unload(entry.add_update_listener(async_update_options))
return True
@ -50,8 +49,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
update_listener = hass.data[DOMAIN][entry.entry_id][UPDATE_LISTENER]
update_listener()
hass.data[DOMAIN].pop(entry.entry_id)
return unload_ok

View File

@ -8,5 +8,3 @@ DATA_HUB = "hub"
DATA_COORDINATOR = "coordinator"
MANUFACTURER = "KMtronic"
UPDATE_LISTENER = "update_listener"