Skip to content

Commit

Permalink
Merge pull request #1066 from Strauman/add_ts0043_zha
Browse files Browse the repository at this point in the history
Add TS0043 to ZHA
  • Loading branch information
xaviml authored Nov 8, 2024
2 parents 38c0f2f + 3ca3c86 commit 67c6f0a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ _This minor change does not contain any breaking changes._
## :video_game: New devices

- [TS0042](https://BASE_URL/controllerx/controllers/TS0042) - add device with ZHA support. [ #1065 ]
- [TS0043](https://BASE_URL/controllerx/controllers/TS0043) - add ZHA support. [ #1066 ]

<!--
## :hammer: Fixes
Expand Down
24 changes: 24 additions & 0 deletions apps/controllerx/cx_devices/tuya.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
"3_hold": Light.CLICK_BRIGHTNESS_DOWN,
}

def get_zha_actions_mapping(self) -> DefaultActionsMapping:
return {
"1_remote_button_short_press": Light.TOGGLE,
"1_remote_button_double_press": Light.CLICK_BRIGHTNESS_UP,
"1_remote_button_long_press": Light.CLICK_BRIGHTNESS_DOWN,
"2_remote_button_short_press": Light.TOGGLE,
"2_remote_button_double_press": Light.CLICK_BRIGHTNESS_UP,
"2_remote_button_long_press": Light.CLICK_BRIGHTNESS_DOWN,
"3_remote_button_short_press": Light.TOGGLE,
"3_remote_button_double_press": Light.CLICK_BRIGHTNESS_UP,
"3_remote_button_long_press": Light.CLICK_BRIGHTNESS_DOWN,
}

def get_zha_action(self, data: EventData) -> str:
args: str = ""
# Command is {endpoint_id}_{command}
if len(data["args"]) > 0:
if isinstance(data["args"], list):
args = "_" + "_".join([str(d) for d in data["args"]])
else:
args = args + f"{data['args']}"
command: str = f"{data['endpoint_id']}_{data['command']}{args}"
return command


class TuYaERS10TZBVKAALightController(LightController):
def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
Expand Down

0 comments on commit 67c6f0a

Please sign in to comment.