Skip to content

Commit

Permalink
feat(device): add TS0044 TuYa device
Browse files Browse the repository at this point in the history
Z2M support

related to #240
  • Loading branch information
xaviml committed Apr 9, 2021
1 parent 2045258 commit 38ee4b0
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Expand Up @@ -26,3 +26,4 @@ _PRERELEASE_NOTE_

## :video_game: New devices
- [HG06323](https://xaviml.github.io/controllerx/controllers/HG06323) - add ZHA support [ #274 ] @Thomas55555
- [TS0044](https://xaviml.github.io/controllerx/controllers/TS0044) - add device with Z2M support [ #240 ]
1 change: 1 addition & 0 deletions apps/controllerx/controllerx.py
Expand Up @@ -29,3 +29,4 @@
from cx_devices.sonoff import *
from cx_devices.terncy import *
from cx_devices.trust import *
from cx_devices.tuya import *
20 changes: 20 additions & 0 deletions apps/controllerx/cx_devices/tuya.py
@@ -0,0 +1,20 @@
from cx_const import DefaultActionsMapping, Light
from cx_core import LightController


class TS0044LightController(LightController):
def get_z2m_actions_mapping(self) -> DefaultActionsMapping:
return {
"1_single": Light.TOGGLE,
"1_double": Light.CLICK_BRIGHTNESS_UP,
"1_hold": Light.CLICK_BRIGHTNESS_DOWN,
"2_single": Light.TOGGLE,
"2_double": Light.CLICK_BRIGHTNESS_UP,
"2_hold": Light.CLICK_BRIGHTNESS_DOWN,
"3_single": Light.TOGGLE,
"3_double": Light.CLICK_BRIGHTNESS_UP,
"3_hold": Light.CLICK_BRIGHTNESS_DOWN,
"4_single": Light.TOGGLE,
"4_double": Light.CLICK_BRIGHTNESS_UP,
"4_hold": Light.CLICK_BRIGHTNESS_DOWN,
}
43 changes: 43 additions & 0 deletions docs/_data/controllers/TS0044.yml
@@ -0,0 +1,43 @@
name: TS0044 (TuYa)
device_support:
- type: Light
domain: light
controller: TS0044LightController
delay: 350
mapping:
- "Click top left → Toggle"
- "Double click top left → Brighten up (1 step)"
- "Hold top left → Dim down (1 step)"
- "Click top right → Toggle"
- "Double click top right → Brighten up (1 step)"
- "Hold top right → Dim down (1 step)"
- "Click bottom left → Toggle"
- "Double click bottom left → Brighten up (1 step)"
- "Hold bottom left → Dim down (1 step)"
- "Click top right → Toggle"
- "Double click top right → Brighten up (1 step)"
- "Hold top right → Dim down (1 step)"
integrations:
- name: Zigbee2MQTT
codename: z2m
actions:
- 1_single → Click top left
- 1_double → Double click top left
- 1_hold → Hold top left
- 2_single → Click top right
- 2_double → Double click top right
- 2_hold → Hold top right
- 3_single → Click bottom left
- 3_double → Double click bottom left
- 3_hold → Hold bottom left
- 4_single → Click top right
- 4_double → Double click top right
- 4_hold → Hold top right
note: >-
Note that each button perform the same actions.
This is because ControllerX is design to control just one entity (light or media player).
So you can include the `actions` parameter to include the actions needed,
or use the `mapping` attribute to define a <a href="/controllerx/advanced/custom-controllers">custom mapping</a>.
You can check <a href="https://github.com/xaviml/controllerx/issues/18#issuecomment-582535634">here</a> for reference.
Also, this controller support hold action, but not release. This means that there is not
smooth brightness changes when holding, just step by step everytime is held.
Binary file added docs/assets/img/TS0044.jpeg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions docs/controllers/TS0044.md
@@ -0,0 +1,5 @@
---
layout: controller
title: TS0044 (TuYa)
device: TS0044
---

0 comments on commit 38ee4b0

Please sign in to comment.