Input_select HH:MM to be used as time trigger in automations

I am trying to set up an automation based on a number of fixed times such as:

input_select:
  late_night_check:
    name: Time to check
    options:
      - 00:00
      - 00:30
      - 01:00
      - 01:30
      - 02:00

I want to use it like this:

    trigger:
      platform: time
      at: '{{strptime(states.input_select.late_night_check.state, "HH:MM")}}'

The above timestamp gives me a value like ‘00:30’, but is not accepted in the automation.
Grateful for any hints on how to solve this.
Thanks

Try something like this:

trigger:
  platform: time
  minutes: '/1'
condition:
  condition: template
  value_template: '{{ ((now().strftime("%s") | int ) | timestamp_custom("%H:%M")) == states.input_select.late_night_check.state }}'
1 Like

Thanks, I will try that out, but I am a bit concerned about triggering something every minute to check stuff that will only apply once in a while and only between certain hours of the night.

Yeah, I know what you mean. There is another way I do this and I’ll check tonight at home but I use about 50 automations that are time triggers and no difference in performance. I’ll see if I can dig up the other method that I know works too.

I have tried and it works with >=, but not if I use ==, which is strange. The former is fine, but I need to reset a boolean switch then in order not to trigger the automation continously.

Really? That’s odd. I use it with a sensor and it works with no issues. What if you converted both to strings like this:

value_template: '{{ ((now().strftime("%s") | int ) | timestamp_custom("%H:%M") | string) ==(states.input_select.late_night_check.state | string) }}'

Yes, that could be worth a try. However, it worked nicely with >=, which also allows trigger every 5 minutes or less (as I going to have my input_select in steps of 30 minutes.

I settled for the following, similar to what I use for my alarm clock. Only needs to check every 5 minutes and quite readable as well:

- condition: template
  value_template: >
    {% set hour_to_check = states.input_select.late_night_check.state[:2] | round(0) %}
    {% set min_to_check = states.input_select.late_night_check.state[3:] | round(0) %}
    {{ now().hour == hour_to_check and now().minute - min_to_check >= 0 and now().minute - min_to_check <= 5 }}

I use a sensor to get current time, and a template trigger:

sensor:
  - platform: time_date
    display_options:
      - 'time'
--------------------------------------
automation:
...
trigger:
  platform: template
  value_template: '{{ states.sensor.time.state == states.input_select.alarma_cuarto.state }}'

Looks like a neat solution. Is your input_select.alarma_cuarto in the form of '06:00', '06:10' etc.?

Yes, they are, I use that for wake up alarm.

Thanks, I just tried and it worked beatifully!