Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tuya TS0042LightController ZHA #1065

Merged
merged 6 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.