It’s not easy to test using trigger
states but am I right in thinking that trigger.now.hour
returns a single digit for hours less than ten? (also minutes and seconds).
If so is there a good justification for this?
In any case, if I have a set of input_datetime
being used as time
triggers, how best to ascertain which one caused the trigger?
This doesn’t work for hours or minutes less than ten, and unless there is a better way I think I am probably asking how to pad trigger.now.hour
(and minutes) with leading zeros up to 2 characters in jinja?
- alias: Heating Downstairs Schedules
variables:
active_schedule_no: >
{% for schedule in states.input_datetime if schedule.object_id.startswith('heating_downstairs_schedule_time') %}
{% if schedule.state == trigger.now.hour ~ ":" ~ trigger.now.minute ~ ':00' %}
{{ loop.index }}
{% endif %}
{% endfor %}
trigger:
- platform: time
at:
- input_datetime.heating_downstairs_schedule_time1
- input_datetime.heating_downstairs_schedule_time2
- input_datetime.heating_downstairs_schedule_time3
- input_datetime.heating_downstairs_schedule_time4
- input_datetime.heating_downstairs_schedule_time5
- input_datetime.heating_downstairs_schedule_time6