mirror of
https://github.com/home-assistant/core.git
synced 2025-04-19 14:57:52 +00:00
Simplify huawei_lte entities event setup (#142501)
This commit is contained in:
parent
881079ccc1
commit
3378b8d7ce
@ -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."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user