Hi all,
wonder if anyone can help with the following scenario:
I’m looking to make use of a input_select, where a list of half hour times are provided. I’m trying to match the current time to the time selected (or within a 5 min after tolerance):
The dropdown list of values are defined as below:
I’ve tried creating 2 templates, called current_time and current_time_plus_5
- sensor:
- name: current_time
state: >
{{ (now()).strftime("%H:%M:%S") }}
- name: current_time_plus_5
state: >
{{ (now() + timedelta(minutes = 5)).strftime("%H:%M:%S") }}
Which is then picked up in a template in an automation:
{% if ((states('input_select.time_of_day') >= states('current_time')) and (states('input_select.time_of_day') <= states('current_time_plus_5'))) %}
true
{% else %}
false
{% endif %}
However, even with the current time is within the allocated timeframe, this is still not returning true.
Can anyone help with how this should be coded?
Thanks in advance!