Well, I leave this in case it happens to someone, I solve it by deleting the Device and adding it again. He rarely did Blueprint automation but it didn’t reflect on the Devices he commanded.
Hello everyone,
here is my blueprint to use the Moes Smart Knob as Volume Controller. I’ve made it very flexible (no hardcoded media-controll). Hope you like it.
1: Your Moes Device
2: Your Media-Player to controll the volume
3. Optional (second) Device for the Button-Push-Action
4. What to when pushing the button (I use ADB from FireTV to Start / Pause Playback)
blueprint:
name: ZHA - Moes Tuya Smart Knob (TS004F) controller for media_player
description: Steuern Sie die Lautstärke des Media Players und setzen Sie Play/Pause darauf
domain: automation
input:
remote:
name: Remote
description: Moes Tuya Smart Knob-Gerät zur Verwendung
selector:
device:
integration: zha
model: TS004F
media_player:
name: MediaPlayer
description: Der MediaPlayer, der gesteuert werden soll
selector:
target:
entity:
domain: media_player
volume_step_size:
name: Volume Step Size
description: Wert der Drehung, der einer Lautstärke-Änderung von 1% entspricht
default: 13
selector:
number:
min: 1
max: 100
mode: slider
step: 1
secondary_media_player:
name: Secondary MediaPlayer
description: Ein weiterer MediaPlayer, der bei einem Tastendruck gesteuert werden soll
selector:
target:
entity:
domain: media_player
button_custom_action:
name: Button Custom Action
description: Benutzerdefinierte Aktion, die beim Tastendruck ausgeführt werden soll
selector:
action: {}
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 args %}
{% if 'StepMode.Up' in args %}
up
{% elif 'StepMode.Down' in args %}
down
{% endif %}
{% else %}
none
{% endif %}
amount: '{{ (args and args.split(",")[1] | int(default=50)) or 50 }}'
rate: '{{ (args and args.split(",")[2] | int(default=1)) or 1 }}'
volume_step_size: !input 'volume_step_size'
# --- Media Player ---
media_player_entity: !input 'media_player'
media_player_is_on: "{{ states(media_player_entity.entity_id) not in ['off', 'unavailable', 'idle'] }}" # Überprüft, ob der Media Player eingeschaltet oder am Abspielen ist.
- choose:
- conditions:
- '{{ command == "toggle" }}'
- '{{ cluster_id == 6 }}'
- '{{ endpoint_id == 1 }}'
sequence: !input 'button_custom_action'
- conditions:
- '{{ command == "step" }}'
- '{{ cluster_id == 8 }}'
- '{{ endpoint_id == 1 }}'
- '{{ media_player_is_on }}'
sequence:
- repeat:
count: '{{ rate }}'
sequence:
- service: media_player.volume_set
target: !input 'media_player'
data:
volume_level: >
{% set current_volume = state_attr(media_player_entity.entity_id, 'volume_level') | float %}
{% set volume_increment = (amount | float) / volume_step_size / 100 %}
{% if step_type == 'up' %}
{% set new_volume = current_volume + volume_increment %}
{% elif step_type == 'down' %}
{% set new_volume = current_volume - volume_increment %}
{% endif %}
{% set new_volume = new_volume if 0 <= new_volume <= 1 else 0 if new_volume < 0 else 1 %}
{{ new_volume }}
- delay: '00:00:01' # Eine konstante Verzögerung zwischen den Befehlen
I used some of the code from your blueprint and created a blueprint for anyone who wants to import it directly.
It also supports push and rotate, increase and decrease volume.
Here is the link to it : ZHA - Moes Smart Knob for Media Player · GitHub
Thanks, everyone, for contributing & improving on this blueprint to control media player volume & mute for the Moes Tuya (_TZ3000_4fjiwweb) TS004F Smart Knob (rotary dial). This has a high wife-acceptance factor in my home!
Any thoughts on adding double press functionality?
It turned out to be the zigbee coordinator firmware was bad. I rolled it back and it started working again.
I just picked up a couple of these today saw this thread. I’m using zigbee2mqtt and wanted the color temperature to work as well so I created this blueprint. It works in command mode and will set brightness (just turn the dial) and color temperature (press and turn the dial) as long as the light has max_mired and min_mired like the tplink bulbs I have do. It requires the mqtt topic to get the data from and uses the action_step_size to match the speed of the dial to how fast to change the brightness or color temp. Single press will toggle on and off.
blueprint:
name: Moes Dial Automation
description: Control brightness and color temperature with a Moes dial button
domain: automation
input:
target_light:
name: Lights
description: The light(s) with Mireds
selector:
entity:
filter:
- domain: light
mqtt_topic:
name: Device specific MQTT topic
description: Topic that the Moes dial publishes to
step_value:
name: Step Value
description: Used for configuring percentage of each step for brightness and color temperature
default: 5
selector:
number:
min: 1
max: 100
trigger:
- platform: mqtt
topic: !input mqtt_topic
action:
- variables:
command: "{{ trigger.payload_json.action }}"
size: "{{ trigger.payload_json.action_step_size }}"
target_light: !input target_light
light_temp: "{{ state_attr(target_light, 'color_temp') }}"
brigtness_step: 13
temperature_step: 18
pct_change: !input step_value
temp_pct_change: >-
{{ ((state_attr(target_light, 'max_mireds') -
state_attr(target_light, 'min_mireds')) /100 ) * pct_change }}
- choose:
- conditions:
- condition: template
value_template: "{{ trigger.payload_json.action == 'toggle' }}"
sequence:
- service: light.toggle
entity_id: !input target_light
- conditions:
- condition: template
value_template: "{{ command == 'brightness_step_up' }}"
sequence:
- service: light.turn_on
data:
brightness_step_pct: "{{ pct_change * (size / brigtness_step) }}"
target:
entity_id: !input target_light
- conditions:
- condition: template
value_template: "{{ command == 'brightness_step_down' }}"
sequence:
- service: light.turn_on
data:
brightness_step_pct: "{{ -pct_change * (size / brigtness_step) }}"
target:
entity_id: !input target_light
- conditions:
- condition: template
value_template: "{{ command == 'color_temperature_step_down' }}"
sequence:
- service: light.turn_on
metadata: {}
data:
color_temp: >-
{{ light_temp + (-temp_pct_change * (size / temperature_step)) |
int }}
target:
entity_id: !input target_light
- conditions:
- condition: template
value_template: "{{ command == 'color_temperature_step_up' }} "
sequence:
- service: light.turn_on
metadata: {}
data:
color_temp: >-
{{ light_temp + (temp_pct_change * (size / temperature_step)) |
int }}
target:
entity_id: !input target_light
mode: single
max_exceeded: silent
Thanks! I got stuck a little with this one as it didn’t respond very well to my actions and all was really slow. (Maybe because by default it doesn’t have “mode: restart”?). It sucked and was quite dissappointed with it.
But with this good blueprints, it’s quite OK. Thanks again.
I made a copy without the manufacturer lock, because I have “_TZ3000_qja6nq5z” there.
ZHA - Moes Smart Knob for lights (without manufacturer lock) (github.com)
Hello all !
I just discovered this device, and setting in up with your blueprint made it very easy to control things. Thanks to all of you !
At this time, I wondered if it’s possible to control devices instead of lights, that’s why I got my hands dirty and made a version inspired by the improved version of gonzaloalbito !
It’s my first blueprint so it’s possible that there are a few things that could be changed
And here is another version where step_size is used and mode is queued, so you it doesn’t matter how fast you rotate. It feels much smoother than the original.
I also removed al redundant conditions and manufacturer, since my device was different)
- press toggles the light
- rotate changes brightness
- press-rotate changes the color temperature (or hue, see next point)
- long press switches the lamp between rgb and color temperature
- tripple click switches the device into a separate mode where double click and long click are available. This blueprint just writes to the console but you can adapt as necessary
I removed the manufacturer lock too, as I found out it works perfectly with the more generic “Tuya Mini Smart Knob”
It works fine, thank you
I tried this version as well, but it is throwing an error.
Would someone be so kind and make a z2m version of that?
The blueprint has everything I am looking for.
I’ve just bought one of these, and I’ve used mateine’s blueprint as it looks like the latest on here.
Works fine for on / off and dimming, but I can’t get it to change the colour temperature.
Mine is a TS004F
by _TZ3000_qja6nq5z
It’s supposedly a “Moes” device, but it’s from AliExpress, so could easily be rebranded.
I can see there is an quirk loaded for it: Quirk: zhaquirks.tuya.ts004f.TuyaSmartRemote004FROK
I’ve not had to troubleshoot zigbee issues yet, and I don’t really understand the code in the blueprint for changing colour.
Any suggestions most welcome!
did you ever get it working with z2m?
I have not yet tried it.
Works like a charm. Any chanse to add turning left limit? So light doesnt turn off by turning knob left?