Note: There is quite a similar wireless switch out there which looks exactly like the one this blueprint can be used for but it has different button press actions (e.g. long press) which this blueprint doesn’t support.
Import the blueprint by clicking the badge
or using the forum topic URL!
Changelog
2024-04-05: Changed mode to queued
2023-05-15: Removed attribute: click
2021-02-04: Adjust name of blueprint to differ from the similar switch with different types of button presses
2021-01-07: Added mqtt as integration type for the sensor
2020-12-22: Initial version
blueprint:
name: Aqara Wireless Switch (single, double, triple, quadruple)
description: 'Control anything using Aqara Wireless Switch'
domain: automation
input:
switch:
name: Switch
description: Action sensor of Aqara Wireless Switch to use
selector:
entity:
domain: sensor
integration: mqtt
press_single:
name: Single button press
description: Action to run on single button press
default: []
selector:
action: {}
press_double:
name: Double button press
description: Action to run on double button press
default: []
selector:
action: {}
press_triple:
name: Triple button press
description: Action to run on double triple press
default: []
selector:
action: {}
press_quadruple:
name: Quadruple button press
description: Action to run on double quadruple press
default: []
selector:
action: {}
mode: queued
max_exceeded: silent
trigger:
- platform: state
entity_id: !input switch
action:
- variables:
command: "{{ trigger.to_state.state }}"
- choose:
- conditions:
- "{{ command == 'single' }}"
sequence: !input press_single
- conditions:
- "{{ command == 'double' }}"
sequence: !input press_double
- conditions:
- "{{ command == 'triple' }}"
sequence: !input press_triple
- conditions:
- "{{ command == 'quadruple' }}"
sequence: !input press_quadruple
Seems to work flawlessly with my buttons. The only improvement I could come up with for now is that adding the line integration: mqtt under entity for the input device will limit the number of selectable sensors.
The first section would then look like:
blueprint:
name: Aqara Wireless Switch
description: 'Control anything using Aqara Wireless Switch'
domain: automation
input:
switch:
name: Switch
description: Action sensor of Aqara Wireless Switch to use
selector:
entity:
domain: sensor
integration: mqtt
Can you please check if really no change has been made to the file? I just compared the different versions of the code and other than the changes I wanted to make no differences are present.
To be honest with you I very recently made the switch from Zigbee2MQTT to the native ZHA integration so I cannot fully verify functionality. But since I switched I just changed this line:
Could you describe again a little more precisely what you want to do? This blueprint is designed to match the return commands of the entity created by Zigbee2MQTT
As I don’t own a switch that sends the long-pressed command I can’t help you on this one either. But are you sure that it does send that command to Zigbee2MQTT? Or do you want me to integrate another command from a button into this blueprint?
Yes, i’m sure. it sends the “release” command when the button was released and then you can build an automation on duration the button was hold. for example hold 3 seconds = turn off single light, hold 5 seconds = turn off all light.
I solved it like this:
sorry I’m a newbie in HA. I’ve set my HA on a raspberry soon, with zigbee2mqtt. It works fine.
I’ve just bought an aqara switch [WRS-R02] Xiaomi WRS-R02 control via MQTT | Zigbee2MQTT with 2 buttons. It’s supposed to have single, double, long press … actions but when I try to add an automatisation, the only actions I have are : button1_single/triple, button2_single, toggle1.
Does this blueprint can help me? I’ve searched in this forum and zigbee2mqtt but I didn’t found anything good.
Hi @bertrand, glad to have you on board with HA
I’m sorry, but this blueprint won’t do for you. I designed it specifically for the button above. You’ll probably have to write your own blueprint. After a quick search, I found this blueprint, which is only for ZHA, but could serve as an example for a Xiaomi switch with two buttons. Combine it with this blueprint and it should quite easily do the trick.
Sorry for the late answer. I sadly cannot help you with the blueprint, as I changed my setup. I know that it used to work but don’t know if they changed something fundamental about blueprints…
I came across this while migrating from ZHA to Zigbee2MQTT and debugged the issue for why it wasn’t working. You can remove the “attribute: click” line in the trigger as the single/double/etc action is stored in the main state. With that change, it should work.
I hope that someone can help : I am trying to use the blueprint to control a number of lights/group of lights together
“single” action → light.turn_on for all of the individual lights devices or the group entity
“double” action → light.turn_off for all of the individual lights devices or the group entity
Everythig works well with this blueprint as long as there is only one device to control.
As soon as there is a group of lights or multiple individual lights devices (even calling up a scene or a separate automation that control >1 light) it no longer works well ?
Am I the only one in this situation ?
I have checked that the action reports correctly in mqtt_explorer and in the log.
When manually running the light.turn_on from a group of lights everything works well but if that same action on a group of light follows the wirelss switch action trigger it no longer works ???
Am I really the only one in this same situation ?
Have others tried to control more than one device using the blueprint action trigger ?