I’ve created a versatile blueprint for this mini switch/button automation that offers:
Support for single, double, triple, and multi-press actions
Dimming functionality for the last controlled light by holding
Simplified setup using only 1 automation and 2 text helper entities
Key Features
Multi-press Support: Single, double, triple, and beyond - all toggle lights on/off
Smart Dimming: Hold to dim the last controlled light (alternates between increasing and decreasing brightness)
Flexibility: Easily customizable for non-light actions by “owning” and editing the automation
Compatibility Note
This blueprint is designed for use with zigbee2mqtt. Ensure your integration supports similar button action variants for optimal functionality.
Ideal Use Case
This blueprint is perfect if you’re primarily using your mini button for light control. For other types of actions, you can customize the automation to suit your specific needs.
Installation
One-Click Import: Use the button below to import the blueprint directly into Home Assistant:
Create Helper Entities:
Add two text-type helpers in Home Assistant:
For storing the last state
For storing the last controlled entity
Configuration: Follow the blueprint setup instructions to link your button and lights
Feel free to share your experiences or ask questions. Happy automating!
Here is a Z2M 2.0.0 compatible one.
It’s not the fanciest, but it works for me.
blueprint:
name: Xiaomi WXKG11LM Aqara Wireless Switch Mini
description:
"Tested with Xiaomi WXKG11LM Aqara Wireless Switch Mini.\n\nController
automation for executing any kind of action triggered by the provided Xiaomi WXKG11LM
Aqara Wireless Switch Mini.
\n\n You can have different actions on short press, long press, release and double press. \n\n
Make sure to manually create a separate Text Helper per dimmer
device and define its entity in the automation. It's used to store the last controller
event to filter possible empty events. "
domain: automation
input:
mqtt_topic:
name: MQTT Topic
description: Topic of the Xiaomi WXKG11LM
default: zigbee2mqtt/<device name>
helper_last_controller_event:
name: (Required) Helper - Last Controller Event
description:
Input Text used to store the last event fired by the controller.
You will need to manually create a text input Helper entity for this.
default: ""
selector:
entity:
domain:
- input_text
multiple: false
short:
name: SHORT button press
description: Action to run
default: []
selector:
action: {}
long:
name: LONG button press
description: Action to run
default: []
selector:
action: {}
release:
name: RELEASE of button
description: Action to run
default: []
selector:
action: {}
double:
name: DOUBLE button press
description: Action to run
default: []
selector:
action: {}
mode: queued
max_exceeded: silent
trigger:
- platform: mqtt
topic: !input mqtt_topic
condition:
- condition: template
value_template: "{{ trigger.payload_json.action != '' }}"
action:
- variables:
helper_last_controller_event: !input helper_last_controller_event
command: "{{ trigger.payload_json.action }}"
prev_command: "{{ states(helper_last_controller_event) }}"
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: "{{ command }}"
- choose:
- conditions:
- '{{ command == "single" }}'
sequence: !input short
- conditions:
- '{{ command == "hold" }}'
sequence: !input long
- conditions:
- '{{ command == "release" }}'
sequence: !input release
- conditions:
- '{{ command == "double" }}'
sequence: !input double
I copied the text and pasted it into a new yaml file that I created in the blueprints folder. Then I tweaked the blueprint a bit because I use the slighly bigger xiaomi button, which feature additional gestures. I then created an automation and it worked.
blueprint:
name: xiaomi button WXKG11LM (Zigbee MQTT Trigger)
description:
"Tested with Xiaomi WXKG11LM Aqara Wireless Switch Mini.\n\nController
automation for executing any kind of action triggered by the provided Xiaomi WXKG11LM
Aqara Wireless Switch Mini.
\n\n You can have different actions on short press, long press, release and double press. \n\n
Make sure to manually create a separate Text Helper per dimmer
device and define its entity in the automation. It's used to store the last controller
event to filter possible empty events. "
domain: automation
input:
mqtt_topic:
name: MQTT Topic
description: Topic of the Xiaomi WXKG11LM
default: zigbee2mqtt/<device name>
helper_last_controller_event:
name: (Required) Helper - Last Controller Event
description:
Input Text used to store the last event fired by the controller.
You will need to manually create a text input Helper entity for this.
default: ""
selector:
entity:
domain:
- input_text
multiple: false
short:
name: SHORT button press
description: Action to run
default: []
selector:
action: {}
long:
name: LONG button press
description: Action to run
default: []
selector:
action: {}
release:
name: RELEASE of button
description: Action to run
default: []
selector:
action: {}
double:
name: DOUBLE button press
description: Action to run
default: []
selector:
action: {}
triple:
name: Triple button press
description: Action to run
default: []
selector:
action: {}
mode: queued
max_exceeded: silent
trigger:
- platform: mqtt
topic: !input mqtt_topic
condition:
- condition: template
value_template: "{{ trigger.payload_json.action != '' }}"
action:
- variables:
helper_last_controller_event: !input helper_last_controller_event
command: "{{ trigger.payload_json.action }}"
prev_command: "{{ states(helper_last_controller_event) }}"
- service: input_text.set_value
data:
entity_id: !input helper_last_controller_event
value: "{{ command }}"
- choose:
- conditions:
- '{{ command == "single" }}'
sequence: !input short
- conditions:
- '{{ command == "hold" }}'
sequence: !input long
- conditions:
- '{{ command == "release" }}'
sequence: !input release
- conditions:
- '{{ command == "double" }}'
sequence: !input double
- conditions:
- '{{ command == "triple" }}'
sequence: !input triple