Help with data_template automation

I changed the format as below but error message remains the same:

# Front Lights Off at Night
- id: front_lights_off_at_night
  alias: front lights off at night
  trigger:
    platform: time
    at: '{% if states("sensor.season") == "Winter" %}"21:30:00"{%  elif states("sensor.season") == "Spring" %}"22:30:00"{%  elif states("sensor.season") == "Summer" %}"23:59:59"{%  elif states("sensor.season") == "Autumn" %}"23:00:00"{% endif %}'
  action:
    service: homeassistant.turn_off
    entity_id: switch.maindoor

Error message:
Invalid time specified: {% if states(“sensor.season”) == “Winter” %}“21:30:00”{% elif states(“sensor.season”) == “Spring” %}“22:30:00”{% elif states(“sensor.season”) == “Summer” %}“23:59:59”{% elif states(“sensor.season”) == “Autumn” %}“23:00:00”{% endif %} for dictionary value @ data[‘trigger’][0][‘at’]. Got None. (See /config/configuration.yaml, line 299). Please check the docs at https://home-assistant.io/components/automation/

That’s probably because you aren’t using a sensor with a delay :stuck_out_tongue:

1 Like