Hi,
I am playing around with an alarm clock automation and I want the automation to start 15 minutes before the wake up time set (slowly increasing the light).
I would have used the following format when using the time set to start the automation action:
- id: '7'
alias: Wake up
trigger:
- platform: time
minutes: /1
seconds: 0
condition:
- condition: template
value_template: '{{ now().strftime("%H:%M") == states.sensor.wake_up.state }}'
When offsetting the time fifteen minutes I simply add fifteen minutes to the current time when testing it against the alarm time I use the following instead:
- id: '7'
alias: Wake up
trigger:
- platform: time
minutes: /1
seconds: 0
condition:
- condition: template
value_template: '{{ (now().strftime("%s") | int + (15*60)) | timestamp_custom("%H:%M") == states.sensor.wake_up.state }}'
Surprisingly, the second example renders a time to test against the sensor state that is not 15 minutes later than the first but 1 hour and 15 minutes later.
This means that if I test the template
{{ now().strftime("%H:%M") }}
and it renders 20:00
then the template
{{ (now().strftime("%s") | int + (15*60)) | timestamp_custom("%H:%M") }}
renders 21:15.
Can anyone explain why?
I can of course offset this by using
{{ (now().strftime("%s") | int - (45*60)) | timestamp_custom("%H:%M") }}
which renders in the same case 20:15, which is the desired time.
I just want to make sure that the difference is not an effect of time zone and that it will change if we move from summer to winter time.