Forked from blizzrdof77/zha-moes-zigbee-rotary-smart-knob-remote-control.yaml
Last active
July 16, 2023 02:28
-
-
Save JaviSoto/0a419981a2f3a8d5be0c88a9d4f7bd6d to your computer and use it in GitHub Desktop.
ZHA - Moes Tuya Smart Knob (TS004F) controller for light dimming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: ZHA - Moes Tuya Smart Knob (TS004F) controller for light dimming | |
description: Control a light with a Tuya smart knob. | |
domain: automation | |
source_url: https://gist.github.com/JaviSoto/0a419981a2f3a8d5be0c88a9d4f7bd6d#file-zha-moes-zigbee-rotary-smart-knob-remote-control-yaml | |
input: | |
remote: | |
name: Smart Knob Device | |
description: Moes Tuya Smart Knob Device to use | |
selector: | |
device: | |
integration: zha | |
manufacturer: _TZ3000_4fjiwweb | |
model: TS004F | |
multiple: false | |
light_entity: | |
name: Light Entity | |
description: The device ID string of the light to control | |
selector: | |
text: | |
multiline: false | |
mode: restart | |
max_exceeded: silent | |
trigger: | |
- platform: event | |
event_type: zha_event | |
event_data: | |
device_id: !input remote | |
action: | |
- variables: | |
command: "{{ trigger.event.data.command }}" | |
cluster_id: "{{ trigger.event.data.cluster_id }}" | |
endpoint_id: "{{ trigger.event.data.endpoint_id }}" | |
args: "{{ trigger.event.data.args }}" | |
step_type: | |
"{%- if (trigger.event.data.args|list)|length == 3 -%}\n {%- set args | |
= trigger.event.data.args|list -%}\n {%- if args|first == 0 -%}\n {{ 'up' | |
}}\n {%- elif args|first == 1 -%}\n {{ 'down' }}\n {%- else -%}\n {{ | |
'' }}\n {%- endif -%}\n{%- else -%}\n {{ 'single_press' }}\n{%- endif -%}" | |
amount: | |
"{%- if (trigger.event.data.args|list)|length == 3 -%}\n {%- set args | |
= trigger.event.data.args|list -%}\n {{ args[1]|int }}\n{%- else -%}\n {{ | |
0 }}\n{%- endif -%}" | |
rate: | |
"{%- if (trigger.event.data.args|list)|length == 3 -%}\n {%- set args = | |
trigger.event.data.args|list -%}\n {{ args|last|int }}\n{%- else -%}\n {{ | |
0 }}\n{%- endif -%}" | |
- choose: | |
- conditions: | |
- '{{ command == "toggle" }}' | |
- "{{ cluster_id == 6 }}" | |
- "{{ endpoint_id == 1 }}" | |
sequence: | |
- service: light.toggle | |
target: | |
device_id: !input light_entity | |
- conditions: | |
- '{{ command == "step" }}' | |
- "{{ cluster_id == 8 }}" | |
- "{{ endpoint_id == 1 }}" | |
- '{{ step_type == "up" }}' | |
sequence: | |
- service: light.turn_on | |
target: | |
device_id: !input light_entity | |
data: | |
brightness_step_pct: "{{ (amount|int) / 10 }}" | |
- conditions: | |
- '{{ command == "step" }}' | |
- "{{ cluster_id == 8 }}" | |
- "{{ endpoint_id == 1 }}" | |
- '{{ step_type == "down" }}' | |
sequence: | |
- service: light.turn_on | |
target: | |
device_id: !input light_entity | |
data: | |
brightness_step_pct: "{{ - (amount|int) / 10 }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment