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