Skip to content

Commit

Permalink
feat(device): change some things from AUA1ZBR2GW controller
Browse files Browse the repository at this point in the history
  • Loading branch information
xaviml committed Mar 6, 2021
1 parent d5b45c4 commit 0f85d67
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
6 changes: 3 additions & 3 deletions apps/controllerx/cx_devices/aurora.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ def get_zha_actions_mapping(self) -> DefaultActionsMapping:
def get_zha_action(self, data: EventData) -> str:
endpoint_id = data.get("endpoint_id", 1)
command = action = data["command"]
args = data.get("args", {})
args_mapping = {0: "up", 1: "down", 3: "up"}
args = data.get("args", [])
if command == "step" or command == "step_color_temp":
args_mapping = {0: "up", 1: "down", 3: "up"}
action = "_".join((action, args_mapping[args[0]]))
if command == "on" or command == "off":
action = "toggle"
action = "_".join((str(endpoint_id), action))
action = f"{endpoint_id}_{action}"
return action
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ device_support:
- type: Light
domain: light
controller: AUA1ZBR2GWLightController
delay: 100
delay: 350
mapping:
- "Click left knob → Toggle 2"
- "Rotate left knob clockwise → Increase brightness 2"
Expand Down
Binary file modified docs/assets/img/AU-A1ZBR2GW.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions tests/unit_tests/cx_devices/aurora_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest
from cx_core.integration import EventData
from cx_devices.aurora import AUA1ZBR2GWLightController


@pytest.mark.parametrize(
"data, expected_action",
[
({"command": "on"}, "1_toggle"),
({"command": "on", "endpoint_id": 2}, "2_toggle"),
({"command": "off"}, "1_toggle"),
({"command": "step", "args": [0]}, "1_step_up"),
({"command": "step", "args": [3]}, "1_step_up"),
({"command": "step_color_temp", "args": [1]}, "1_step_color_temp_down"),
],
)
def test_zha_action_WXKG01LMLightController(data: EventData, expected_action: str):
sut = AUA1ZBR2GWLightController() # type: ignore
action = sut.get_zha_action(data)
assert action == expected_action

0 comments on commit 0f85d67

Please sign in to comment.