The light you want to control must have a color temp attributes.
If there is an option other than color_temp, you will need to modify your code to the correct value, not color_temp.
With the same code I have no problem to control
color temp attributes, should like this.
Thanks so much for your answer. It’s really weird behaviour, my lights have the color_temp attribute and I can change that manually just fine. These are IKEA lights and I can control the color temperature with an IKEA 5 button controller under ZHA, but not with H1 under Z2M and this code.
Is it me or has z2m changed some of these from attributes of the action to separate sensors thus the above code samples don’t work anymore?
Thank you. Its working.
So I am ablue to use Aqara Knob H1 Dial Switch with my lights. Amazing :).
I would like to use Aqara H1 Double Switch Remote with my roller shutter. But I found an issue. There are no support for HOLD RELEASE event?
I want to start moving on HOLD and stop moving on RELEASE. But i am not able to do that.
Which H1 switch are you using? I have the Single Rocker with Neutral, Double Rocker with Neutral and the Double Rocker Wireless Remote ones and none of them support the release
event/action. The wireless one does support hold_left
, hold_right
and hold_both
. I don’t think you should need the release
event/action to be able to control the blinds though as the hold
events\actions should do the job.
If you do need the release
event/action, you could use the Wireless Mini Switch (Button), as that does support both hold
and release
events/actions.
Another other option, if yours don’t have the hold
events\actions for some reason is to use a single-click to start movement and a double-click to stop movement. Or, if your roller blinds update their state quick enough, you could use a condition so that a single-click starts and stops them depending on whether they are in motion or not.
I am using Shelly double switch relay to control blinds. So my setup with Aqara Switch is like this:
-Single left click - blind toggle direction up (so start moving when idle and stop moving when not idle)
-Single right click - same with direction down
But I wanted to add option which I used with Philips Hue Dimmer Switches. When I hold button, blinds should be in moving and when I release, blinds should stop.
Now I know, that this is not possible with Aqara becouse there is lack of support :(.
I moved from Philips Hue Dimmer Switch becouse of design - i love Aqara design.
I think I have no option today with any switch. I think with Fibaro Walli it should work, but there is no battery version.
I loved on Aqara Switches, that there are also battery versions.
Thanks to your help, I was able to assign my Aqara H1 Wireless Dimmer with all the functions that I already know from the Yeelight Bluetooth dimmers when connected directly to the lamps.
The Aqara is connected via z2m and I use Yeelight lamps.
Due to the integration via z2m, you have to note that the normal Rotate changes its values via attribute and the Hold and Rotate must be queried via the separate entity states.
Here is my code for a single dimmer to control a lamp.
Single Click: switches the lamp on or off
Double Click: switches to moonlight mode and back
Rotate left/right: increases or decreases the brightness
Hold and Rotate left/right: increases or decreases the color temperature
alias: Light - Aqara H1 Dimmer
description: ""
trigger:
- platform: state
entity_id:
- sensor.bedroom_dimmer_table_action
- sensor.bedroom_dimmer_table_action_rotation_angle_speed
id: BedroomDimmerTable
condition: []
action:
- alias: Bedroom - Yeelight
if:
- condition: trigger
id:
- BedroomDimmerTable
then:
- alias: Dimmer Types
choose:
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'single' }}"
sequence:
- type: toggle
entity_id: light.yeelight_bedroom
domain: light
alias: Single_click
- conditions:
- condition: template
value_template: "{{ trigger.to_state.state == 'double' }}"
sequence:
- if:
- condition: state
entity_id: light.yeelight_bedroom
attribute: night_light
state: false
then:
- service: yeelight.set_mode
metadata: {}
data:
mode: moonlight
target:
entity_id: light.yeelight_bedroom
else:
- service: yeelight.set_mode
metadata: {}
data:
mode: normal
target:
entity_id: light.yeelight_bedroom
alias: Double_click
- conditions:
- condition: template
value_template: >-
{{ trigger.to_state.state == 'start_rotating' or
trigger.to_state.state == 'rotating' }}
sequence:
- service: light.turn_on
metadata: {}
data:
brightness_step_pct: >-
{%- if
((trigger.to_state.attributes.action_rotation_angle_speed |
int / 24) | abs) < 1 -%}
{{ trigger.to_state.attributes.action_rotation_angle | int / 2 }}
{%- else -%}
{{ (trigger.to_state.attributes.action_rotation_angle | int / 2) * ((trigger.to_state.attributes.action_rotation_angle_speed | int / 24) | abs) }}
{%- endif -%}
target:
entity_id: light.yeelight_bedroom
alias: Rotate left or right
- conditions:
- condition: template
value_template: >-
{{ trigger.to_state.entity_id ==
'sensor.bedroom_dimmer_table_action_rotation_angle_speed'
}}
sequence:
- service: light.turn_on
metadata: {}
data:
color_temp: >-
{{
((state_attr('light.yeelight_bedroom','color_temp')|int(1))
+
((trigger.to_state.state|float(2))/2.55)|round(2)*3)|int(1)
}}
target:
entity_id: light.yeelight_bedroom
alias: Hold and Rotate left or right
mode: restart
edit:
Unfortunately, there are still some errors hidden in my code.
The trigger for color_temp “trigger.to_state.entity_id == 'sensor.bedroom_dimmer_table_action_rotation_angle_speed” is not correct as it is also triggered in the idle state and therefore the light simply switches on without any operation.
I’ve tried to reproduce this automation, and as far as I see it’s an exact copy from @TDCroPower with replaced entity names but it seems it does not work for me. The light on which I’m testing is dimmable and has multiple colors.
The reason I’m experimenting with this automation is that I want to make a sound volume up/down automation, which I have already achieved with a numeric state above 0 (for up) or below 0 (for down) using “livingroom-media-vol Action rotation percent” but it seems it always make two steps with volume, when starting a rotation and when finishing it, even when making only one step with the knob.
Did you guys observe the same behavior with the knob? (Using Zigbee2Mqtt 1.36.1)
This is what I came up with, but as mentioned I would like to avoid making two steps on the volume:
alias: "Livingroom TV: Volume Down"
description: ""
trigger:
- platform: state
entity_id:
- sensor.livingroom_media_play_action
to: 3_single
id: ltv-voldn-s
- platform: state
entity_id:
- sensor.livingroom_media_play_action
to: 3_double
id: ltv-voldn-d
enabled: false
- platform: numeric_state
entity_id:
- sensor.livingroom_media_vol_action_rotation_percent
below: 0
id: livingroom-media-vol-dn-1
enabled: true
condition: []
action:
- choose:
- conditions:
- condition: trigger
id:
- ltv-voldn-s
- livingroom-media-vol-dn-1
sequence:
- service: script.turn_on
data: {}
target:
entity_id: script.livingroom_tv_volume_down
- conditions:
- condition: trigger
id:
- ltv-voldn-d
sequence:
- service: script.turn_on
data: {}
target:
entity_id: script.livingroom_tv_volume_down
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 300
- service: script.turn_on
data: {}
target:
entity_id: script.livingroom_tv_volume_down
mode: parallel
max: 10
Finally had some time to wrap my head around this and based on the ideas flying around above realised it the solution was all along right in front of me, so managed to to fix the double steps performed by the rotary knob. Thanks for the idea @AUkkers
The aim in my use-case is to perform just one (and exactly only one) simple action with one step of rotation, in my former use-case to adjust volume and later case to seek in a video.
Sharing the solution below, maybe would be useful for others aswell.
This was the important part I was missing:
to:
- start_rotating
- rotation
Rotate Left:
alias: "Livingroom TV: Left"
description: ""
triggers:
- trigger: state
entity_id: sensor.livingroom_media_vol_action
to:
- start_rotating
- rotation
enabled: true
conditions:
- condition: numeric_state
entity_id: sensor.livingroom_media_vol_action_rotation_percent
below: 0
enabled: true
actions:
- action: script.turn_on
target:
entity_id: script.livingroom_tv_left
data: {}
mode: restart
Rotate right:
alias: "Livingroom TV: Right"
description: ""
triggers:
- trigger: state
entity_id: sensor.livingroom_media_vol_action
to:
- start_rotating
- rotation
conditions:
- condition: numeric_state
entity_id: sensor.livingroom_media_vol_action_rotation_percent
above: 0
actions:
- action: script.turn_on
target:
entity_id: script.livingroom_tv_right
data: {}
enabled: true
mode: restart
Keywords: ZNXNKG02LM | Aqara Knob H1
Has anyone got this setup to control their blinds? Planning to do this, would like to know if it works well. I have a mix of aqara and tuya blind chain motors but planning to change to zemismart tubular motors.
Assuming you would want step control over the blinds you could use my solution right above.
You just need to create the relevant scripts for each direction for stepping the motor one bit and reference them, then you could just rotate the knob as much as you want for the blinds to open/close.