-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZHA Philips Hue Dimmer Switch V2 (RWL022).yaml
227 lines (226 loc) · 7.36 KB
/
ZHA Philips Hue Dimmer Switch V2 (RWL022).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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
blueprint:
name: MQTT Philips Hue Dimmer Switch (RWL022) v.2.5.7
description: Control lights with a Philips Hue Dimmer Switch
domain: automation
input:
dimmer_switch:
name: Dimmer Switch
description: The dimmer switch to use
selector:
entity:
domain: sensor
filter:
- integration: mqtt
multiple: false
main_scene:
name: Main Scene
description: Scene will be active on top press
selector:
entity:
filter:
- domain:
- scene
multiple: false
light:
name: Lights
description: The lights to control with + / - and to turn off
selector:
entity:
domain:
- light
multiple: false
included_scenes:
name: Hue Button Scenes
description: Scenes to be included
default: []
selector:
entity:
filter:
- domain:
- scene
multiple: true
scene_helper:
name: Scene helper
description: Please select a Input Text Helper to be used to record the scene sequence.
selector:
entity:
domain:
- input_text
multiple: false
transition_time:
name: Transition time
description: Transition time when changes
default: 1
selector:
number:
min: 0.0
max: 3.0
step: 0.1
unit_of_measurement: sec
mode: slider
hold_press_change:
name: Hold press change
description: Transition time between changes
default: 17
selector:
number:
min: 0.0
max: 25.0
step: 1.0
unit_of_measurement: "%"
mode: slider
reset_after:
name: Reset After
description:
Timeout can be set after which the order is reset to the first
scene.
default: 5
selector:
number:
min: 1.0
max: 120.0
step: 1.0
unit_of_measurement: s
mode: slider
aux_scene_on:
name: ON Button Aux Scene
description: Scene will be active on hold ON press
selector:
entity:
filter:
- domain:
- scene
multiple: false
aux_scene_off:
name: Off Button Aux Scene
description: Scene will be active on hold OFF press
selector:
entity:
filter:
- domain:
- scene
multiple: false
mode: parallel
max_exceeded: silent
trigger:
- platform: state
entity_id: !input dimmer_switch
action:
- variables:
command: "{{ trigger.to_state.state }}"
included_scenes: !input included_scenes
scene_helper: !input scene_helper
reset_after: !input reset_after
main_scene: !input main_scene
active_scene: >
{% set data = states(scene_helper) %}
{% if data != "unknown" %}
{% if (as_timestamp(now()) - (data | from_json).timestamp) < reset_after %}
{{ (data | from_json).scene }}
{% else %}
0
{% endif %}
{% else %}
0
{% endif %}
target_lights: !input light
hold_press_change: !input hold_press_change
- choose:
- conditions: "{{ command == 'on_press' }}"
sequence:
- service: scene.turn_on
target:
entity_id: !input main_scene
data:
transition: !input transition_time
- conditions: "{{ command == 'on_double_press' }}"
sequence:
- service: scene.turn_on
target:
entity_id: !input aux_scene_on
- conditions:
- "{{ command == 'up_hold' or command == 'up_press'}}"
sequence:
- choose:
- conditions:
"{{ (state_attr(target_lights, 'brightness') + ((hold_press_change/100)*254)
| round) <= 255 }}"
sequence:
- service: light.turn_on
target:
entity_id:
"{{ expand(target_lights) | selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | list }}"
data:
brightness_step_pct: "{{ hold_press_change }}"
transition: !input transition_time
- conditions:
"{{ (state_attr(target_lights, 'brightness') + ((hold_press_change/100)*254)
| round) > 255 }}"
sequence:
- service: light.turn_on
target:
entity_id:
"{{ expand(target_lights) | selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | list }}"
data:
brightness_pct: 100
transition: !input transition_time
- conditions:
- "{{ command == 'down_hold' or command == 'down_press' }}"
sequence:
- choose:
- conditions:
"{{ (state_attr(target_lights, 'brightness') - ((hold_press_change/100)*254)
| round) >= hold_press_change }}"
sequence:
- service: light.turn_on
target:
entity_id:
"{{ expand(target_lights) | selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | list }}"
data:
brightness_step_pct: "{{ -hold_press_change }}"
transition: !input transition_time
- delay: !input transition_time
- conditions:
"{{ (state_attr(target_lights, 'brightness') - ((hold_press_change/100)*254)
| round) < hold_press_change or (state_attr(target_lights, 'brightness')
- ((hold_press_change/100)*254) | round) >= 1}}"
sequence:
- service: light.turn_on
target:
entity_id:
"{{ expand(target_lights) | selectattr('state', 'eq', 'on')
| map(attribute='entity_id') | list }}"
data:
brightness_pct: 1
transition: !input transition_time
- delay: !input transition_time
- conditions: "{{ command == 'off_press' }}"
sequence:
- service: scene.turn_on
data_template:
transition: !input transition_time
entity_id: >
{{ included_scenes[active_scene] }}
- service: input_text.set_value
target:
entity_id: !input scene_helper
data:
value: >
{{ {"scene": (active_scene + 1) % included_scenes | length, "timestamp": as_timestamp(now())} | to_json }}
- conditions: "{{ command == 'off_hold' }}"
sequence:
- service: scene.turn_on
target:
entity_id: !input aux_scene_off
data:
transition: !input transition_time
- conditions: "{{ command == 'on_hold' }}"
sequence:
- service: scene.turn_on
target:
entity_id: !input aux_scene_on
data:
transition: !input transition_time