Simplify huawei_lte entities event setup (#142501)

This commit is contained in:
Ville Skyttä 2025-04-14 23:31:27 +03:00 committed by GitHub
parent 881079ccc1
commit 3378b8d7ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,7 +2,6 @@
from __future__ import annotations
from collections.abc import Callable
from datetime import timedelta
from homeassistant.helpers.device_registry import DeviceInfo
@ -25,7 +24,6 @@ class HuaweiLteBaseEntity(Entity):
def __init__(self, router: Router) -> None:
"""Initialize."""
self.router = router
self._unsub_handlers: list[Callable] = []
@property
def _device_unique_id(self) -> str:
@ -48,7 +46,7 @@ class HuaweiLteBaseEntity(Entity):
async def async_added_to_hass(self) -> None:
"""Connect to update signals."""
self._unsub_handlers.append(
self.async_on_remove(
async_dispatcher_connect(self.hass, UPDATE_SIGNAL, self._async_maybe_update)
)
@ -57,12 +55,6 @@ class HuaweiLteBaseEntity(Entity):
if config_entry_unique_id == self.router.config_entry.unique_id:
self.async_schedule_update_ha_state(True)
async def async_will_remove_from_hass(self) -> None:
"""Invoke unsubscription handlers."""
for unsub in self._unsub_handlers:
unsub()
self._unsub_handlers.clear()
class HuaweiLteBaseEntityWithDevice(HuaweiLteBaseEntity):
"""Base entity with device info."""