Trigger Automation Using Delay From Input_Select

I have an automation that turns on a light in my daughter’s room every morning at 0700, and she knows to keep sleeping or at least stay in there and play until it comes on. Some mornings we want to delay it by up to 30 minutes. I created an input_select with values 00, 05, 10, 15…up to 30. This makes it easy for my wife to just select a number and the delay should be taken care of from there (add the delay to 0700).

How can I integrate this input_select value into an automation trigger template to make this work? I have a time sensor, a time_date helper with 07:00 stored in it, and the input_select with the delay stored in it. I understand templates enough to know how to compare things, but I cannot figure out how to format things correctly to compare the current time to the 07:00+delay.

Have you considered setting the automation to fire at 07:00 and have the first action be wait? The wait time can be set with an input number.

Here is a snippet from my input_numbers.yaml file.

    name: wait_time
    icon: mdi:clock-start
    initial: 1
    min: 0.5
    max: 30
    step: 0.5
    mode: slider
    unit_of_measurement: min

The yaml in the automation will look something like this:

‘- delay: ‘{{ states(’‘input_number.wait_time’’) | multiply(60) | int }}‘’

I use this method for lawn irrigation

I downloaded the hacs slider-entry-row to make this settable from the front end. Here is a screenshot of the sliders for my irrigation system.


Wow, that’s the definition of keeping it simple. I was originally thinking we may add 5 minutes, then decide we want another 5 minutes. Your method would prevent that from working I think, but I don’t think that will be an issue. I like the slider even better than a drop down box too. Thanks for taking the time to help me out!

This should work in a Template Trigger if your input_datetime is time-only. If’s it time and date, the template will need to be adjusted. Let me know if that’s the case.

{{ (now().time()|string)[:5] == (state_attr('input_datetime.alarm_time', 'timestamp') + (states('input_select.offset') | int * 60)) | timestamp_custom('%H:%M', false) }}
  • The left hand side simply gets the current time as a string in this format: HH:MM

  • The right hand side gets the timestamp value of the input_datetime (in seconds) and adds it to the input_select’s value after it’s been converted to an integer and multiplied by 60 (to get seconds). The result is converted to a time string in this format: HH:MM

The template updates itself minimally every minute plus whenever you change the value of either the input_select or input_datetime.