summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--esphome/config/bedlight.yaml73
1 files changed, 53 insertions, 20 deletions
diff --git a/esphome/config/bedlight.yaml b/esphome/config/bedlight.yaml
index f34f021..7688e79 100644
--- a/esphome/config/bedlight.yaml
+++ b/esphome/config/bedlight.yaml
@@ -5,13 +5,17 @@ esphome:
5 #esp8266_restore_from_flash: true 5 #esp8266_restore_from_flash: true
6 6
7 # light default values 7 # light default values
8 #on_boot: 8 on_boot:
9 # then: 9 then:
10 # - light.control: 10 - lock.template.publish:
11 # id: bed 11 id: child_lock
12 # state: on 12 state: UNLOCKED
13 # brightness: 10% 13 # light default values
14 # color_temperature: 330.0 mireds 14 #- light.control:
15 # id: bed
16 # state: on
17 # brightness: 10%
18 # color_temperature: 330.0 mireds
15 19
16# Enable logging 20# Enable logging
17logger: 21logger:
@@ -122,6 +126,13 @@ script:
122 then: 126 then:
123 - delay: 10s 127 - delay: 10s
124 - lambda: 'id(g_dim_level) = abs(id(g_dim_level));' 128 - lambda: 'id(g_dim_level) = abs(id(g_dim_level));'
129 - id: reset_child_lock
130 mode: restart
131 then:
132 - delay: 30min
133 - lock.template.publish:
134 id: child_lock
135 state: UNLOCKED
125 136
126binary_sensor: 137binary_sensor:
127 - id: user_button 138 - id: user_button
@@ -133,25 +144,33 @@ binary_sensor:
133 min_length: 30ms 144 min_length: 30ms
134 max_length: 350ms 145 max_length: 350ms
135 then: 146 then:
136 - logger.log: "on_click" 147 - if:
137 # TODO: if brightness is low, turn on + transition is also slow 148 condition:
138 - light.toggle: bed 149 lock.is_unlocked: child_lock
139 # dim up per default unless brightness is 95% 150 then:
140 - lambda: |- 151 - logger.log: "on_click"
141 id(g_dim_level) = abs(id(g_dim_level)); 152 # TODO: if brightness is low, turn on + transition is also slow
142 if (id(bed).current_values.get_brightness() >= 0.95) 153 - light.toggle: bed
143 id(g_dim_level) *= -1; 154 # dim up per default unless brightness is 95%
155 - lambda: |-
156 id(g_dim_level) = abs(id(g_dim_level));
157 if (id(bed).current_values.get_brightness() >= 0.95)
158 id(g_dim_level) *= -1;
144 on_press: 159 on_press:
145 then: 160 then:
146 - delay: 500ms 161 - delay: 500ms
147 - if: 162 - if:
148 condition: 163 condition:
149 # make sure button is still pressed 164 and:
150 binary_sensor.is_on: user_button 165 - lock.is_unlocked: child_lock
166 # make sure button is still pressed
167 - binary_sensor.is_on: user_button
151 then: 168 then:
152 - while: 169 - while:
153 condition: 170 condition:
154 binary_sensor.is_on: user_button 171 and:
172 - lock.is_unlocked: child_lock
173 - binary_sensor.is_on: user_button
155 then: 174 then:
156 - logger.log: "on_press" 175 - logger.log: "on_press"
157 - light.dim_relative: 176 - light.dim_relative:
@@ -172,5 +191,19 @@ binary_sensor:
172 - script.execute: reset_dim_direction 191 - script.execute: reset_dim_direction
173 on_double_click: 192 on_double_click:
174 then: 193 then:
175 - homeassistant.event: 194 - if:
176 event: esphome.double_click 195 condition:
196 lock.is_unlocked: child_lock
197 then:
198 - homeassistant.event:
199 event: esphome.double_click
200
201lock:
202 - id: child_lock
203 platform: template
204 name: "Child Lock"
205 optimistic: true
206 on_lock:
207 - script.execute: reset_child_lock
208 on_unlock:
209 - script.stop: reset_child_lock