Introduction:
This Blueprint allows you to configure an Xiaomi Mijia Round Wireless Switch (WXKG01LM) paired to the ZHA integration. The Zigbee ID for this button is “lumi.sensor_switch”.
It supports six commands - single press, button hold, double press, triple press, quadruple press and “multiple” press, which is basically anything higher than 5 presses (aka “furious”).
Thanks to @jodur for the button hold behavior.
This blueprint is based on ZHA - Aqara Wireless Mini Switch from @SeanM!
As @SeanM mentions on his blueprint:
Also, an additional tip: if you select the “Choose” action type, you can increase the amount of actions each button is capable of executing. For example you can make “double press” activate a scene by default, but make it skip tracks if Spotify is playing, and make it fast forward if you’re watching a movie.
Other Recommended Xiaomi ZHA Blueprints:
Here are some Blueprints I am using for Xiaomi devices using ZHA, which are working great.
ZHA - Xiaomi Aqara Wireless Mini Switch (WXKG11LM) - lumi.sensor_switch.aq2 - by me, @carlosmesquita
ZHA - Aqara Wireless Remote Switch (Double Rocker) - by @NachtaktiverHalbaffe
Requirements:
Blueprint:
You can check the blueprint YAML here if you want, or just try it out by importing it using this topics’ URL:
blueprint:
name: ZHA - Mijia Wireless Remote Switch (WXKG01LM)
description: Automate your Xiaomi Mijia Wireless Round Remote Switch using ZHA events.
domain: automation
input:
mijia_round_switch:
name: Mijia Wireless Round Switch
description: Mijia Wireless Round Switch to use
selector:
device:
integration: zha
manufacturer: LUMI
model: lumi.sensor_switch
remote_button_short_press:
name: Single Press
description: Action to run on single press
default: []
selector:
action: {}
remote_button_hold_press:
name: Hold
description: Action to run on hold
default: []
selector:
action: {}
holdtime:
name: Time interval for hold detection, in seconds
description: Time to wait until hold_press is activated
default: 0.60
selector:
number:
min: 0.15
max: 2.5
unit_of_measurement: seconds
step: 0.05
mode: slider
remote_button_double_press:
name: Double Press
description: Action to run on double press
default: []
selector:
action: {}
remote_button_triple_press:
name: Triple Press
description: Action to run on triple press
default: []
selector:
action: {}
remote_button_quadruple_press:
name: Quadruple Press
description: Action to run on quadruple press
default: []
selector:
action: {}
remote_button_multiple_press:
name: Multiple Press
description: Action to run on multiple press
default: []
selector:
action: {}
mode: parallel
max_exceeded: silent
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'mijia_round_switch'
action:
- variables:
click_type: '{{ trigger.event.data.args.click_type }}'
attrname: '{{ trigger.event.data.args.attribute_name }}'
value: '{{ trigger.event.data.args.value }}'
command: '{{ trigger.event.data.command }}'
- choose:
- conditions:
- '{{ attrname == ''on_off'' }}'
- '{{ value == true }}'
sequence:
- wait_for_trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'mijia_round_switch'
command: 'attribute_updated'
args:
attribute_id: 0
attribute_name: on_off
value: false
continue_on_timeout: true
timeout: !input 'holdtime'
- choose:
- conditions:
- condition: template
value_template: '{{ not wait.trigger }}'
sequence: !input 'remote_button_hold_press'
default: !input 'remote_button_short_press'
- conditions:
- condition: template
value_template: "{{ command == 'click' }}"
sequence:
- choose:
- conditions: "{{ click_type == 'double' }}"
sequence: !input remote_button_double_press
- conditions: "{{ click_type == 'triple' }}"
sequence: !input remote_button_triple_press
- conditions: "{{ click_type == 'quadruple' }}"
sequence: !input remote_button_quadruple_press
- conditions: "{{ click_type == 'furious' }}"
sequence: !input remote_button_multiple_press
Below you can check the Automation creation screen from this blueprint:
Changelog
-
2021-04-09: Changed Hold time default value (from 1s to 0.6s), along with the minimum hold time ( from 0 to 0.15s), max time (from 10s to 2.5s) and the step (from 1 to 0.05), to allow more granularity and flexibility. Kudos to @jant90
-
2021-02-24: Changed Automation Mode from restart to parallel, to fix multiple actions per event not working properly.
-
2021-01-03: Added hold action & refactored to improve readability. Thanks to @jodur and @123.
-
2020-12-22: Initial version.
Enjoy!