Huawei LTE unload cleanups (#49788)

This commit is contained in:
Ville Skyttä 2021-04-28 00:08:14 +03:00 committed by GitHub
parent c193f8fd18
commit 9db6d0cee4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 13 deletions

View file

@ -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

View file

@ -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)