TemplateSyntaxError: expected name or number

Can anyone explain why when I enter to following template, I get an error ‘TemplateSyntaxError: expected name or number’

- sensor:
    ############ Waste Today ######
    - name: "Waste Today"
      unique_id: 5bed5d68-e1bf-4027-a76b-3ec14d3a7285
      state: >
        {% set waste_type = "Nothing" %}
        {% set waste_collection_date = as_datetime(state_attr('sensor.upcoming','upcoming')[0].date) %}
        {% set days_until_collection = (waste_collection_date.date() - now().date()).days %}
        {% if days_until_collection == 0 %}
          {%set waste_type = state_attr('sensor.upcoming'.'upcoming')[0].type %}
        {% endif %}
        {{ waste_type }}

Because of:

1 Like

I am far from PC, but this I noticed first - seems that you typed a dot instead of a comma. Did not check other stuff.

Many thanks guys, that seems to be the issue.

Much appreciated

1 Like