Aqara Buttons All-In-One [Zigbee2MQTT]

Ah yep, it is. In the blueprint I was able to correct the typo of ‘tripple’ and the command works OK now.

Blueprint updated!

Changelist:

  1. Fix typo of Triple action. Thanks @niko123456000

Hello,
I find this confusing.
The first sentence indicates that legacy triggers are required, so to be left enabled.
The second sentence (set legacy to false), means according to the site this links to:
legacy: Set to false to disable the legacy integration (highly recommended), will change structure of the published payload (default true). The value must be true or false.

Nevertheless, independently of my confusion, the blueprint works with my mini switch on first try :slight_smile:

homeassistant_legacy_triggers is not the same legacy in device options. About triggers see Z2M Responding to button clicks. By default homeassistant_legacy_triggers: true and if you haven’t touched this - you don’t need to do anything.

legacy: false in device section removes the deprecated click sensor (we use action sensor instead) and it’s not required, just a recommendation.

Hi. Same, I realized that the automation is being triggered 3-4 times every time, instead of 1 as it should.

I did some testing with a switch Helper to confirm it:


(of course, I only clicked once)

image

The blueprint is triggering multiple times because that’s how it works. You might a null trigger that wakes the switch, a real trigger, then a null trigger that turns the switch action off.

If you add a condition statement after the trigger, you can set it to only allow triggers into the rest of the blueprint that the blueprint can properly act on. You may still see the extra triggers, but the error log won’t spam on seeing the things that there is no action for.

I mentioned this to someone else here…

EDIT July 6 2022

So, this was a bit annoying because there are so many triggers, but I wrote it up for you folks upon a request… The owner of the main blueprint needs to edit it and add this as I cannot do that.

You can on your own add this to your copy. It should make sure that only valid triggers make the blueprint code execute. I don’t have any of the hardware so this team will need to take this test and troubleshoot it. It is pretty straightforward if you look at it. (here is a list of the triggers I can handle, ignore everything else) It will still trigger on garbage, but those are trapped as not matching the condition and will just show up as an empty trace.

Sorry in advance if there is a typo…

Add this after the trigger, before the action:

condition:
  condition: template
  value_template: '{{ trigger.to_state.attributes.action in ( ''single'',''double'',''triple'',''quadruple'',''hold'',''release'',''shake'',''single_left'',''double_left'',''triple_left'',''hold_left'',''release_left'',''single_right'',''double_right'',''triple_right'',''hold_right'',''release_right'',''single_center'',''double_center'',''triple_center'',''hold_center'',''release_center'',''single_both'',''double_both'',''triple_both'',''hold_both'',''release_both'') }}'

If you still cannot see the trace you want, simply tell HA to add more traces…

2 Likes

Hi. I am using this blueprint since a lot of time. Since yesterday everything worked fine but, since I added some Philips Hue on my Home Assistant Zigbbee2MQTT, the release Actions of my aqara buttons stopped working and I cant understand why… I tried disabling any buttons automation and recreate everything from beginning but there is no way to make it work anymore…

I tryied to lounch any kind of service using single button release and multiple button release but nothing happens… Any Idea?

@Drafted Thanks so much for creating and sharing this blueprint! I’ve successfully used it with my new Aqara Wireless Mini Switch model WXKG11LM for single and double click actions. I am getting an error in my logs though,

Logger: homeassistant.helpers.template
Source: helpers/template.py:147
First occurred: 6 January 2023 at 19:04:48 (8 occurrences)
Last logged: 6 January 2023 at 19:59:28

Template variable warning: 'homeassistant.util.read_only_dict.ReadOnlyDict object' has no attribute 'action' when rendering '{{ trigger.to_state.attributes.action if trigger.to_state.state == "" else trigger.to_state.state }}'

Any idea how to resolve to prevent this error?

I would advise everyone to use a more modern and native way to bind actions to buttons without using blueprints:

  1. Create a new empty automation.
  2. In the When section, click on Add trigger and choose Device. Select your device and the desired trigger (e.g., “single_left” action), then set the Trigger ID (e.g., single_left) by clicking Edit ID in the options menu (three dots). If the action you’re looking for doesn’t appear, perform the action on your device, and it will show up in the list (you may also need to refresh the page in the browser).
  3. Repeat step 2 for each trigger type you need (double, hold, etc…)

  1. In the When section, click on Add building blocks and choose If-then.
  2. In the If section click Add condition and choose Triggered by (from Other conditions menu). Next, select the trigger ID you want, such as single_left.
  3. In the Then section, click Add action select the desired action, e.g. toggle entity.

  1. Repeat step 4 for each trigger ID and save your changes.
  2. Enjoy!
11 Likes

Oddly that’s exactly what I started doing originally with my Aqara buttons, but I couldn’t get the desired functions to work. I found the blueprint after a search and thought I would try it, and the single and double clicks instantly worked, so I was definitely doing something wrong somehow with my original automation.

I’ve gone back and set the automation up successfully without the blueprint now, after double checking the steps with your screenshots, so thank you for taking the time to post the above.

One final thing I can’t figure out yet, and it may be trying to do too much with a single button, is using the hold action event trigger. My button sends a hold as well as a release action event through Z2M.
I would like to use the hold for dimming of one bulb.

  1. Hold button - Brightness increases to max possible until button released.
  2. Hold button - Brightness decreases to minimum possible until button released.
    I would just like to cycle the function, based on the previous function. So if brightness increased on previous hold, then decrease on the next hold until released, and vice versa.

Can anyone help with how this could be setup, or does it involve a lot of configuration, in which case, it may be better to just keep the button for single and double presses, and use the HA mobile app dashboard to change brightness as and when that is required, or look at a dedicated dimmer like the hue v2 with dedicated function buttons?

2 Likes

I’m new to using momentary action switches but was able to use both your blueprint and your manual instructions successfully for a simple minded device on-off automation as a test.

I have a complex automation that I’m currently starting from a click on the HA dashboard that I’d also like to start from a physical click on one or more these switches. Since the action portion is embedded in an automation itself, is it possible to direct it to an automation rather than to a device?

Thanks.

Thanks for this amazing blueprint, made my life a lot easier!
I had to customize it to include the action “many” from this device, so if you’re still updating this would be helpful for other people!

Could you add the new aqara knob h1?

I feel the same way as @fir3drag0n. Could you create a blueprint for Aqara H1 knob? product model is “ZNXNKG02LM”

Any progress on this?

Separate issue I ran into as of 2023.7.1 (may have been broken before, but I recently updated to a newer version of this Blueprint via this updater script: GitHub - koter84/HomeAssistant_Blueprints_Update: This is a script to automatically check for updates for your HA Blueprints

As a result of one/both of those changes, all my automations using this blueprint failed with the following error:

message malformed: invalid template (templatesyntaxerror: unexpected char '\\' at 67) for dictionary value @ data['action'][0]['variables']['command']

Anyways, I had to manually edit the blueprint to fix the issue.

  1. Open blueprint yaml under config/blueprint/automation/ in file editor
  2. Edit command on 186 from '{{ trigger.to_state.attributes.action if trigger.to_state.state == "" else trigger.to_state.state }}' to the former value of '{{ trigger.to_state.state }}'.
  3. Restart home assistant, and all my automations worked again.

It looks like you can just change the line to:

command: '{{ trigger.to_state.attributes.action if trigger.to_state.state == "" else trigger.to_state.state }}'

Which is what the official blueprint syntax is. Looks like the update script may be parsing the source incorrectly and it escaped the double double quotes.

Works for me with that edit :slight_smile:

Hey @Scoff ; have you find a way to manage this ? I’m looking to the exact same behavior too.

@Drafted : Any recommendation for this ?

Hey @flowerpower , I ended up using AppDaemon and ControllerX with Z2M in order to achieve the single click, double click and hold dimming functionality - works perfectly :slightly_smiling_face:

Great idea !! I just had a look and it fits the needs :wink: Thanks !