The problem
Using list.append causes an error:
SecurityError: access to attribute 'append' of 'list' object is unsafe.
Environment
- Home Assistant Core release with the issue: 0.107.7
- Last working Home Assistant Core release (if known): N/A
- Operating environment (Home Assistant/Supervised/Docker/venv): Docker
- Integration causing this issue: Templating?
- Link to integration documentation on our website: https://www.home-assistant.io/docs/configuration/templating/
Problem-relevant configuration.yaml
Jinja template:
{% set entities = [] %}
{% for state in states.cover %}
{{ entities.append(state.entity_id) }}
{% endfor %}
{{ entities|join(',') }}
Traceback/Error logs
SecurityError: access to attribute 'append' of 'list' object is unsafe.
Additional information
I can understand why this could be a security issue if you could append to states.cover for example ... but for local variables??
I know there are workarounds like:
{%- set entities = namespace() %}
{%- set entities.entities = '' %}
{%- for state in states.cover -%}
{%- if entities.entities != '' %}{% set entities.entities = entities.entities + ',' %}{%- endif %}
{%- set entities.entities = entities.entities + state.entity_id %}
{%- endfor %}
{{- entities.entities }}
... but this is not as nice and somewhat tedious.
The problem
Using list.append causes an error:
SecurityError: access to attribute 'append' of 'list' object is unsafe.
Environment
Problem-relevant
configuration.yamlJinja template:
Traceback/Error logs
Additional information
I can understand why this could be a security issue if you could append to states.cover for example ... but for local variables??
I know there are workarounds like:
... but this is not as nice and somewhat tedious.