Skip to content

Instantly share code, notes, and snippets.

@deskoh
Last active May 31, 2025 05:38
Show Gist options
  • Save deskoh/7846f7366dc945cc66c3bc0cfcb98b2c to your computer and use it in GitHub Desktop.
Save deskoh/7846f7366dc945cc66c3bc0cfcb98b2c to your computer and use it in GitHub Desktop.
blueprint:
name: Zigbee2MQTT - Mi Button
description:
Automation to configure Mi Button Switch using Zigbee2MQTT integration.
domain: automation
homeassistant:
min_version: 2025.1.0
input:
switch:
name: Select the device you want to configure
description: Wireless button switch to use
selector:
device:
filter:
- integration: mqtt
model: Mi wireless switch
multiple: false
single:
name: Single button press
description: Action to run on single button press
default: []
selector:
action: {}
double:
name: Double button press
description: Action to run on double button press
default: []
selector:
action: {}
triple:
name: Triple button press
description: Action to run on triple button press
default: []
selector:
action: {}
quadruple:
name: Quadruple button press
description: Action to run on quadruple button press
default: []
selector:
action: {}
hold:
name: Hold
description: Action to run on holding button
default: []
selector:
action: {}
release:
name: Release
description: Action to run on release after holding button
default: []
selector:
action: {}
many:
name: Many
description: Action to run on many button press
default: []
selector:
action: {}
mode: restart
max_exceeded: silent
triggers:
- domain: mqtt
device_id: !input switch
type: action
subtype: left
trigger: device
- domain: mqtt
device_id: !input switch
type: action
subtype: double
trigger: device
- domain: mqtt
device_id: !input switch
type: action
subtype: triple
trigger: device
- domain: mqtt
device_id: !input switch
type: action
subtype: quadruple
trigger: device
- domain: mqtt
device_id: !input switch
type: action
subtype: hold
trigger: device
- domain: mqtt
device_id: !input switch
type: action
subtype: release
trigger: device
- domain: mqtt
device_id: !input switch
type: action
subtype: many
trigger: device
actions:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.payload == ''single'' }}'
sequence: !input single
- conditions:
- condition: template
value_template: '{{ trigger.payload == ''double'' }}'
sequence: !input double
- conditions:
- condition: template
value_template: '{{ trigger.payload == ''triple'' }}'
sequence: !input triple
- conditions:
- condition: template
value_template: '{{ trigger.payload == ''quadruple'' }}'
sequence: !input quadruple
- conditions:
- condition: template
value_template: '{{ trigger.payload == ''hold'' }}'
sequence: !input hold
- conditions:
- condition: template
value_template: '{{ trigger.payload == ''release'' }}'
sequence: !input release
- conditions:
- condition: template
value_template: '{{ trigger.payload == ''many'' }}'
sequence: !input many
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment