Forked from rhl2401/zigbee2mqtt_aqara_wireless_switch.yaml
Last active
September 1, 2026 16:47
-
-
Save CrazyCoder/1dc0767b620ccd8535e6a11f9a983d13 to your computer and use it in GitHub Desktop.
Aqara Wireless Switch (single, double, hold, release)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: | |
| controller_device: | |
| name: Aqara Wireless Switch | |
| description: Select the Aqara wireless switch device | |
| selector: | |
| device: | |
| filter: | |
| - integration: mqtt | |
| manufacturer: Aqara | |
| model: Wireless mini switch | |
| automation_mode: | |
| name: Automation mode | |
| description: >- | |
| Leave this alone unless an action in this automation runs for longer | |
| than about a second. The device sends several events for one gesture, | |
| about a second apart, and with 'restart' a later event cancels the | |
| action that an earlier event started. A long action belongs in a script | |
| that you call with 'script.turn_on', which no mode can interrupt. | |
| default: restart | |
| selector: | |
| select: | |
| mode: dropdown | |
| options: | |
| - single | |
| - restart | |
| - queued | |
| - parallel | |
| 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: {} | |
| source_url: https://gist.github.com/CrazyCoder/1dc0767b620ccd8535e6a11f9a983d13 | |
| mode: !input automation_mode | |
| trigger: | |
| - trigger: device | |
| id: single | |
| domain: mqtt | |
| device_id: !input controller_device | |
| type: action | |
| subtype: single | |
| - trigger: device | |
| id: double | |
| domain: mqtt | |
| device_id: !input controller_device | |
| type: action | |
| subtype: double | |
| - trigger: device | |
| id: hold | |
| domain: mqtt | |
| device_id: !input controller_device | |
| type: action | |
| subtype: hold | |
| - trigger: device | |
| id: release | |
| domain: mqtt | |
| device_id: !input controller_device | |
| type: action | |
| subtype: release | |
| action: | |
| - choose: | |
| - conditions: | |
| - condition: trigger | |
| id: single | |
| sequence: !input press_single | |
| - conditions: | |
| - condition: trigger | |
| id: double | |
| sequence: !input press_double | |
| - conditions: | |
| - condition: trigger | |
| id: hold | |
| sequence: !input press_hold | |
| - conditions: | |
| - condition: trigger | |
| id: release | |
| sequence: !input press_release |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The blueprint now has an
automation_modeinput. The default isrestart, which is what the blueprint used before, so an existing automation keeps its behaviour.Change it only if an action in one branch runs for longer than about a second. One gesture produces several events. A hold sends
hold, thenreleaseabout one second later. Withrestartthereleaseevent cancels the action thatholdstarted.Measured here on 2026-09-01. The button sent
holdat 08:14:51 andreleaseat 08:14:52. The automation called a script that turns on a buzzer, announces over TTS, waits 10 seconds, then closes a garage door. The script entity wentonat 08:14:51 andoffat 08:14:52. It never reached the delay, so the door stayed open. Home Assistant logged no error, and the buzzer still sounded, so it looked like a partial success.A mode change is not the best fix for that case. Call the script with
action: script.turn_onand atarget:instead. Home Assistant then runs it in its own task, outside the caller's cancellation scope, so no automation mode can cancel it.script.turn_offstill stops it when you want to abort.Home Assistant substitutes blueprint inputs before it validates the schema, so
mode: !input automation_modeis valid.