Skip to content

Instantly share code, notes, and snippets.

@nikosthanos
Last active December 19, 2020 08:16
Show Gist options
  • Save nikosthanos/82cc8e1f00da62bc4e7838bcc5361de2 to your computer and use it in GitHub Desktop.
Save nikosthanos/82cc8e1f00da62bc4e7838bcc5361de2 to your computer and use it in GitHub Desktop.
blueprint:
name: Xiaomi Mijia Wireless Switch (WXKG01LM)
description: 'Use zigbee2mqtt Connect Mijia wireless switch to control device switch
Through zigbee2mqtt Access, support single tap/double tap/triple tap/four tap/multi tap and ``long press''
'
domain: automation
input:
mijia_button:
name: Xiaomi Mijia Wireless Switch
description: 'Select the wireless switch entity_id, Usually sensor.0x00158d0000000000_action'
default: []
selector:
entity:
domain: sensor
mijia_button_single: { name: Click on(single), default: [], selector: { action: {} } }
mijia_button_hold: { name: Press(hold), default: [], selector: { action: {} } }
mijia_button_double: { name: Double click(double), default: [], selector: { action: {} } }
mijia_button_triple: { name: Triple hit(triple), default: [], selector: { action: {} } }
mijia_button_quadruple: { name: Four combos(quadruple), default: [], selector: { action: {} } }
mijia_button_many: { name: Multiple combos(many), default: [], selector: { action: {} }, description: Click more than four times to trigger this action }
variables:
button_action: '{{ trigger.to_state.state }}'
mode: single
max_exceeded: silent
trigger:
# Available status is : single, double, triple, quadruple, many, hold, release
- { platform: state, entity_id: !input 'mijia_button' }
condition: []
action:
# IF
- choose:
- conditions: '{{ button_action == "single" }}'
sequence: !input 'mijia_button_single'
- conditions: '{{ button_action == "hold" }}'
sequence: !input 'mijia_button_hold'
- conditions: '{{ button_action == "double" }}'
sequence: !input 'mijia_button_double'
- conditions: '{{ button_action == "triple" }}'
sequence: !input 'mijia_button_triple'
- conditions: '{{ button_action == "quadruple" }}'
sequence: !input 'mijia_button_quadruple'
- conditions: '{{ button_action == "single" }}'
sequence: !input 'mijia_button_single'
# trigger:
# - platform: time_pattern
# minutes: "*"
# condition: []
# action:
# - wait_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
# - wait_template: >-
# {{ 0 < as_timestamp(states(timestamp_sensor)) -
# as_timestamp(states('sensor.date_time_iso')) < 60 *
# float(sunrise_duration) }}
# - choose: []
# default: !input pre_sunrise_actions
# - service: light.turn_on
# data:
# brightness_pct: 1
# color_temp: '{{ start_mired }}'
# entity_id: !input light_entity
# - repeat:
# while:
# - condition: template
# value_template: '{{ as_timestamp(states(timestamp_sensor)) != None }}'
# - condition: template
# value_template: >-
# {{ 0 < as_timestamp(states(timestamp_sensor)) -
# as_timestamp(states('sensor.date_time_iso')) < 60 *
# float(sunrise_duration) }}
# sequence:
# - delay: '00:00:05'
# - choose:
# - conditions:
# - condition: state
# entity_id: !input light_entity
# state: 'on'
# sequence:
# - service: light.turn_on
# data:
# brightness_pct: >-
# {{ (100 - (100 *
# (as_timestamp(states(timestamp_sensor)) -
# as_timestamp(now())) /
# (float(sunrise_duration) * 60))) | int }}
# color_temp: >-
# {{ (float(end_mired) + (float(start_mired) - float(end_mired)) *
# ((as_timestamp(states(timestamp_sensor)) -
# as_timestamp(now())) /
# (float(sunrise_duration) * 60))) | int }}
# entity_id: !input light_entity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment