Hey I’m stuck trying to get this to work. I’ve got an automation that sets the house bedtime based on if it’s a school night/weekend/holiday. I’ve got that part figured out in an automation that is triggered at 7pm every night.
I’ve got another automation that then takes the time from ‘input.datetime.bedtime’ and shuts down the house.
I would like to also set another ‘input.datetime.pre_bedtime’ that a separate automation uses to give a warning that there is only 30 minutes until bedtime. I cannot figure out how to subtract 30 minutes from the bedtime and update the pre_bedtime. Any help would be appreciated.
Here is my automation:
It’s fun because it’s exactly what I tried to do yesterday and finally it works now.
Here is what I do :
I use a shortcut on my iPhone that send my next alarm value to Home Assistant. It is written into a input_datetime.my_next_alarm
I use an automation that is triggered by any change on the entity “input_datetime.my_next_alarm” and set another input_datetime.offset_alarm that is 30 minutes before the first one.
Here is my automation :
alias: Time - Update offset for morning routing
description: ''
trigger:
- platform: state
entity_id: input_datetime.my_next_alarm
condition: []
action:
- service: input_datetime.set_datetime
data:
time: "{{ strptime(states('input_datetime.my_next_alarm'), '%H:%M:%S') - strptime('30', '%M') }}"
target:
entity_id: input_datetime.offset_alarm
mode: single
Then I have my final automation that is triggered at the time set in the input_datetime.offset_alarm :
This got it! Thanks so much @123, I tried something like this to begin with using a value template but when I didn’t get it to work I assumed I had to use an integer instead.
It’s one of those things where I was staring at the problem too long and needed to step back and let someone show me how simple it could be
Thanks again!