Huawei LTE unload cleanups (#49788)
This commit is contained in:
parent
c193f8fd18
commit
9db6d0cee4
2 changed files with 2 additions and 13 deletions
|
@ -39,7 +39,6 @@ from homeassistant.const import (
|
|||
CONF_RECIPIENT,
|
||||
CONF_URL,
|
||||
CONF_USERNAME,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
from homeassistant.core import CALLBACK_TYPE, HomeAssistant, ServiceCall
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
@ -143,7 +142,6 @@ class Router:
|
|||
factory=lambda: defaultdict(set, ((x, {"initial_scan"}) for x in ALL_KEYS)),
|
||||
)
|
||||
inflight_gets: set[str] = attr.ib(init=False, factory=set)
|
||||
unload_handlers: list[CALLBACK_TYPE] = attr.ib(init=False, factory=list)
|
||||
client: Client
|
||||
suspended = attr.ib(init=False, default=False)
|
||||
notify_last_attempt: float = attr.ib(init=False, default=-1)
|
||||
|
@ -292,10 +290,6 @@ class Router:
|
|||
|
||||
self.subscriptions.clear()
|
||||
|
||||
for handler in self.unload_handlers:
|
||||
handler()
|
||||
self.unload_handlers.clear()
|
||||
|
||||
self.logout()
|
||||
|
||||
|
||||
|
@ -444,13 +438,8 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
router.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(
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, router.cleanup)
|
||||
async_track_time_interval(hass, _update_router, SCAN_INTERVAL)
|
||||
)
|
||||
|
||||
return True
|
||||
|
|
|
@ -102,7 +102,7 @@ async def async_setup_entry(
|
|||
disconnect_dispatcher = async_dispatcher_connect(
|
||||
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
|
||||
async_add_new_entities(hass, router.url, async_add_entities, tracked)
|
||||
|
|
Loading…
Add table
Reference in a new issue