Hey folks, I’ve got an automation that runs every morning when my alarm goes off on my phone, which turns on a scene and activates several lights around my home, talking about the bathroom light specifically here. At 10:30am every day, I have another automation that turns these same lights off (they could also be turned off if I left the house before then, which I usually don’t on workdays).
I also work form home, and occasionally I won’t have time to get a shower before 10:15am or so. There’s been numerous times when I’ve been in the shower and the bathroom light has turned off, leaving me in the dark.
I’m wondering if there’s an elegant way to delay the 10:30am automation from running until I’m out of the shower/bathroom. I’d likely trigger this with a button to fire either a script or automation, I’m just wondering how I’d delay the automation for maybe 15mins or something, but only if this new button is pressed. Or turn off all the lights except the bathroom light… Idk, looking for ideas?
For my bathroom light, I made sure to include a “check loop” that makes sure the light can be turned off. The light.turn_on and off actions are handled it the same script and have a repeat until action in between the ON and OFF Commands. It repeats until multiple conditions are met (no motion for X minutes, shower isn’t running, door is open for X minutes), inside the repeat action then are these actions again as a condition and after that the turn-off action for the light. One could achieve this with the wait for trigger action, but I wanted more than one “condition” to turn off the light.
This loop also is independently usable for multiple scenarios (like 100% brightness and keep alive 10 minutes regardless of the conditions being met)
That way I make sure that whatever automation, script, or user turned on the lights it turns off automatically if the conditions are met. Obviously you could change the conditions to something like the button you mentioned and maybe use fields for the scripts to dynamically set a “guaranteed” time period in which the light should be on.
Just make sure all automated actions use this “unified” script to turn off the light instead of doing it individually.
But regardless, I’d advise implementing some sort of check before turning off the light.
For reference, this is the code for the loop I use:
alias: Ausschalt Schleife (Warte bis keine Motion und Tür offen) 3m
repeat:
until:
- condition: or
conditions:
- alias: Tür auf / keine Motion
condition: and
conditions:
- condition: state
entity_id: binary_sensor.tur_badezimmer_contact
state: "on"
for:
hours: 0
minutes: 2
seconds: 50
- condition: state
entity_id: binary_sensor.hue_motion_sensor_2_motion
state: "off"
for:
hours: 0
minutes: 3
seconds: 0
- condition: state
entity_id: input_boolean.dusche
state: "off"
- alias: Tür auf / Deckenlicht manuell ausgeschaltet
condition: and
conditions:
- condition: state
entity_id: binary_sensor.tur_badezimmer_contact
state: "on"
for:
hours: 0
minutes: 0
seconds: 5
- condition: device
type: is_off
device_id: 3580cccc03416dece41a08632937cf70
entity_id: cf3ga5248de586302ca39223de316672
domain: light
alias: Deckenlicht bereits aus
sequence:
- delay:
hours: 0
minutes: 0
seconds: 1
milliseconds: 0
- if:
- condition: and
conditions:
- type: is_not_open
condition: device
device_id: 02c8d4a79c9e7b716537954a003211bd
entity_id: 068dd51175124339283df6d7aa09bf63
domain: binary_sensor
- condition: device
type: is_off
device_id: 3580cacc03446dece41ar86c2937cf70
entity_id: cf3fa5h48de586302ca38223d7316672
domain: light
alias: Tür geschlossen aber Licht aus
then:
- service: light.turn_on
data: {}
target:
entity_id: light.deckenlicht_badezimmer
alias: Deckenlicht einschalten
alias: Licht wieder einschalten falls Tür zu aber Licht aus
- alias: Tür auf und keine Motion / oder Deckenlicht manuell ausgeschaltet
condition: or
conditions:
- alias: Tür auf / keine Motion und kein Overwrite
condition: and
conditions:
- condition: state
entity_id: input_boolean.badezimmer_licht_overwrite_30min
state: "off"
- alias: Tür auf / keine Motion
condition: and
conditions:
- condition: state
entity_id: binary_sensor.tur_badezimmer_contact
state: "on"
for:
hours: 0
minutes: 2
seconds: 45
- condition: state
entity_id: binary_sensor.hue_motion_sensor_2_motion
state: "off"
for:
hours: 0
minutes: 2
seconds: 50
- condition: state
entity_id: input_boolean.dusche
state: "off"
- alias: Tür auf / Deckenlicht manuell ausgeschaltet
condition: and
conditions:
- condition: state
entity_id: binary_sensor.tur_badezimmer_contact
state: "on"
for:
hours: 0
minutes: 0
seconds: 5
- condition: device
type: is_off
device_id: 35801ccc03446dece41a086c2g37cf70
entity_id: cf3fa5248dz586302ca38223dy316672
domain: light
alias: Deckenlicht bereits aus
- service: light.turn_off
data:
transition: 5
target:
area_id: badezimmer
@ha_user22323 I think that’s probably a good first step. I was against putting a sensor in the bathroom for a long time, just for privacy. And because there’s only one plug in my bathroom (yay small apartments); but it’s been a few years, and now there’s quite a few battery powered, wireless (non-wifi) options to choose from. So maybe just a simple temp/humidity sensor in a discrete area would help a lot. Then yea, just make it a condition to the shutoff automation.