Automation - (TemplateSyntaxError: tag name expected)

Hello there!

I am trying to automate a daylight alarm clock. It should read the next alarm comig up at my phone and then if its a maximum of 10 minutes to go the lights should start.
There are 2 lights in the lamp - one in the bottom and one in the top. So I am starting the bottom light first and the top one second.
My logs give me this:

Invalid config for [automation]: invalid template (TemplateSyntaxError: tag name expected) for dictionary value @ data['action'][0]['repeat']['sequence'][0]['repeat']['sequence'][0]['data']. Got None. (See /config/configuration.yaml, line 18)

And here is my automation:

- id: 'xxxxxx'
  alias: Alarm_clock
  trigger:
  - platform: template
    value_template: "{% ( as_timestamp(now())+600 | int ) > ((state_attr('sensor.oneplus_a5000_next_alarm', 'Time in Milliseconds') /1000) | int) > ( as_timestamp(now()) | int ) %}"
  condition:
  - condition: zone
    entity_id: person.me
    zone: zone.home
  action:
  - repeat:
      until:
        - condition: numeric_state
          entity_id: light.novo7w_2
          value_template: states.light.novo7w_2.attributes.brightness
          above: 254
      sequence:
      - repeat:
          until:
            - condition: numeric_state
              entity_id: light.novo7w_1
              value_template: states.light.novo7w_1.attributes.brightness
              above: 150
          sequence:
          - service: light.turn_on
            data:
              brightness: '{% (50 + repeat.index) %}'
              rgb_color: [255,'{% repeat.index %}','{% (((-170 + repeat.index), 0) | max) %}']
            entity_id: light.novo7w_1
          - delay: 3
      - repeat:
          until:
            - condition: numeric_state
              entity_id: light.novo7w_1
              value_template: states.light.novo7w_1.attributes.brightness
              above: 254
          sequence:
          - service: light.turn_on
            data:
              brightness: '{% ((200 + repeat.index), 255) | min %}'
              rgb_color: [255,'{% 50 + repeat.index %}','{% ((-150 + repeat.index), 0) | max %}']
            entity_id: light.novo7w_1
          - service: light.turn_on
            data:
              color_temp: '{% (500 - repeat.index) %}'
              white_value: '{% (50 + repeat.index) %}'
            entity_id: light.novo7w_2
          - delay: 2
  mode: single

Would love to find my problem. Thank you in advance!

Templates are rendered by use of {{…}}.

The {%…%} returns no result but only sets variables internally to the template.

Try changing the {%…%} to {{…}}.

I’m still not 100% sure it’ll work but it’s a start.

1 Like

Hey, your advice was the right point to start. I had to implement the sensor.datetime instead of “now()” and change some things here and there like putting the value_template content in ‘{{ […] }}’ as well. It works like a charm! Thanks for the response :slight_smile: