Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stncttr908/d0417344a66ab8cc1230a7ead3f5df68 to your computer and use it in GitHub Desktop.
Save stncttr908/d0417344a66ab8cc1230a7ead3f5df68 to your computer and use it in GitHub Desktop.
Aqara Wireless Switch (single, double, hold)
blueprint:
name: Aqara Wireless Switch (single, double, hold, release)
description: 'Control anything using Aqara Wireless Switch (or Tuya such as TS004F, etc.)
Customizable actions for each press.
This version of the blueprint is for buttons supporting single, double, hold and
release actions. Updated to use MQTT device triggers as the old method was
depricated.'
domain: automation
input:
action_sensor:
name: Zigbee switch device
description: Zigbee2MQTT switch entity
selector:
device:
filter:
- integration: mqtt
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 button hold
default: []
selector:
action: {}
press_release:
name: Button release
description: Action to run on button release
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
trigger:
- id: single
device_id: !input action_sensor
domain: mqtt
type: action
subtype: single
trigger: device
- id: double
device_id: !input action_sensor
domain: mqtt
type: action
subtype: double
trigger: device
- id: hold
device_id: !input action_sensor
domain: mqtt
type: action
subtype: hold
trigger: device
- id: release
device_id: !input action_sensor
domain: mqtt
type: action
subtype: release
trigger: device
action:
- variables:
command: '{{ trigger.id }}'
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment