@chemelli wrote:
Hi,
I would like to build a dynamic list of entities for my automation.
Searched all over but I didn’t find a clear way to proceed. So I have some questions:
- Should I use a value_template in trigger ?
- If so, value_template should return a list of entity_ids or a true/false condition ?
Tested without success the following couple of approches:
trigger: platform: template value_template: "{% set list = namespace(id=[]) %} {% for s in states.sensor %} {% if s.object_id.startswith('shelly') and s.object_id.endswith('_uptime_attr') %} {% set list.id = list.id + [ s.entity_id ] %} {% endif %} {% endfor %} {{ list.id }}"
and
{% for state in states %} {% if state.entity_id | regex_match('.*\.shelly.*_uptime_attr') %} {{ state. }}, {% endif %} {% endfor %}
Any suggestion is more than welcome.
Simone
Posts: 2
Participants: 2