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

Multiple filters using selectattr

$
0
0

Hi,
how can filter two word in the domain-entity name ?
I mean f.i all domain-entities with the string “battery” OR “power” in the name (excluding the entitities in rejectattr filter…).
This code works good, but I can not add “power” in the filtering list.

{% set ns = namespace(namelist=[]) %}
{% set sensor_list = states 
|selectattr("entity_id", "search", "battery")  **OR "power"**
|rejectattr("entity_id", "search", "group*")
|rejectattr("entity_id", "search", ".*amassimo")
|list %}
{% for sensor in sensor_list %}
  {% if sensor.state | int < 90 | int %}
    {% set ns.namelist = [sensor.name+'('+sensor.state+')']  + ns.namelist %}
  {% endif %}
{%endfor%}
{{ns.namelist | join('\n') }}

Thanks all

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 103369

Trending Articles



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