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

Templates select attributes

$
0
0

I am trying to make a template, where I rejectattributes that have friendly_name with Battery+, since I have two sets of Battery names, one just Battery and another with Battery+

´´´Dør Alrum Battery 99.5 %
Dør Alrum Battery+ 99.5 %
Dør Entre Battery 98.5 %
Dør Entre Battery+ 98.5 %´´´

´´´{% set entities = states
| selectattr(‘attributes.device_class’, ‘defined’)
| selectattr(‘attributes.state_class’, ‘defined’)
| selectattr(‘attributes.device_class’, ‘eq’, ‘battery’)
| rejectattr(‘attributes.friendly_name’, ‘search’, ‘Battery+’)
| selectattr(‘state’, ‘is_number’)
| sort(attribute=‘name’) | list -%}
{% for e in entities -%}
{{ e.name}} {{ e.state }} %
{% endfor %}´´´

HOwever, when the rejectattr(‘attributes.friendly_name’, ‘search’, ‘Battery+’), it removes all friendly_name with Battery (those with and without the + (plus) sign)

Any idea what I am doing wrong or is the + sign seen as Battery and more?

Marinus

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 106627

Trending Articles



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