From e134ea08f52e8fa214c97aefc37e3008123b2fba Mon Sep 17 00:00:00 2001 From: Xavier Moreno Date: Thu, 24 Jun 2021 14:02:50 +0200 Subject: [PATCH] feat(device): add ZHA support for E1812 related to #324 --- apps/controllerx/cx_devices/ikea.py | 17 +++++++++++++++++ docs/_data/controllers/E1812.yml | 8 +++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/apps/controllerx/cx_devices/ikea.py b/apps/controllerx/cx_devices/ikea.py index 326ce7a8..e10869f7 100644 --- a/apps/controllerx/cx_devices/ikea.py +++ b/apps/controllerx/cx_devices/ikea.py @@ -13,6 +13,7 @@ SwitchController, action, ) +from cx_core.integration import EventData class E1810Controller(LightController): @@ -503,6 +504,16 @@ def get_deconz_actions_mapping(self) -> DefaultActionsMapping: 1003: Light.RELEASE, } + def get_zha_actions_mapping(self) -> DefaultActionsMapping: + return { + "on": Light.TOGGLE, + "move_with_on_off": Light.HOLD_BRIGHTNESS_TOGGLE, + "stop": Light.RELEASE, + } + + def get_zha_action(self, data: EventData) -> str: + return data["command"] + class E1812SwitchController(SwitchController): def get_z2m_actions_mapping(self) -> DefaultActionsMapping: @@ -511,6 +522,12 @@ def get_z2m_actions_mapping(self) -> DefaultActionsMapping: def get_deconz_actions_mapping(self) -> DefaultActionsMapping: return {1002: Switch.TOGGLE} + def get_zha_actions_mapping(self) -> DefaultActionsMapping: + return {"on": Light.TOGGLE} + + def get_zha_action(self, data: EventData) -> str: + return data["command"] + class W2049LightController(LightController): def get_z2m_actions_mapping(self) -> DefaultActionsMapping: diff --git a/docs/_data/controllers/E1812.yml b/docs/_data/controllers/E1812.yml index f6b710c2..1773ec4b 100644 --- a/docs/_data/controllers/E1812.yml +++ b/docs/_data/controllers/E1812.yml @@ -16,7 +16,7 @@ integrations: - name: Zigbee2MQTT codename: z2m actions: - - "on → Click" + - '"on" → Click' - "brightness_move_up → Hold" - "brightness_stop → Released after being held" - name: deCONZ @@ -25,3 +25,9 @@ integrations: - "1002 → Click" - "1001 → Hold" - "1003 → Released after being held" + - name: ZHA + codename: zha + actions: + - '"on" → Click' + - "move_with_on_off → Hold" + - "stop → Released after being held"