Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ZHA entity state on ZigBee zdo device announce #19208

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions homeassistant/components/zha/entities/entity.py
Expand Up @@ -69,6 +69,8 @@ async def async_added_to_hass(self):
for cluster_id, cluster in self._out_clusters.items():
cluster.add_listener(self._out_listeners.get(cluster_id, self))

self._endpoint.device.zdo.add_listener(self)

self._initialized = True

@property
Expand All @@ -91,6 +93,16 @@ def zdo_command(self, tsn, command_id, args):
"""Handle a ZDO command received on this cluster."""
pass

@callback
def device_announce(self, device):
"""Handle device_announce zdo event."""
self.async_schedule_update_ha_state(force_refresh=True)

@callback
def permit_duration(self, permit_duration):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this overwritten in child classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it is a side effect of how zigpy event listeners work. If you don't implement all events that an emitter can emit it throws warnings / errors and pollutes the logs. So, because the ZDO listener can emit this event we have to have a handler for it.

"""Handle permit_duration zdo event."""
pass

@property
def device_info(self):
"""Return a device description for device registry."""
Expand Down