Skip to content

Commit

Permalink
Merge pull request #229 from choif/dev
Browse files Browse the repository at this point in the history
Add Aqara WXKG07LM z2m/zha mappings
  • Loading branch information
xaviml committed Jan 24, 2021
2 parents b330463 + afccbb7 commit 1537f52
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 2 deletions.
96 changes: 96 additions & 0 deletions apps/controllerx/cx_devices/aqara.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ def get_deconz_actions_mapping(self) -> DefaultActionsMapping:
3004: Light.CLICK_BRIGHTNESS_UP, # double both
}

def get_zha_actions_mapping(self) -> DefaultActionsMapping:
return {
"both_single": Light.TOGGLE,
"both_double": Light.CLICK_BRIGHTNESS_UP,
"both_long press": Light.CLICK_BRIGHTNESS_DOWN,
"left_single": Light.TOGGLE,
"left_double": Light.CLICK_BRIGHTNESS_UP,
"left_long press": Light.CLICK_BRIGHTNESS_DOWN,
"right_single": Light.TOGGLE,
"right_double": Light.CLICK_BRIGHTNESS_UP,
"right_long press": Light.CLICK_BRIGHTNESS_DOWN,
}

def get_zha_action(self, data: EventData) -> str:
return data["command"]


class WXKG02LMSwitchController(SwitchController):
def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
Expand All @@ -46,6 +62,16 @@ def get_deconz_actions_mapping(self) -> DefaultActionsMapping:
3002: Switch.TOGGLE,
}

def get_zha_actions_mapping(self) -> DefaultActionsMapping:
return {
"both_single": Switch.TOGGLE,
"left_single": Switch.TOGGLE,
"right_single": Switch.TOGGLE,
}

def get_zha_action(self, data: EventData) -> str:
return data["command"]


class WXKG01LMLightController(LightController):
"""
Expand Down Expand Up @@ -350,3 +376,73 @@ def get_deconz_actions_mapping(self) -> DefaultActionsMapping:
6001: Light.HOLD_COLOR_UP,
6003: Light.RELEASE,
}


class WXKG07LMLightController(LightController):
def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
return {
"both": Light.TOGGLE,
"both_double": Light.CLICK_BRIGHTNESS_UP,
"both_long": Light.CLICK_BRIGHTNESS_UP,
"left": Light.TOGGLE,
"left_double": Light.CLICK_BRIGHTNESS_UP,
"left_long": Light.CLICK_BRIGHTNESS_UP,
"right": Light.TOGGLE,
"right_double": Light.CLICK_BRIGHTNESS_UP,
"right_long": Light.CLICK_BRIGHTNESS_UP,
}

def get_deconz_actions_mapping(self) -> DefaultActionsMapping:
return {
1002: Light.TOGGLE, # single left
1001: Light.CLICK_BRIGHTNESS_DOWN, # long left
1004: Light.CLICK_BRIGHTNESS_UP, # double left
2002: Light.TOGGLE, # single right
2001: Light.CLICK_BRIGHTNESS_DOWN, # long right
2004: Light.CLICK_BRIGHTNESS_UP, # double right
3002: Light.TOGGLE, # single both
3001: Light.CLICK_BRIGHTNESS_DOWN, # long both
3004: Light.CLICK_BRIGHTNESS_UP, # double both
}

def get_zha_actions_mapping(self) -> DefaultActionsMapping:
return {
"both_single": Light.TOGGLE,
"both_double": Light.CLICK_BRIGHTNESS_UP,
"both_long press": Light.CLICK_BRIGHTNESS_DOWN,
"left_single": Light.TOGGLE,
"left_double": Light.CLICK_BRIGHTNESS_UP,
"left_long press": Light.CLICK_BRIGHTNESS_DOWN,
"right_single": Light.TOGGLE,
"right_double": Light.CLICK_BRIGHTNESS_UP,
"right_long press": Light.CLICK_BRIGHTNESS_DOWN,
}

def get_zha_action(self, data: EventData) -> str:
return data["command"]


class WXKG07LMSwitchController(SwitchController):
def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
return {
"both": Switch.TOGGLE,
"left": Switch.TOGGLE,
"right": Switch.TOGGLE,
}

def get_deconz_actions_mapping(self) -> DefaultActionsMapping:
return {
1002: Switch.TOGGLE,
2002: Switch.TOGGLE,
3002: Switch.TOGGLE,
}

def get_zha_actions_mapping(self) -> DefaultActionsMapping:
return {
"both_single": Switch.TOGGLE,
"left_single": Switch.TOGGLE,
"right_single": Switch.TOGGLE,
}

def get_zha_action(self, data: EventData) -> str:
return data["command"]
16 changes: 14 additions & 2 deletions docs/_data/controllers/WXKG02LM.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: WXKG02LM (Aqara)
device_support:
device_support:
- type: Light
domain: light
controller: WXKG02LMLightController
Expand Down Expand Up @@ -46,10 +46,22 @@ integrations:
- "2002 → Click on right"
- "2004 → Double click on right"
- "2001 → Long click on right"
- name: ZHA
codename: zha
actions:
- "both_single → Click on both"
- "both_double → Double click on both"
- "both_long → Long click on both"
- "left_single → Click on left"
- "left_long press → Double click on left"
- "hold_left → Long click on left"
- "right_single → Click on right"
- "right_double → Double click on right"
- "right_long press → Long click on right"
note: >-
Note that all actions related to both, left and right, do the same.
This is because ControllerX is design to control just one entity (light or media player).
So you can include the `actions` parameter to include the actions needed.
You can check <a href="https://github.com/xaviml/controllerx/issues/18#issuecomment-582535634">here</a> for reference.
Also, this controller support hold action, but not release. This means that there is not
smooth brightness changes when holding, just step by step everytime is held.
smooth brightness changes when holding, just step by step everytime is held.
67 changes: 67 additions & 0 deletions docs/_data/controllers/WXKG07LM.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: WXKG07LM (Aqara)
device_support:
- type: Light
domain: light
controller: WXKG07LMLightController
delay: 350
mapping:
- "Click on both → Toggle"
- "Double click on both → Brighten up (1 step)"
- "Long click on both → Dim down (1 step)"
- "Click on left → Toggle"
- "Double click on left → Brighten up (1 step)"
- "Long click on left → Dim down (1 step)"
- "Click on right → Toggle"
- "Double click on right → Brighten up (1 step)"
- "Long click on right → Dim down (1 step)"
- type: Switch
domain: switch
controller: WXKG07LMSwitchController
mapping:
- "Click on both → Toggle"
- "Click on left → Toggle"
- "Click on right → Toggle"
integrations:
- name: Zigbee2MQTT
codename: z2m
actions:
- "both → Click on both"
- "both_double → Double click on both"
- "both_long → Long click on both"
- "left → Click on left"
- "left_double → Double click on left"
- "left_long → Long click on left"
- "right → Click on right"
- "right_double → Double click on right"
- "right_long → Long click on right"
- name: deCONZ
codename: deconz
actions:
- "3002 → Click on both"
- "3004 → Double click on both"
- "3001 → Long click on both"
- "1002 → Click on left"
- "1004 → Double click on left"
- "1001 → Long click on left"
- "2002 → Click on right"
- "2004 → Double click on right"
- "2001 → Long click on right"
- name: ZHA
codename: zha
actions:
- "both_single → Click on both"
- "both_double → Double click on both"
- "both_long → Long click on both"
- "left_single → Click on left"
- "left_long press → Double click on left"
- "hold_left → Long click on left"
- "right_single → Click on right"
- "right_double → Double click on right"
- "right_long press → Long click on right"
note: >-
Note that all actions related to both, left and right, do the same.
This is because ControllerX is design to control just one entity (light or media player).
So you can include the `actions` parameter to include the actions needed.
You can check <a href="https://github.com/xaviml/controllerx/issues/18#issuecomment-582535634">here</a> for reference.
Also, this controller support hold action, but not release. This means that there is not
smooth brightness changes when holding, just step by step everytime is held.
Binary file added docs/assets/img/WXKG07LM.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/controllers/WXKG07LM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: controller
title: WXKG07LM (Aqara)
device: WXKG07LM
---

0 comments on commit 1537f52

Please sign in to comment.