-
-
Save rhl2401/871cdc129c2d61f894407bef4b44f07d to your computer and use it in GitHub Desktop.
| blueprint: | |
| name: Aqara Wireless Switch (single, double, hold, release) | |
| description: 'Control anything using Aqara Wireless Switch. | |
| Customizable actions for each press. | |
| This version of the blueprint is for buttons supporting single, double, hold and | |
| release actions. ' | |
| domain: automation | |
| input: | |
| action_sensor: | |
| name: Action Sensor | |
| description: Zigbee2mqtt action sensor | |
| selector: | |
| entity: | |
| integration: mqtt | |
| domain: sensor | |
| multiple: false | |
| 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_hold: | |
| name: Button hold | |
| description: Action to run on hold | |
| default: [] | |
| selector: | |
| action: {} | |
| press_release: | |
| name: Button release | |
| description: Action to run on release | |
| default: [] | |
| selector: | |
| action: {} | |
| mode: restart | |
| max_exceeded: silent | |
| trigger: | |
| platform: state | |
| entity_id: !input action_sensor | |
| condition: | |
| - condition: template | |
| value_template: '{{ (trigger.to_state.attributes.action if trigger.to_state.state == "" | |
| else trigger.to_state.state) in ("single","double","hold","release") | |
| }}' | |
| action: | |
| - variables: | |
| command: '{{ trigger.to_state.attributes.action if trigger.to_state.state == "" | |
| else trigger.to_state.state }}' | |
| - choose: | |
| - conditions: | |
| - '{{ command == ''single'' }}' | |
| sequence: !input press_single | |
| - conditions: | |
| - '{{ command == ''double'' }}' | |
| sequence: !input press_double | |
| - conditions: | |
| - '{{ command == ''hold'' }}' | |
| sequence: !input press_hold | |
| - conditions: | |
| - '{{ command == ''release'' }}' | |
| sequence: !input press_release |
Is there a possibility to update this to the new z2m 2.0 version?
@Estradamis
I'm no longer working on this blueprint as I no longer have the Aquara button, thus no way to test.
If anyone can commit an update to make this compatible with Z2M 2.0, I will gladly accept and implement the changes.
It looks like @ovizii came across the same breaking changes voluntarily that Z2M 2.0 now enforces. @Estradamis, @rhl2401, I have forked this gist and refactored it to use MQTT device triggers as per the Z2M2.0 upgrade recommendations at Koenkk/zigbee2mqtt#24198.
The updated gist can be found at https://gist.github.com/denselm/5049daf0d2812c8b6ae9a6dc298f471c
Also gave it a go as a learning experience https://gist.github.com/stncttr908/d0417344a66ab8cc1230a7ead3f5df68
Unfortunately, it doesn't look like MQTT device triggers support templates so I suspect supporting multiple devices in trigger an action in the same automation will require a refactor to use MQTT topic triggers and parse out the triggered device ids instead.
I made some changes in Z2M and now your blueprint does not work for me anymore. I had actually an older version of your blueprint, Instead of input: action_sensor: I think my copy used a switch as input. Anyway, this current version here does not "see" my WXKG11LM
I click "create automation" next to your blueprint and it cannot find any matching entity. If I type my friendly name of my WXKG11LM I am only presented with these entities:
Any idea what the problem could be? The changes I made to Z2M were to turn off all legacy options I could find. For mqtt as well as for HA and the WXKG11LM has it legacy option turned off:
