I’ve added a new feature to the blueprint and zigbee2mqtt. It now allows for color_temperature control action, that enbles color temperature control of your lamp, or control other devices brightness, volume etc.
In my example I’ve used the action to control the brightness of my led strip, but you’re free to use it for volume control, color temperature control and anything else.
I’ve also included an example for color temperature control, because it wasn’t straight forward (atleast for me).
Hi, sorry if this is high jacking your post but you seem to be the only source of useful information for this device.
I’m using this to control a input number helper 0-5 which correlates to 6 individual RF commands through RM pro to my fan.
I’d like it to register the commands faster so if i rotate right quickly it will jump to higher fan speeds without having to go through each step. Can this method be used to achieve this result?
Also, I’ve been trying to work out the difference between command and event modes, can you explain? I tried switching to command mode but everything stopped working, so guess I would have to recreate all the automations to find out and its taken me months just to get it working so I’m not in a hurry to do that yet. I do have a second unit so maybe ill try it over Christmas if needed.
Thanks a lot for the blueprint. I managed to get it working. Just a question though, is there a way to limit brightness so it doesn’t turn off the light when the knob is rotated all the way?
I want the button to toggle the lights and the rotation to determine brightness. Rotating too far shouldn’t turn the lights off.
You most likely can fix this by doing some templating magic. Like an if statement, that checks if the brightness percent goes negative.
Means that you need to fetch the brightness from your lamp, calculate the brightness step as before and then add the step to your brightness and check if it’s equal or greater than 1, if it’s 0, home assistant will turn it off
I just started with Zigbee2MQTT and prefer the event entities, so I adjusted your blueprint somewhat to work with that. I also added a few features, such as that you can assign something to the rotation while the button is pressed (the color_temp mode) and you can adjust the sensitivity.
blueprint:
name: Universal Smart Knob Control
description: Control any entity with a Smart Knob using customizable rotation and click actions
domain: automation
input:
brightness_delta_sensor:
name: Brightness Delta Sensor
description: Sensor providing brightness delta values from Smart Knob rotation
selector:
entity:
filter:
domain: sensor
integration: mqtt
step_size_sensor:
name: Action Step Size Sensor
description: Sensor providing the step size unsigned, can be used with the pressed rotation
selector:
entity:
filter:
domain: sensor
integration: mqtt
event_entity:
name: Smart Knob Event Sensor
description: Sensor providing all events from the knob (toggle and rotations)
selector:
entity:
filter:
domain: event
integration: mqtt
sensitivity_brightness:
name: Sensitivity Brightness
description: factor the delta_value for the brightness action is multiplied with to adjust the strength of the control
selector:
number:
min: 0.01
max: 10
step: 0.01
mode: box
default: 0.5
sensitivity_color:
name: Sensitivity Color
description: factor the delta_value for the color action is multiplied with to adjust the strength of the control
selector:
number:
min: 0.01
max: 10
step: 0.01
mode: box
default: 0.5
rotation_action:
name: Rotation Action
description: Action to execute when rotating the knob. Uses 'delta_value' variable for the rotation value.
default: []
selector:
action: {}
color_rotation_action:
name: Color Rotation Action
description: Action to execute when rotating the knob while pressed. Uses 'delta_value' variable for the rotation value.
default: []
selector:
action: {}
click_action:
name: Click Action
description: Action to execute when clicking the knob
default: []
selector:
action: {}
mode: parallel
max_exceeded: silent
variables:
event_entity: !input event_entity
brightness_delta_sensor: !input brightness_delta_sensor
step_size_sensor: !input step_size_sensor
trigger:
- trigger: state
entity_id: !input event_entity
condition:
- condition: template
value_template: >
{{ trigger.to_state.state not in ['unavailable', 'unknown'] }}
- condition: template
value_template: >
{{ trigger.from_state.state not in ['unavailable', 'unknown'] }}
action:
- variables:
sensitivity_brightness: !input sensitivity_brightness
sensitivity_color: !input sensitivity_color
command: "{{ state_attr(event_entity, 'event_type') }}"
brightness_delta: "{{ states(brightness_delta_sensor) | float(0) * sensitivity_brightness }}"
step_size: "{{ states(step_size_sensor) | float(0) * sensitivity_color }}"
- choose:
# Handle rotation action
- conditions:
- condition: template
value_template: >
{{ command == 'brightness_step' }}
sequence:
- variables:
delta_value: "{{ brightness_delta }}"
- alias: "Execute rotation action"
sequence: !input rotation_action
# Handle color rotation action up
- conditions:
- condition: template
value_template: >
{{ command == 'color_temperature_step_up' }}
sequence:
- variables:
delta_value: "{{ step_size }}"
- alias: "Execute color rotation action"
sequence: !input color_rotation_action
# Handle color rotation action down
- conditions:
- condition: template
value_template: >
{{ command == 'color_temperature_step_down' }}
sequence:
- variables:
delta_value: "{{ - step_size }}"
- alias: "Execute color rotation action"
sequence: !input color_rotation_action
# Handle click action
- conditions:
- condition: template
value_template: >
{{ command == 'toggle' }}
sequence:
- alias: "Execute click action"
sequence: !input click_action
default:
- action: logbook.log
data:
name: "Smart Knob Debug"
message: "Unhandled command: {{ command }}"
[edit] I have learned you also need to protect against a from_state that is unavaible, this sometimes happens pontaneously (I don’t know why) and on restarts of z2mqtt.
Hello.
I’m trying out this blueprint but I cannot get the rotation to work. The click to turn the lights on and off does work however.
I think I’ve followed the necessary steps but I guess I’m doing something wrong.
I can see “Smart knob custom” in Z2M for the knob’s description.
I’m attempting to control a Z2M group of lights called “bedroom_lights”
This is my yaml for the automation. Any help is appreciated!
Hello. I also have problems with setting my knob. Perhaps someone can help me.
I have installed the external converter successfully. The description and the picture of the knob in the MQTT UI changed to “Smart knob custom”
The exact knob model I am having is reported in MQTT as: _TZ3000_402vrq2i
The blueprint is also installed in the folder and responding when I create an automation.
The problem is I don’t see the click action (sensor.knob_action) in the suggested entities:
You’re not doing anything wrong. Since the end of last year, Z2M was updated to v2.0.0 and the action sensor was disabled by default as one of the breaking changes.
You have 2 options:
Set legacy_action_sensor: true in the Z2M config (it’s also available as an option in the Z2M Settings page)
Use the new Z2M events for your automation as shown in this post instead.
I just wen through the story of setting up this knob - finally got there - thank you all!
For anyone looking for help - once you got the knob configured as in the docs (still need the converter), use template from sophof post from above (Tuya smart knob improved blueprint for Zigbee2Mqtt - #13 by sophof), add it as a new template (Creating an automation blueprint - Home Assistant), reload your automations and create an automation with the blueprint via GUI - fill in all actions related to the knob itself and then just the click action and save. Then edit it with YAML to fill in the “custom” stuff and the rotations. Here’s my YAML of the automation:
alias: Garderoba - Universal Smart Knob Control - v2
description: ""
use_blueprint:
path: MyOwn/Smart Knob.yaml
input:
brightness_delta_sensor: sensor.garderoba_wylacznik_action_brightness_delta
step_size_sensor: sensor.garderoba_wylacznik_action_step_size
event_entity: event.garderoba_wylacznik_action
click_action:
- action: light.toggle
target:
entity_id:
- light.garderoba_swiatla_grupa
data:
transition: 1
rotation_action:
- action: light.turn_on
target:
entity_id:
- light.garderoba_swiatla_grupa
data:
brightness: >
{% set current = state_attr('light.garderoba_swiatla_grupa',
'brightness') | int %} {% set new = current + delta_value | int %}
{% set min_brightness = 5 %} {% set max_brightness = 255 %} {{
[min_brightness, [new, max_brightness]|min]|max }}
transition: 1
color_rotation_action:
- action: light.turn_on
target:
entity_id:
- light.garderoba_swiatla_grupa
data:
color_temp: >
{% set current = state_attr('light.garderoba_swiatla_grupa',
'color_temp') | int %} {% set new = current + delta_value | int %}
{% set min_ct = 250 %} {% set max_ct = 454 %} {{ [min_ct, [new,
max_ct]|min]|max }}
transition: 2
sensitivity_brightness: 2
sensitivity_color: 2