20 lines
622 B
YAML
20 lines
622 B
YAML
- platform: template
|
|
sensors:
|
|
devices_with_low_battery:
|
|
friendly_name: "Devices with low battery"
|
|
unit_of_measurement: devices
|
|
value_template: >-
|
|
{{ states.sensor
|
|
| selectattr('attributes.device_class', 'eq', 'battery')
|
|
| map(attribute='state')
|
|
| reject('in', ['unknown', 'unavailable', 'Ok'])
|
|
| map('int', -1) | select('le', 97)
|
|
| list | count
|
|
}}
|
|
icon_template: >-
|
|
{% if is_state('sensor.devices_with_low_battery', '0') %}
|
|
mdi:check-circle
|
|
{% else %}
|
|
mdi:battery-alert
|
|
{% endif %}
|