Hello, I’m getting an error when running one of my automations that I’m not sure how to fix. I’m trying to set an input_datetime based on a few different sensors.
Here’s the automation:
- alias: Kids Light ready to go for tomorrow
trigger:
- platform: time
at: '11:30:00'
condition:
- condition: state
entity_id: input_boolean.vacation_mode
state: 'off'
action:
- service: input_datetime.set_datetime
entity_id: input_datetime.kids_light
data_template:
time: >-
{% if is_state('sensor.school_day_tomorrow', 'true') %}
"06:30:00"
{% elif is_state('sensor.distance_learning_tomorrow', 'true') %}
"07:00:00"
{% else %}
"07:30:00"
{% endif %}
And here’s the error:
Invalid time specified: "07:30:00" for dictionary value @ data['time']
The reason is because your original example specified the time values with unnecessary double-quotes. Remove them and the error message will be eliminated.
Your second example works not because the template is all on one line but because the time values are no longer wrapped in double-quotes.
To be fair, the docs show all the example as having quotes. Tho there was no example specific to this it seems that it should work to use quotes here too.