Wake up Routine

Go Easy on me, this is my first time.

I installed hass.io on a raspberry pi I had lying round, and I am trying to get familiar with HA. I am loving what I’ve seen so far.

I want to create a wake up routine for a eufy light bulb I have. I have made simple automations turning the bulb on and off, and done a stepped gentle brighten using delays (as the bulb doesn’t support the transition flag). All well and good.

What I would like is to set an alarm on my phone, and 10 minutes before it goes off the automation to trigger.
I have followed this thread here

And I can now see the state sensor.alarmtime in my HA and it changes when I change my alarm on my phone. Brilliant.
I have created a time sensor using:
- platform: time_date

which I can also see in the states page. Both are in the same format which is ideal.What I can’t work out how to do is to compare the two values and trigger when it is 10 minutes before sensor.alarmtime. My google-fu has let me down, any assistance would be appreciated

Assuming your sensor.alarmtime has a date and time (looked like it does from a quick scan of the post you linked):

    platform: time   
    minutes: '/1'
    seconds: 00
    condition: template
    value_template: "{{ as_timestamp( now() ) - 600 - as_timestamp( states('sensor.alarmtime' ) <= 0}}"
    service: do_your_thing_here

What we are doing is triggering every minute and then checking if the condition template is true. We have to do it this way because we cant use now() in a trigger template. It only gets evaluated when the template is actually read and thus won’t generate a trigger event.

In the condition template we change the times to timestamps (seconds since Jan1 1900) for easy subtraction. When the time now minus 600 seconds (ten minutes) minus your alarm sensor time is less than or equal to zero the condition will be true and the action can occur.

Having said that it’s late, I’ve been drinking and I’m pretty sure I have this bit wrong:

as_timestamp( states('sensor.alarmtime' )

because I can’t get a similar sensor of mine to evaluate in the template editor. Someone else may be able to see my mistake. I have to go to bed.

It would be helpful if you gave an example of what sensor.alarmtime looks like, or at least told us which time_date option you’re using that looks the same (e.g., time, date, date_time?)