-
Notifications
You must be signed in to change notification settings - Fork 0
/
mijia-wireless-switch.yaml
110 lines (110 loc) · 3.42 KB
/
mijia-wireless-switch.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
blueprint:
name: '[ZHA] Xiaomi Mijia Wireless Switch (WXKG01LM)'
description: Automate your Xiaomi Mijia Wireless Switch using ZHA events.
domain: automation
input:
mijia_switch:
name: Switch
description: Mijia Wireless Switch
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: {}
hold_delay:
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_switch'
action:
- variables:
click_type: '{{ trigger.event.data.args.click_type }}'
attribute_name: '{{ trigger.event.data.args.attribute_name }}'
value: '{{ trigger.event.data.args.value }}'
command: '{{ trigger.event.data.command }}'
- choose:
- conditions:
- '{{ attribute_name == ''on_off'' }}'
- '{{ value == true }}'
sequence:
- wait_for_trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'mijia_switch'
command: 'attribute_updated'
args:
attribute_id: 0
attribute_name: on_off
value: false
continue_on_timeout: true
timeout: !input 'hold_delay'
- 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