Skip to content

Commit

Permalink
Use Zigpy definition objects in ZHA cluster handlers (home-assistant#…
Browse files Browse the repository at this point in the history
…108383)

* use zigpy def objects in ZHA cluster handlers

* shorten with direct imports

* shorten with rename due to clash
  • Loading branch information
dmulcahey authored Jan 25, 2024
1 parent 4138b5c commit 74a6092
Show file tree
Hide file tree
Showing 9 changed files with 538 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def __getattr__(self, name):
class ZDOClusterHandler(LogMixin):
"""Cluster handler for ZDO events."""

def __init__(self, device):
def __init__(self, device) -> None:
"""Initialize ZDOClusterHandler."""
self.name = CLUSTER_HANDLER_ZDO
self._cluster = device.device.endpoints[0]
Expand Down
14 changes: 11 additions & 3 deletions homeassistant/components/zha/core/cluster_handlers/closures.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,23 @@ class DoorLockClusterHandler(ClusterHandler):

_value_attribute = 0
REPORT_CONFIG = (
AttrReportConfig(attr="lock_state", config=REPORT_CONFIG_IMMEDIATE),
AttrReportConfig(
attr=closures.DoorLock.AttributeDefs.lock_state.name,
config=REPORT_CONFIG_IMMEDIATE,
),
)

async def async_update(self):
"""Retrieve latest state."""
result = await self.get_attribute_value("lock_state", from_cache=True)
result = await self.get_attribute_value(
closures.DoorLock.AttributeDefs.lock_state.name, from_cache=True
)
if result is not None:
self.async_send_signal(
f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", 0, "lock_state", result
f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}",
closures.DoorLock.AttributeDefs.lock_state.id,
closures.DoorLock.AttributeDefs.lock_state.name,
result,
)

@callback
Expand Down
Loading

0 comments on commit 74a6092

Please sign in to comment.