Automation trigger time template => different approach

Hi,

this has been discussed (and solved) with a workaround (here, and in other threads as well). The solution is usually to use a template sensor that will check whether the set value is equal to now() or similar.

I have been using this for quite some time; actually it was in my yamls for so long, that I forgot how to do it now that I need it again. The solution above work fine!! But just out of curiosity, would there be a downside (programming wise, or just in general) to have something similar to this?

input_datetime:
  my_time:
    has_date: false
    has_time: true
    initial: "20:10:23"

automation:
  - alias: "Time Trigger"
    trigger:
      - platform: time
        # perhaps value_template here? 
        at: " {{ states('input_datetime.my_time') }}"
    action:
      # ...

I use templates quite often, and while my way of writing them usually works, working with anything time-related is always a bit more difficult to me than other things. Please don’t get me wrong, I am not asking to change the ways just because I don’t understand how to handle time values :smiley: But I do think that this makes sense. It would be way easier to quickly create a time-based automation that can be modified without changing your code (just by changing the input_datetime value in lovelace; I use custom:time-picker-card for this).

So for now, I’ll just copy my working code, that is similar to what has been posted in the thread I linked above. Still, just suggesting this because I (from a non-programmer standpoint) think that it would be sensible.

Thank you for your feedback :slight_smile:

just to let you know you can use the input_datetime as trigger, without the template:

automation:
  - alias: test trigger
    trigger:
      - platform: time
        at: input_datetime.test_time

talking about the templates, it would still be nice if we could forgo the

    trigger:
      platform: template
      value_template: >
        {{states('sensor.time') == states('sensor.alarmclock_wd_time')}}

and simply use:

    trigger:
      platform: time
      at: >
        {{states('sensor.alarmclock_wd_time')}} 
# 07:15 format

so a +1