Migrate Harmony to has entity name (#104737)
* Migrate Harmony to has entity name * Fix tests --------- Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
6106a66ed8
commit
44211dc761
10 changed files with 120 additions and 114 deletions
|
@ -19,11 +19,12 @@ TIME_MARK_DISCONNECTED = 10
|
|||
class HarmonyEntity(Entity):
|
||||
"""Base entity for Harmony with connection state handling."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, data: HarmonyData) -> None:
|
||||
"""Initialize the Harmony base entity."""
|
||||
super().__init__()
|
||||
self._unsub_mark_disconnected: Callable[[], None] | None = None
|
||||
self._name = data.name
|
||||
self._data = data
|
||||
self._attr_should_poll = False
|
||||
|
||||
|
@ -34,14 +35,14 @@ class HarmonyEntity(Entity):
|
|||
|
||||
async def async_got_connected(self, _: str | None = None) -> None:
|
||||
"""Notification that we're connected to the HUB."""
|
||||
_LOGGER.debug("%s: connected to the HUB", self._name)
|
||||
_LOGGER.debug("%s: connected to the HUB", self._data.name)
|
||||
self.async_write_ha_state()
|
||||
|
||||
self._clear_disconnection_delay()
|
||||
|
||||
async def async_got_disconnected(self, _: str | None = None) -> None:
|
||||
"""Notification that we're disconnected from the HUB."""
|
||||
_LOGGER.debug("%s: disconnected from the HUB", self._name)
|
||||
_LOGGER.debug("%s: disconnected from the HUB", self._data.name)
|
||||
# We're going to wait for 10 seconds before announcing we're
|
||||
# unavailable, this to allow a reconnection to happen.
|
||||
self._unsub_mark_disconnected = async_call_later(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue