Last active
June 4, 2024 05:49
-
-
Save blizzrdof77/c30c388ca5f4ce7ed72752296767417d to your computer and use it in GitHub Desktop.
ZHA - Moes Tuya Smart Knob (TS004F) controller for remote control devices
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 remote control 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/blizzrdof77/c30c388ca5f4ce7ed72752296767417d | |
input: | |
remote: | |
name: Smart Knob Device | |
description: Moes Tuya Smart Knob Device to use | |
selector: | |
device: | |
integration: zha | |
manufacturer: _TZ3000_4fjiwweb | |
model: TS004F | |
remote_entity: | |
name: Remote Entity | |
description: The remote to control | |
selector: | |
target: | |
entity: | |
domain: remote | |
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 }}' | |
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
Hi @PeterHindes --
I got rid of the unused input field
linked_entity_id
.Here is an example of an automation that is working for me.
This automation is configured to use my logitech harmony remote, using the device with an ID of
71580545
(you can find thedevice_name
in the harmony configuration file -- named something likeharmony_UNIQUE_ID.conf
in your HA config directory).The automation is configured to do the following:
VolumeUp
andVolumeDown
) to my receiver (via the harmony remote) when I turn the dial either direction.SpeakerA
command (toggles speaker group on my receiver) to my receiver (via the harmony remote) when I click the middle button on the smart knob.Automation
YAML
Screenshot