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.
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.
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.