Hi, I’m using the following template with the auto-entities card to display a list of devices with low battery:
type: custom:auto-entities
card:
type: entities
title: Low Battery
filter:
template: |-
{{ states.sensor | selectattr("entity_id", "search", ".*_battery_level")
| selectattr("state", "is_number")
| selectattr("state", "le", "20")
| rejectattr("state", "in", ["unavailable", "unknown"])
| rejectattr("entity_id", "search", ".*_zwave")
| rejectattr("entity_id", "search", ".*iphone*")
| map(attribute="entity_id") | list }}
show_empty: false
The issue I’m having is that I’m seeing some entities in the resulting list with a state of 100%
or 100.0%
. I think this is because the state of these sensors are strings, rather than integers:
My question is, how could I modify the template above so that I’m testing if the integer of the state of selected entities is less than 20?
Thank you!