Files
zorruno-homeassistant/sensor/low_battery_template.yaml
2022-10-11 15:40:40 +13:00

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 %}