Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Need help for automation: trigger and value_template

$
0
0

@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

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>