Skip to content

Commit

Permalink
Merge pull request #1065 from Strauman/add_ts0042
Browse files Browse the repository at this point in the history
Add Tuya TS0042LightController ZHA
  • Loading branch information
xaviml authored Nov 8, 2024
2 parents b3d3021 + b8ca23b commit 38c0f2f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 1 addition & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ _This minor change does not contain any breaking changes._
## :pencil2: Features
-->

<!--
## :video_game: New devices

- [XYZ](https://BASE_URL/controllerx/controllers/XYZ) - add device with Z2M support. [ #123 ]
-->
- [TS0042](https://BASE_URL/controllerx/controllers/TS0042) - add device with ZHA support. [ #1065 ]

<!--
## :hammer: Fixes
Expand Down
22 changes: 22 additions & 0 deletions apps/controllerx/cx_devices/tuya.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,25 @@ def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
"double": MediaPlayer.NEXT_TRACK,
"hold": MediaPlayer.PREVIOUS_TRACK,
}


class TS0042LightController(LightController):
def get_zha_actions_mapping(self) -> DefaultActionsMapping:
return {
"1_remote_button_short_press": Light.ON,
"1_remote_button_double_press": Light.CLICK_BRIGHTNESS_UP,
"1_remote_button_long_press": Light.ON_FULL_BRIGHTNESS,
"2_remote_button_short_press": Light.OFF,
"2_remote_button_double_press": Light.ON_MIN_BRIGHTNESS,
}

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
Binary file added docs/docs/assets/controllers/TS0042.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 38c0f2f

Please sign in to comment.