I created a dynamic group to list devices with low battery level on dashboard. Works mostly:
alias: Dynamic Battery Group
description: Creates Group of Items with Low Battery Level on HA Startup
triggers:
- trigger: homeassistant
event: start
conditions: []
actions:
- action: group.set
metadata: {}
data:
object_id: low_battery
name: Low Battery
icon: mdi:battery-outline
entities: >-
{{ states.sensor | selectattr('attributes.device_class', 'defined') |
selectattr('attributes.device_class', 'eq', 'battery') |
rejectattr('entity_id', 'eq', 'SM-S906U') | selectattr('state',
'lt','50') | map(attribute='entity_id') | list }}
mode: single
```yaml
Questions:
1. The rejectattr line is not working to prevent my phone with HA companion app from being on the list. Do I need to refer to that entity differently?
2. I have tried to create a separate template sensor to count the number of items in this dynamic group with no luck. This is to be used as a badge on a dashboard. Any example code on how to create this count sensor?
Any thoughts would be appreciated.