This is a minimum example of a template, causing an TemplateSyntaxError in the template editor with HA 2021.5.4:
{% set z=1 %}
{% if z<02 %}
255
{% endif %}
This is the error caused: TemplateSyntaxError: expected token 'end of statement block', got 'integer'
This template doesn’t make much practical sense, but as said, it’s only a minimum example to trigger this error.
Using this template in an automation…
automation:
- id: xxx
trigger:
platform: time_pattern
minutes: "/5"
action:
- service: light.turn_on
data:
entity_id: light.bulb
brightness: >-
{% set z=1 %}
{% if z<02 %}
255
{% endif %}
…passes the Configuration validation…
… but it raises an invalid config notification…
…and an error in the log file:
2021-05-19 17:03:50 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token 'end of statement block', got 'integer') for dictionary value @ data['action'][0]['data']. Got None. (See ?, line ?).
When removing the leading zero from the if clause, the template is rendered without an error in the template editor as well as not causing an error in the log anymore:
{% set z=1 %}
{% if z<2 %}
255
{% endif %}
It seems, numbers with leading zeros aren’t interpreted as integers anymore. Is this expected behaviour?
Was there any (breaking) change between 2021.5.2 and 2021.5.4 which may have caused integers being interpreted differently than before? I read the release notes for 2021.5.3 and 2021.5.4, but couldn’t see any changes that may be related to this issue.