Hi, I’m totally ignorant about automation on hassio.
I have the android app of Home Assistant, which natively send to HA the timestamp of the next scheduled alarm clock (entity is called sensor.smartphone_moto__next_alarm).
I’d like to automatically turn on the light in the room ~5 minutes before the alarm clock will ring (I already have that switch configured/working).
Now I’m not sure about what I have to insert inside automation.yaml . Seems like I have to compile the trigger section with some platfrom able to send events. But in fact, it seems that the time of next alarm is sent as state, see below [1].
At the same time, the hassio UI is “correctly” interpreting that state, because it shows a countdown to the next alarm clock. Any idea about how to configure such automation?
[1] : state visible from “Developer tools” in hassio UI
Local Time: Sun Jul 11 07:28:00 GMT+02:00 2021
Package: com.google.android.deskclock
Time in Milliseconds: 1625981280000
friendly_name: smartphone_moto Next Alarm
icon: mdi:alarm
device_class: timestamp
The first automation is setting your “light_on_time” in this input_datetime with a value sensor.smartphone... minus five minutes. This automation is triggered by the state change of the sensor.
The second automation is turning your light on, when the time in the input_datetime is triggered.
If you want to go crazy, you can even set the time frame (the five minutes) via an input_number that represents that value.
thank you both I’ve successfully configured the solution proposed by @finity . But I see the higher level of customization of @paddy0174 's solution.
are there other practical differences, between the two solution? I suppose that hassio perform a constant evaluation (of expression) for @finity solution, while @paddy0174 solution sounds more like event driven . Am I right?