Forked from Drout/zha-moes-zigbee-rotary-smart-knob-remote-control.yaml
Last active
May 19, 2024 20:54
-
-
Save Legot/cf9906e717cc825bda31f6991728d16e to your computer and use it in GitHub Desktop.
ZHA - Moes Tuya Smart Knob (TS004F) controller for any device
This file contains hidden or 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 any devices | |
| description: Control remotes (e.g. volume up/down) with a Moes Tuya smart knob (the spinny ones). You can set functions for single press, rotating left, and rotating right. | |
| domain: automation | |
| source_url: https://gist.github.com/Legot/cf9906e717cc825bda31f6991728d16e # Changed URL | |
| input: | |
| remote: | |
| name: Smart Knob Device | |
| description: Moes Tuya Smart Knob Device to use | |
| selector: | |
| device: | |
| integration: zha | |
| #manufacturer: _TZ3000_4fjiwweb # Mine was _TZ3000_qja6nq5z so I commented out this line | |
| model: TS004F | |
| linked_entity_id: | |
| name: Linked Entity (Optional) | |
| description: Optionally link an entity to use it's custom attributes defined in customize.yaml. | |
| default: "" | |
| selector: | |
| entity: {} | |
| remote_entity: | |
| name: Remote Entity | |
| description: The remote to control | |
| selector: | |
| target: | |
| device_name: | |
| name: Device Name/ID | |
| description: The device name (or ID) associated with the chosen remote. | |
| default: "" | |
| selector: | |
| text: | |
| multiline: false | |
| command_single_press: | |
| name: Single-press Command | |
| description: Remote command name used for a single press. | |
| default: PowerToggle | |
| selector: | |
| text: | |
| multiline: false | |
| command_up: | |
| name: Up Command | |
| description: Remote command name used when dial is turned up/right (clockwise) | |
| default: VolumeUp | |
| selector: | |
| text: | |
| multiline: false | |
| command_down: | |
| name: Down Command | |
| description: Remote command name used when dial is turned down/left (counter-clockwise) | |
| default: VolumeDown | |
| 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 }}' | |
| linked_entity: !input 'linked_entity_id' | |
| step_type: >- | |
| {%- if (trigger.event.data.args|list)|length == 3 -%} | |
| {%- set args = trigger.event.data.args|list -%} | |
| {%- if args|first == 0 -%} | |
| {{ 'up' }} | |
| {%- elif args|first == 1 -%} | |
| {{ 'down' }} | |
| {%- else -%} | |
| {{ '' }} | |
| {%- endif -%} | |
| {%- else -%} | |
| {{ 'single_press' }} | |
| {%- endif -%} | |
| amount: >- | |
| {%- if (trigger.event.data.args|list)|length == 3 -%} | |
| {%- set args = trigger.event.data.args|list -%} | |
| {{ args[1]|int }} | |
| {%- else -%} | |
| {{ 0 }} | |
| {%- endif -%} | |
| rate: >- | |
| {%- if (trigger.event.data.args|list)|length == 3 -%} | |
| {%- set args = trigger.event.data.args|list -%} | |
| {{ args|last|int }} | |
| {%- else -%} | |
| {{ 0 }} | |
| {%- endif -%} | |
| cmd_single_press: !input 'command_single_press' | |
| cmd_up: !input 'command_up' | |
| cmd_down: !input 'command_down' | |
| - choose: | |
| - conditions: | |
| - '{{ command == "toggle" }}' | |
| - '{{ cluster_id == 6 }}' | |
| - '{{ endpoint_id == 1 }}' | |
| sequence: | |
| - service: remote.send_command | |
| target: !input 'remote_entity' | |
| data: | |
| device: !input 'device_name' | |
| command: >- | |
| {%- set cmd = (cmd_single_press|string)|replace(', ', ',')|trim -%} | |
| {{ cmd.split(',') }} | |
| - conditions: | |
| - '{{ command == "step" }}' | |
| - '{{ cluster_id == 8 }}' | |
| - '{{ endpoint_id == 1 }}' | |
| - '{{ step_type == "up" }}' | |
| sequence: | |
| - service: remote.send_command | |
| target: !input 'remote_entity' | |
| data: | |
| num_repeats: '{{ (rate|int) + 1 }}' | |
| delay_secs: 0.1 | |
| hold_secs: 0.1 | |
| device: !input 'device_name' | |
| command: >- | |
| {%- set cmd = (cmd_up|string)|replace(', ', ',')|trim -%} | |
| {{ cmd.split(',') }} | |
| - conditions: | |
| - '{{ command == "step" }}' | |
| - '{{ cluster_id == 8 }}' | |
| - '{{ endpoint_id == 1 }}' | |
| - '{{ step_type == "down" }}' | |
| sequence: | |
| - service: remote.send_command | |
| target: !input 'remote_entity' | |
| data: | |
| num_repeats: '{{ (rate|int) + 1 }}' | |
| delay_secs: 0.1 | |
| hold_secs: 0.1 | |
| device: !input 'device_name' | |
| command: >- | |
| {%- set cmd = (cmd_down|string)|replace(', ', ',')|trim -%} | |
| {{ cmd.split(',') }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment