mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +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 __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Callable
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.helpers.device_registry import DeviceInfo
|
from homeassistant.helpers.device_registry import DeviceInfo
|
||||||
@ -25,7 +24,6 @@ class HuaweiLteBaseEntity(Entity):
|
|||||||
def __init__(self, router: Router) -> None:
|
def __init__(self, router: Router) -> None:
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self.router = router
|
self.router = router
|
||||||
self._unsub_handlers: list[Callable] = []
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _device_unique_id(self) -> str:
|
def _device_unique_id(self) -> str:
|
||||||
@ -48,7 +46,7 @@ class HuaweiLteBaseEntity(Entity):
|
|||||||
|
|
||||||
async def async_added_to_hass(self) -> None:
|
async def async_added_to_hass(self) -> None:
|
||||||
"""Connect to update signals."""
|
"""Connect to update signals."""
|
||||||
self._unsub_handlers.append(
|
self.async_on_remove(
|
||||||
async_dispatcher_connect(self.hass, UPDATE_SIGNAL, self._async_maybe_update)
|
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:
|
if config_entry_unique_id == self.router.config_entry.unique_id:
|
||||||
self.async_schedule_update_ha_state(True)
|
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):
|
class HuaweiLteBaseEntityWithDevice(HuaweiLteBaseEntity):
|
||||||
"""Base entity with device info."""
|
"""Base entity with device info."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user