mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Huawei LTE unload cleanups (#49788)
This commit is contained in:
parent
c193f8fd18
commit
9db6d0cee4
@ -39,7 +39,6 @@ from homeassistant.const import (
|
|||||||
CONF_RECIPIENT,
|
CONF_RECIPIENT,
|
||||||
CONF_URL,
|
CONF_URL,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
|
||||||
)
|
)
|
||||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, ServiceCall
|
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
@ -143,7 +142,6 @@ class Router:
|
|||||||
factory=lambda: defaultdict(set, ((x, {"initial_scan"}) for x in ALL_KEYS)),
|
factory=lambda: defaultdict(set, ((x, {"initial_scan"}) for x in ALL_KEYS)),
|
||||||
)
|
)
|
||||||
inflight_gets: set[str] = attr.ib(init=False, factory=set)
|
inflight_gets: set[str] = attr.ib(init=False, factory=set)
|
||||||
unload_handlers: list[CALLBACK_TYPE] = attr.ib(init=False, factory=list)
|
|
||||||
client: Client
|
client: Client
|
||||||
suspended = attr.ib(init=False, default=False)
|
suspended = attr.ib(init=False, default=False)
|
||||||
notify_last_attempt: float = attr.ib(init=False, default=-1)
|
notify_last_attempt: float = attr.ib(init=False, default=-1)
|
||||||
@ -292,10 +290,6 @@ class Router:
|
|||||||
|
|
||||||
self.subscriptions.clear()
|
self.subscriptions.clear()
|
||||||
|
|
||||||
for handler in self.unload_handlers:
|
|
||||||
handler()
|
|
||||||
self.unload_handlers.clear()
|
|
||||||
|
|
||||||
self.logout()
|
self.logout()
|
||||||
|
|
||||||
|
|
||||||
@ -444,13 +438,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
router.update()
|
router.update()
|
||||||
|
|
||||||
# Set up periodic update
|
# Set up periodic update
|
||||||
router.unload_handlers.append(
|
|
||||||
async_track_time_interval(hass, _update_router, SCAN_INTERVAL)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Clean up at end
|
|
||||||
config_entry.async_on_unload(
|
config_entry.async_on_unload(
|
||||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, router.cleanup)
|
async_track_time_interval(hass, _update_router, SCAN_INTERVAL)
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -102,7 +102,7 @@ async def async_setup_entry(
|
|||||||
disconnect_dispatcher = async_dispatcher_connect(
|
disconnect_dispatcher = async_dispatcher_connect(
|
||||||
hass, UPDATE_SIGNAL, _async_maybe_add_new_entities
|
hass, UPDATE_SIGNAL, _async_maybe_add_new_entities
|
||||||
)
|
)
|
||||||
router.unload_handlers.append(disconnect_dispatcher)
|
config_entry.async_on_unload(disconnect_dispatcher)
|
||||||
|
|
||||||
# Add new entities from initial scan
|
# Add new entities from initial scan
|
||||||
async_add_new_entities(hass, router.url, async_add_entities, tracked)
|
async_add_new_entities(hass, router.url, async_add_entities, tracked)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user