mr_white
(Martin)
September 27, 2021, 10:04am
1
Hey guys!
I have a wake-up alarm configured as a datetime.
I like to trigger some automations (heating and lights) a specified time before the alarm time.
I tried a template sensor that subtracts 1hour (or a time specified in a separate datetime) from the alarm but this do not work.
Can someone tell me how to fix this or how to do it with a template trigger?
- platform: template
sensors:
badheizung_startzeittest:
friendly_name: 'badheizung_startzeittest'
value_template: '{{ (states.input_datetime.alarm.state | timestamp_custom("%H:%M:%S")) - (states.input_datetime.badheizung_vor_wecker.state | timestamp_custom("%H:%M:%S")) }}'
Thanks in advance
koying
(Chris B)
September 27, 2021, 10:25am
2
Just do a forum search on “wake-up” to get a bazillion of examples.
1 Like
mr_white
(Martin)
October 17, 2021, 10:12am
3
Hey!
thank you for your answer.
You´r right there are millions of anwers for that question, and that was the problem
For now I will do it with a simple template trigger that triggers 3600 seconds before alarm (input_datetime)
{{ states('sensor.time') == (state_attr('input_datetime.alarm', 'timestamp') - 3600) |timestamp_custom('%H:%M', false) }}
thanks to the community
koying
(Chris B)
October 17, 2021, 10:29am
4
So you decided to ask the same question to add another identical answer. Interesting
mr_white
(Martin)
October 17, 2021, 3:01pm
5
Hey @koying !
Sorry for double asking
But I didn´t get the answer till now.
Asked for a template sensor and now is a template trigger → same function
thank you
123
(Taras)
October 17, 2021, 3:22pm
6
FYI
If you wish you can replace the reference to the sensor.time
entity with now()
like this:
{{ now().ctime()[11:16] == (state_attr('input_datetime.alarm', 'timestamp') - 3600) |timestamp_custom('%H:%M', false) }}
mr_white
(Martin)
October 17, 2021, 5:14pm
7
Thank you!
And how to use this as a sensor?
123
(Taras)
October 17, 2021, 5:31pm
8
It could be used in a Template Binary Sensor. It would report on
the moment the current time matches the input_datetime’s adjusted time (i.e. minus 3600 seconds) and off
for all other times.
However it’s already suitable for use as a Template Trigger for an automation.
If the goal is to display the adjusted time in a Template Sensor, simply remove the entire left half of the equation and just use the right half.
mr_white
(Martin)
October 17, 2021, 6:47pm
9
Thank you so much
Yes the goal is (was) to display the time till the alarm time.
So I think of a calculation like time now minus alarm time.
Then I could use this for trigger
But this way works fine as well, just without displaying the time left
Greez from Vienna