So, input_datetime exists, and an obvious use for it is creating some sort of alarm-clock event (say, slowly turning lights on/bluer to wake you up).
This is currently somewhat fiddly, the simplest solution is to add a time sensor:
sensor:
- platform: time_date
display_options:
- time
Then add a template trigger to compare the times:
automation:
- alias: Wake me up
trigger:
platform: template
value_template: "{{ states('sensor.time') >= states('input_datetime.alarm_clock')[:5] }}"
action:
...
Which works, though you also need to do something about the fact that it’ll run if you restart home-assistant after the alarm time.
I have a custom component which lets me do this instead:
automation:
- alias: Wake me up
trigger:
platform: time_template
at: "{{ states('input_datetime.alarm_clock') }}"
action:
...
No time sensor, no worrying about post-start-state, less template complexity.
I’m inclined to flesh out the tests, write some docs, and submit a PR. But, there are options:
- Should this be a template config as part of the main time trigger, something like
trigger:
platform: time
template:
value_template: "{{ states('input_datetime.alarm_clock') }}"
entity_id: # optional, but shown here to show why we need template as a dict
- input_datetime.alarm_clock
- Should there be hour/minute/second options? (I actually have these in my custom component, but can remove for the sake of code reduction and they need a whole bunch of tests)
- Or, should I add something under the template trigger:
trigger:
platform: template
at_template: "{{ states('input_datetime.alarm_clock') }}"
Opinions? Particularly opinions of home-assistant devs, since you’ll be reviewing it