So for a ‘wake up light’ emulation, i have different automations, triggering other automations and canceling other automations.
I know I could probably turn this into one large automation (i’m not so good with code) and if/else,
but is it a problem having different automations triggering and canceling each other?
I’m a bit affraid that If I put this in one big automation, I will lose the overview and it will be more difficult to change a value (I think)
what happens is:
- When I set the alarm on my phone (pixel 3xl) the sensor…next_alarm shows my next alarm time (in unreadable format but ok)
- I have an automation that translate that (unreadable) value to a clear timestamp value date + time
- that timestamp is written to a helper but with minus 15 minutes
- if during this proces I cancel my alarm, the Next_alarm sensor will automaticly get value “unavailable”
-
- If the alarm stays on (and the above status isn’t “unavailable”), a new automation will trigger my light to slowely go brighter during 15 min
for info you are interested: my automations.
My automations:
-
is just a sensor : sensor.pixel_3_xl_volgende_alarm
-
(translate to readable value)
alias: wekker juiste uur
description: ''
trigger:
- platform: state
entity_id: sensor.pixel_3_xl_volgende_alarm
condition: []
action:
- service: input_datetime.set_datetime
data:
timestamp: '{{ as_timestamp(states.sensor.pixel_3_xl_volgende_alarm.state) }}'
entity_id: input_datetime.alarm_datum_en_uur
mode: single
- write timestamp minus 15 minutes to helper
alias: wekker zon
description: ''
trigger:
- platform: state
entity_id: sensor.pixel_3_xl_volgende_alarm
condition: []
action:
- service: input_datetime.set_datetime
data:
timestamp: >-
{{ as_timestamp(states.sensor.pixel_3_xl_volgende_alarm.state) - 60 * 15
}}
entity_id: input_datetime.voor_alarm
mode: single
4 + 5) if alarm is still set execute wake-up light:
alias: kwartier voor alarm
description: ''
trigger:
- platform: time
at: input_datetime.voor_alarm
condition:
- condition: not
conditions:
- condition: state
entity_id: sensor.pixel_3_xl_volgende_alarm
state: unavailable
action:
- service: automation.trigger
data: {}
entity_id: automation.wake_up_light_boven
mode: single
is it ok to work this way or could I make it a lot simpler?
Thanks guys !!