Aqara knob H1 (wireless) automations

So I’ve given this a shot however I seem to be getting this error at the bottom part

Error: Error rendering data template: UndefinedError: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'action_rotation_angle_speed'

this is the automation ive got

alias: Matt - Dim lamps test
description: ""
trigger:
  - platform: state
    entity_id: sensor.xxx_switch_action
    to:
      - start_rotating
      - rotation
action:
  - service: light.turn_on
    target:
      entity_id: light.xxx_lamps
    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 / 12 }}
        {%- else -%}
          {{ (trigger.to_state.attributes.action_rotation_angle | int / 12) * ((trigger.to_state.attributes.action_rotation_angle_speed | int / 24) | abs) }}
        {%- endif -%}
mode: single
max_exceeded: silent

And then when I look in the states area I see this

Are you using ZHA rather than Zigbee2MQTT? It looks like the attributes are not exposed on sensor.xxx_switch_action.

While you are in Deveoper Tools and States, turn the knob and see if anything else populates for it. If not, the automation will need to be modified to use sensor.xxx_switch_action_rotation_angle and sensor.xxx_switch_action_rotation_angle_speed rather than using trigger.to_state.attributes.action_rotation_angle and trigger.to_state.attributes.action_rotation_angle_speed.

I am not able to test or check this as I am not using ZHA. I am assuming you are as I can’t think why else the attributes are not being exposed.

Nah I’m on z2m but I added the device quite some time ago maybe they’ve changed it since because I’ve always had the attributes separated out :open_mouth: ill give it a repair and see if there is any change otherwise ill go with hard coding them in

I think its glitch on z2m, because its not show correctly current percent rotation WITHOUT CLICK.
but if you press to button and continue rotate, then you see a digits
change your trigger to

trigger:
  - platform: state
    entity_id:
      - sensor.0x54ef44100065408f_action_rotation_percent
    from: unknown

and it’s work

That’s strange. I don’t see that behaviour. I wonder if it’s related to the Zigbee coordinator. I’m using a Conbee II.

I’ve made two blueprints for this device:

1 Like

Don’t work in my system (
Select is empty
Aqara H1 Rotary Dial
Select the rotary dial you wish to use

But I have a couple of this dimmers (
What I doing wrong ?

Ah, are you using Z2M? This blueprint is for ZHA, sorry.

Ah, realy ?
Yes, I using Z2M )
I was inattentive ) Thanks !

Thank you, that’s awesome !
I would like to adapt it to my needs but I got this error message before modifying anything (after replacing entities, id’s and scenes also) :

Message malformed: extra keys not allowed @ data['0']

Do you know why? I’m beginning with YAML…

Thanks

hi @ robertwigley

when i use your code, the light turn on an off but the brightness not change.

thanx a lot @robertwigley !
I was looking for this for ages. Finaly found this Aqara H1 and with your automation it feels really intuitive!

grtz
Bart

Do you solve you problem with attributes ?

Thanks to everyone that has contributed to this post! I was able to get things working pretty intuitively for my H1 knob. Is there any chance anybody has solved how to change color temperature in place of brightness? When I try with the following it doesn’t work, but with brightness it works just fine.

service: light.turn_on
data:
  color_temp: >-
    {{ ((state_attr('light.living_room_normal','color_temp')|int(1)) + ((trigger.to_state.state|float(2))/2.55)|round(2)*3)|int(1) }}
target:
  entity_id: light.living_room_normal
enabled: true

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?
sensors

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? :frowning:
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.