Split event subscriptions from async_added_to_hass in isy994 (#185867)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
G Johansson
2026-10-11 21:24:52 -04:00
committed by GitHub
co-authored by Claude Opus 5.5
parent c4f7a81f7a
commit acbadce9fc
4 changed files with 18 additions and 6 deletions
+12
View File
@@ -53,6 +53,12 @@ class ISYEntity(Entity):
@override
async def async_added_to_hass(self) -> None:
"""Subscribe to the node change events."""
await super().async_added_to_hass()
self._async_subscribe_to_events()
@callback
def _async_subscribe_to_events(self) -> None:
"""Subscribe to the node change events."""
self._change_handler = self._node.status_events.subscribe(self.async_on_update)
self.async_on_remove(self._change_handler.unsubscribe)
@@ -248,6 +254,12 @@ class ISYAuxControlEntity(Entity):
@override
async def async_added_to_hass(self) -> None:
"""Subscribe to the node control change events."""
await super().async_added_to_hass()
self._async_subscribe_to_events()
@callback
def _async_subscribe_to_events(self) -> None:
"""Subscribe to the node control change events."""
self._change_handler = self._node.control_events.subscribe(
self.async_on_update,
+2 -2
View File
@@ -136,9 +136,9 @@ class ISYButtonEvent(ISYNodeEntity, EventEntity):
# these and most users only automate a few.
self._attr_entity_registry_enabled_default = False
@callback
@override
# pylint: disable-next=home-assistant-missing-super-call
async def async_added_to_hass(self) -> None:
def _async_subscribe_to_events(self) -> None:
"""Subscribe to control events and node enabled/disabled changes only.
Skipping the base class's status_events subscription avoids a state
+2 -2
View File
@@ -365,9 +365,9 @@ class ISYAuxSensorEntity(ISYSensorEntity):
"""Return the target value."""
return None if self.target is None else self.target.value
@callback
@override
# pylint: disable-next=home-assistant-missing-super-call
async def async_added_to_hass(self) -> None:
def _async_subscribe_to_events(self) -> None:
"""Subscribe to the node control change events.
Overloads the default ISYNodeEntity updater to only update when
+2 -2
View File
@@ -162,9 +162,9 @@ class ISYEnableSwitchEntity(ISYAuxControlEntity, SwitchEntity):
self._attr_name = description.name # Override super
self._change_handler: EventListener | None = None
@callback
@override
# pylint: disable-next=home-assistant-missing-super-call
async def async_added_to_hass(self) -> None:
def _async_subscribe_to_events(self) -> None:
"""Subscribe to the node control change events."""
self._change_handler = self._node.isy.nodes.status_events.subscribe(
self.async_on_update,