Last active
December 22, 2024 09:34
-
-
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 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 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(',') }} |
I am using the following equipment / integrations:
Equipment
- Moes Tuya ZigBee control Smart Knob Switch Controller (model
TS004F
) - Logitech Harmony Hub (model
O-R0004
) - Conbee II Universal Zigbee USB Gateway (model
BN-600107
)
Home Assistant Install
Home Assistant Integrations
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 the device_name
in the harmony configuration file -- named something like harmony_UNIQUE_ID.conf
in your HA config directory).
The automation is configured to do the following:
- Send the volume up/down commands (
VolumeUp
andVolumeDown
) to my receiver (via the harmony remote) when I turn the dial either direction. - Send the
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
# automation:
- id: zigbee_moes_tuya_rotary_smart_knob_remote_controller_1
alias: Zigbee Moes Tuya Rotary Smart Knob Remote Controller [1]
description: Controls all ZHA events from the Moes Tuya zigbee smart knob dial button device for an associated remote. [1]
use_blueprint:
path: zigbee/zha-moes-zigbee-rotary-smart-knob-remote-control.yaml
input:
remote: 2816a049692c64054da731a246c2b007
remote_entity:
entity_id: remote.log_harmony_bop_hub
device_name: '71580545'
command_single_press: SpeakerA
command_up: VolumeUp
command_down: VolumeDown
Screenshot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I cant seem to get this to work with mine. How is it supposed to work? Can you show a screenshot?