summaryrefslogtreecommitdiffstats
path: root/esphome/config
diff options
context:
space:
mode:
Diffstat (limited to 'esphome/config')
-rw-r--r--esphome/config/toiletlight.yaml64
1 files changed, 36 insertions, 28 deletions
diff --git a/esphome/config/toiletlight.yaml b/esphome/config/toiletlight.yaml
index 35b968e..cd39e6b 100644
--- a/esphome/config/toiletlight.yaml
+++ b/esphome/config/toiletlight.yaml
@@ -77,7 +77,7 @@ output:
77 pin: GPIO1 77 pin: GPIO1
78 frequency: 3900 Hz 78 frequency: 3900 Hz
79 channel: 0 79 channel: 0
80 min_power: 0.04 80 min_power: 0.02
81 zero_means_zero: true 81 zero_means_zero: true
82 82
83 - id: pwm_warm 83 - id: pwm_warm
@@ -146,31 +146,39 @@ globals:
146 initial_value: '222.0' # 4500K 146 initial_value: '222.0' # 4500K
147 147
148binary_sensor: 148binary_sensor:
149 - platform: homeassistant 149 - platform: gpio
150 name: "Nightlight enabled from Home Assistant" 150 name: "Presence detector"
151 entity_id: input_boolean.toilet_light_nightlight 151 id: presence_detector
152 on_state_change: 152 pin:
153 number: GPIO10
154 mode: INPUT_PULLUP
155 inverted: true
156 filters:
157 - delayed_on: 10ms
158 - delayed_off: 10ms
159 on_state:
153 then: 160 then:
154 - if: 161 - lambda: 'id(toilet).make_call().set_state(x).perform();'
155 condition: 162 trigger_on_initial_state: true
156 lambda: 'return x.has_value() && x.value();' 163
157 then: 164switch:
158 - lambda: |- 165 - platform: template
159 if (!id(saved_values)) { 166 name: "Nightlight"
160 id(saved_brightness) = id(toilet).current_values.get_brightness(); 167 icon: "mdi:lightbulb-night"
161 id(saved_color_temp) = id(toilet).current_values.get_color_temperature(); 168 lambda: 'return id(saved_values);'
162 id(saved_values) = true; 169 turn_on_action:
163 } 170 - lambda: |-
164 - light.turn_on: 171 id(saved_brightness) = id(toilet).current_values.get_brightness();
165 id: toilet 172 id(saved_color_temp) = id(toilet).current_values.get_color_temperature();
166 brightness: 1% 173 id(saved_values) = true;
167 color_temperature: 3000 K 174 - light.control:
168 else: 175 id: toilet
169 - lambda: |- 176 brightness: 1%
170 if (id(saved_values)) { 177 color_temperature: 3000 K
171 auto call = id(toilet).turn_on(); 178 turn_off_action:
172 call.set_brightness(id(saved_brightness)); 179 - lambda: |-
173 call.set_color_temperature(id(saved_color_temp)); 180 auto call = id(toilet).make_call();
174 call.perform(); 181 call.set_brightness(id(saved_brightness));
175 id(saved_values) = false; 182 call.set_color_temperature(id(saved_color_temp));
176 } 183 call.perform();
184 id(saved_values) = false;