Skip to content

Commit

Permalink
fix(HueDimmerController): Fix ZHA mapping
Browse files Browse the repository at this point in the history
related to #110
  • Loading branch information
xaviml committed Aug 8, 2020
1 parent 0274db5 commit b0f55de
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
22 changes: 15 additions & 7 deletions apps/controllerx/cx_devices/philips.py
Expand Up @@ -42,15 +42,23 @@ def get_deconz_actions_mapping(self) -> TypeActionsMapping:

def get_zha_actions_mapping(self) -> TypeActionsMapping:
return {
"on": Light.ON,
"step_0_30_9": Light.CLICK_BRIGHTNESS_UP,
"step_0_56_9": Light.HOLD_BRIGHTNESS_UP,
"step_1_30_9": Light.CLICK_BRIGHTNESS_DOWN,
"step_1_56_9": Light.HOLD_BRIGHTNESS_DOWN,
"off_with_effect_0_0": Light.OFF,
"stop": Light.RELEASE,
"off_long_release": Light.RELEASE,
"off_hold": Light.HOLD_COLOR_DOWN,
"off_short_release": Light.OFF,
"down_long_release": Light.RELEASE,
"down_hold": Light.HOLD_BRIGHTNESS_DOWN,
"down_short_release": Light.CLICK_BRIGHTNESS_DOWN,
"up_long_release": Light.RELEASE,
"up_hold": Light.HOLD_BRIGHTNESS_UP,
"up_short_release": Light.CLICK_BRIGHTNESS_UP,
"on_long_release": Light.RELEASE,
"on_hold": Light.HOLD_COLOR_UP,
"on_short_release": Light.ON,
}

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


class Niko91004LightController(LightController):
def get_deconz_actions_mapping(self) -> TypeActionsMapping:
Expand Down
3 changes: 3 additions & 0 deletions docs/_data/controllers/E1744.yml
Expand Up @@ -49,3 +49,6 @@ integrations:
- "toggle 🠖 1 click"
- "step_0_1_0 🠖 2 click"
- "step_1_1_0 🠖 3 click"
note: >-
If you want to use the default controller, you will need to set `legacy: false` in the Zigbee2MQTT configuration.
Read more in <a href="https://www.zigbee2mqtt.io/devices/E1744.html#legacy-integration">here</a>.
16 changes: 16 additions & 0 deletions tests/cx_devices/phillips_test.py
@@ -0,0 +1,16 @@
import pytest
from cx_devices.philips import HueDimmerController


@pytest.mark.parametrize(
"data, expected_action",
[
({"command": "on_long_release"}, "on_long_release"),
({"command": "down_press"}, "down_press"),
({"command": "off_hold"}, "off_hold"),
],
)
def test_zha_action_HueDimmerController(data, expected_action):
sut = HueDimmerController()
action = sut.get_zha_action(data)
assert action == expected_action

0 comments on commit b0f55de

Please sign in to comment.