blob: 412ce3d002c88a5a8a02240549af4738796e9403 (
plain)
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
|
blueprint:
name: Knob Multi-Bulb Control
description: Knob (clicking/rotating) to control bulb (or LED band) brightness, color temperature, and hue
domain: automation
input:
knob:
name: knob
description: controller (select _action entity)
selector:
entity:
domain: sensor
lights:
name: Bulb
description: smart bulb or power socket
selector:
entity:
multiple: true
domain: light
toggle:
name: toggle
description: Script to run on clicking knob button (e.g. turn-of bulb power on/off)
default: []
selector:
action:
name:
name: name
description: Name of variables tracking bulb parameters (should include ***_current, ***_brighness0, ***_temperature0, ***_hue0
default: knob_office
hue_delay:
name: Hue Delay
description: Delay between hue changes
default: 500
selector:
number:
min: 100
max: 10000
trigger:
- platform: state
id: knob
entity_id: !input "knob"
to:
- "toggle"
- "brightness_step_up"
- "brightness_step_down"
- "color_temperature_step_up"
- "color_temperature_step_down"
- "hue_move"
variables:
name: !input name
current: 'input_number.{{ name + "_current" }}'
brightness: 'input_number.{{ name + "_brightness" }}{{ states(current) | int }}'
temperature: 'input_number.{{ name + "_temperature" }}{{ states(current) | int }}'
hue: 'input_number.{{ name + "_hue" }}{{ states(current) | int }}'
lights: !input lights
light: '{{ lights[states(current) | int] }}'
hue_delay: !input hue_delay
mode: queued
action:
- choose:
- conditions:
- condition: trigger
id: knob
sequence:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "brightness_step_up" }}'
sequence:
- service: input_number.increment
target:
entity_id: '{{ brightness }}'
- service: light.turn_on
data:
brightness: '{{ states(brightness) }}'
target:
entity_id: '{{ light }}'
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "brightness_step_down" }}'
sequence:
- service: input_number.decrement
data: {}
target:
entity_id: '{{ brightness }}'
- service: light.turn_on
data:
brightness: '{{ states(brightness) }}'
target:
entity_id: '{{ light }}'
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "color_temperature_step_up" }}'
sequence:
- service: input_number.increment
target:
entity_id: '{{ temperature }}'
- service: light.turn_on
data:
kelvin: '{{ states(temperature) }}'
target:
entity_id: '{{ light }}'
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "color_temperature_step_down" }}'
sequence:
- service: input_number.decrement
target:
entity_id: '{{ temperature }}'
- service: light.turn_on
data:
kelvin: '{{ states(temperature) }}'
target:
entity_id: '{{ light }}'
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "hue_move" }}'
sequence:
- repeat:
until:
- condition: template
value_template: '{{ wait.trigger != None }}'
sequence:
- if:
- condition: template
value_template: '{{ states(hue) | float < 359 }}'
then:
- service: input_number.increment
data: {}
target:
entity_id: '{{ hue }}'
else:
- service: input_number.set_value
data:
value: 0
target:
entity_id: '{{ hue }}'
- service: light.turn_on
data:
hs_color: '{{ states(hue) }}, 100'
target:
entity_id: '{{ light }}'
- wait_for_trigger:
- platform: state
entity_id: !input knob
to: 'hue_stop'
timeout:
milliseconds: !input hue_delay
continue_on_timeout: true
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == "toggle" }}'
sequence:
- if:
- condition: template
value_template: '{{ toggle | length > 0 }}'
then:
- choose: []
default: !input "toggle"
else:
- service: input_number.increment
target:
entity_id: '{{ current }}'
- if:
- condition: template
value_template: '{{ states(current) | float == (lights | length) }}'
then:
- service: input_number.set_value
data:
value: 0
target:
entity_id: '{{ current }}'
- service: light.turn_off
target:
entity_id: '{{ lights[states(current) | int] }}'
- delay:
seconds: 1
- service: light.turn_on
data:
kelvin: '{{ states("input_number." + name + "_temperature" + (states(current) | int | string)) }}'
brightness: '{{ states("input_number." + name + "_brightness" + (states(current) | int | string)) }}'
# hs_color: '{{ states("input_number." + name + "_hue" + (states(current) | int | string)) }}, 100'
target:
entity_id: '{{ lights[states(current) | int] }}'
|