|
49 | 49 | LockDisableUserLockCodeCommand,
|
50 | 50 | LockEnableUserLockCodeCommand,
|
51 | 51 | LockLockCommand,
|
| 52 | + LockRestoreExternalStateAttributesCommand, |
52 | 53 | LockSetUserLockCodeCommand,
|
53 | 54 | LockUnlockCommand,
|
54 | 55 | )
|
55 | 56 | from zha.application.platforms.model import BaseEntityInfo, BasePlatformEntityInfo
|
56 | 57 | from zha.application.platforms.number.websocket_api import NumberSetValueCommand
|
57 |
| -from zha.application.platforms.select.websocket_api import SelectSelectOptionCommand |
| 58 | +from zha.application.platforms.select.websocket_api import ( |
| 59 | + SelectRestoreExternalStateAttributesCommand, |
| 60 | + SelectSelectOptionCommand, |
| 61 | +) |
58 | 62 | from zha.application.platforms.siren.websocket_api import (
|
59 | 63 | SirenTurnOffCommand,
|
60 | 64 | SirenTurnOnCommand,
|
|
63 | 67 | SwitchTurnOffCommand,
|
64 | 68 | SwitchTurnOnCommand,
|
65 | 69 | )
|
66 |
| -from zha.application.platforms.websocket_api import PlatformEntityRefreshStateCommand |
| 70 | +from zha.application.platforms.websocket_api import ( |
| 71 | + PlatformEntityDisableCommand, |
| 72 | + PlatformEntityEnableCommand, |
| 73 | + PlatformEntityRefreshStateCommand, |
| 74 | +) |
67 | 75 | from zha.application.websocket_api import (
|
68 | 76 | AddGroupMembersCommand,
|
69 | 77 | CreateGroupCommand,
|
@@ -552,6 +560,20 @@ async def disable_user_lock_code(
|
552 | 560 | )
|
553 | 561 | return await self._client.async_send_command(command)
|
554 | 562 |
|
| 563 | + async def restore_external_state_attributes( |
| 564 | + self, |
| 565 | + lock_platform_entity: BasePlatformEntityInfo, |
| 566 | + state: Literal["locked", "unlocked"] | None, |
| 567 | + ) -> WebSocketCommandResponse: |
| 568 | + """Restore external state attributes.""" |
| 569 | + ensure_platform_entity(lock_platform_entity, Platform.LOCK) |
| 570 | + command = LockRestoreExternalStateAttributesCommand( |
| 571 | + ieee=lock_platform_entity.device_ieee, |
| 572 | + unique_id=lock_platform_entity.unique_id, |
| 573 | + state=state, |
| 574 | + ) |
| 575 | + return await self._client.async_send_command(command) |
| 576 | + |
555 | 577 |
|
556 | 578 | class NumberHelper:
|
557 | 579 | """Helper to issue number commands."""
|
@@ -596,6 +618,20 @@ async def select_option(
|
596 | 618 | )
|
597 | 619 | return await self._client.async_send_command(command)
|
598 | 620 |
|
| 621 | + async def restore_external_state_attributes( |
| 622 | + self, |
| 623 | + select_platform_entity: BasePlatformEntityInfo, |
| 624 | + state: str | None, |
| 625 | + ) -> WebSocketCommandResponse: |
| 626 | + """Restore external state attributes.""" |
| 627 | + ensure_platform_entity(select_platform_entity, Platform.SELECT) |
| 628 | + command = SelectRestoreExternalStateAttributesCommand( |
| 629 | + ieee=select_platform_entity.device_ieee, |
| 630 | + unique_id=select_platform_entity.unique_id, |
| 631 | + state=state, |
| 632 | + ) |
| 633 | + return await self._client.async_send_command(command) |
| 634 | + |
599 | 635 |
|
600 | 636 | class ClimateHelper:
|
601 | 637 | """Helper to issue climate commands."""
|
@@ -768,6 +804,28 @@ async def refresh_state(
|
768 | 804 | )
|
769 | 805 | return await self._client.async_send_command(command)
|
770 | 806 |
|
| 807 | + async def enable( |
| 808 | + self, platform_entity: BasePlatformEntityInfo |
| 809 | + ) -> WebSocketCommandResponse: |
| 810 | + """Enable a platform entity.""" |
| 811 | + command = PlatformEntityEnableCommand( |
| 812 | + ieee=platform_entity.device_ieee, |
| 813 | + unique_id=platform_entity.unique_id, |
| 814 | + platform=platform_entity.platform, |
| 815 | + ) |
| 816 | + return await self._client.async_send_command(command) |
| 817 | + |
| 818 | + async def disable( |
| 819 | + self, platform_entity: BasePlatformEntityInfo |
| 820 | + ) -> WebSocketCommandResponse: |
| 821 | + """Disable a platform entity.""" |
| 822 | + command = PlatformEntityDisableCommand( |
| 823 | + ieee=platform_entity.device_ieee, |
| 824 | + unique_id=platform_entity.unique_id, |
| 825 | + platform=platform_entity.platform, |
| 826 | + ) |
| 827 | + return await self._client.async_send_command(command) |
| 828 | + |
771 | 829 |
|
772 | 830 | class ClientHelper:
|
773 | 831 | """Helper to send client specific commands."""
|
|
0 commit comments