-
-
Notifications
You must be signed in to change notification settings - Fork 37.8k
ZHA lock code services and events #47208
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
Changes from 6 commits
28237c0
96d84e1
9dc9e09
fdff804
37f3ab4
5f90fe1
77a41a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,6 +23,27 @@ async def async_update(self): | |||||||||||||||||||||||||||||||
| f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", 0, "lock_state", result | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @callback | ||||||||||||||||||||||||||||||||
| def cluster_command(self, tsn, command_id, args): | ||||||||||||||||||||||||||||||||
| """Handle a cluster command received on this cluster.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||
| self._cluster.client_commands is None | ||||||||||||||||||||||||||||||||
| or self._cluster.client_commands.get(command_id) is None | ||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| command_name = self._cluster.client_commands.get(command_id, [command_id])[0] | ||||||||||||||||||||||||||||||||
| if command_name == "operation_event_notification": | ||||||||||||||||||||||||||||||||
| self.zha_send_event( | ||||||||||||||||||||||||||||||||
| command_name, | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| "source": args[0].name, | ||||||||||||||||||||||||||||||||
| "operation": args[1].name, | ||||||||||||||||||||||||||||||||
| "code_slot": (args[2] + 1), # start code slots at 1 | ||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @callback | ||||||||||||||||||||||||||||||||
| def attribute_updated(self, attrid, value): | ||||||||||||||||||||||||||||||||
| """Handle attribute update from lock cluster.""" | ||||||||||||||||||||||||||||||||
|
|
@@ -35,6 +56,63 @@ def attribute_updated(self, attrid, value): | |||||||||||||||||||||||||||||||
| f"{self.unique_id}_{SIGNAL_ATTR_UPDATED}", attrid, attr_name, value | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async def async_set_user_code(self, code_slot: int, user_code: str) -> None: | ||||||||||||||||||||||||||||||||
| """Set the user code for the code slot.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| set_pin_code = self.__getattr__("set_pin_code") | ||||||||||||||||||||||||||||||||
| await set_pin_code( | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is that a thing that will work? If so I can update to that easily
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. definitely test it, but it should work.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still new to python :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Work got crazy for a couple weeks, but I finally was able to test with my door locks. As you suggested, it worked just fine. Updated commit pushed. |
||||||||||||||||||||||||||||||||
| *( | ||||||||||||||||||||||||||||||||
| code_slot - 1, # start code slots at 1, Zigbee internals use 0 | ||||||||||||||||||||||||||||||||
| closures.DoorLock.UserStatus.Enabled, | ||||||||||||||||||||||||||||||||
| closures.DoorLock.UserType.Unrestricted, | ||||||||||||||||||||||||||||||||
| user_code, | ||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async def async_enable_user_code(self, code_slot: int) -> None: | ||||||||||||||||||||||||||||||||
| """Enable the code slot.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| set_user_status = self.__getattr__("set_user_status") | ||||||||||||||||||||||||||||||||
| await set_user_status(*(code_slot - 1, closures.DoorLock.UserStatus.Enabled)) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async def async_disable_user_code(self, code_slot: int) -> None: | ||||||||||||||||||||||||||||||||
| """Disable the code slot.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| set_user_status = self.__getattr__("set_user_status") | ||||||||||||||||||||||||||||||||
| await set_user_status(*(code_slot - 1, closures.DoorLock.UserStatus.Disabled)) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async def async_get_user_code(self, code_slot: int) -> int: | ||||||||||||||||||||||||||||||||
| """Get the user code from the code slot.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| get_pin_code = self.__getattr__("get_pin_code") | ||||||||||||||||||||||||||||||||
| result = await get_pin_code(*(code_slot - 1,)) | ||||||||||||||||||||||||||||||||
| return result | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async def async_clear_user_code(self, code_slot: int) -> None: | ||||||||||||||||||||||||||||||||
| """Clear the code slot.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| clear_pin_code = self.__getattr__("clear_pin_code") | ||||||||||||||||||||||||||||||||
| await clear_pin_code(*(code_slot - 1,)) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async def async_clear_all_user_codes(self) -> None: | ||||||||||||||||||||||||||||||||
| """Clear all code slots.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| clear_all_pin_codes = self.__getattr__("clear_all_pin_codes") | ||||||||||||||||||||||||||||||||
| await clear_all_pin_codes(*()) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async def async_set_user_type(self, code_slot: int, user_type: str) -> None: | ||||||||||||||||||||||||||||||||
| """Set user type.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| set_user_type = self.__getattr__("set_user_type") | ||||||||||||||||||||||||||||||||
| await set_user_type(*(code_slot - 1, user_type)) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async def async_get_user_type(self, code_slot: int) -> str: | ||||||||||||||||||||||||||||||||
| """Get user type.""" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| get_user_type = self.__getattr__("get_user_type") | ||||||||||||||||||||||||||||||||
| result = await get_user_type(*(code_slot - 1)) | ||||||||||||||||||||||||||||||||
| return result | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| @registries.ZIGBEE_CHANNEL_REGISTRY.register(closures.Shade.cluster_id) | ||||||||||||||||||||||||||||||||
| class Shade(ZigbeeChannel): | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Adminiuga is there a better way to parse the args out? Or is there a better way to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really, cause args would change depending on the command_id