I built an automation to check all devices in the group ‘batterie_sub’. (By the way: Some words are in german)
It checks at a specific time all entities in this group an notifies me on my iphone. It stops as soon as one device is below the predetermined value. In this case 34%.
# Check Battery
- alias: Check Battery
hide_entity: True
trigger:
- platform: time
at: '10:24:00'
condition:
- condition: template
value_template: >-
{% for entity_id in states.group.batterie_sub.attributes.entity_id if states(entity_id) | int < 34 %}
{%- if loop.first -%}
{{ true }}
{%- endif -%}
{% endfor %}
action:
- service: notify.ios_renes_iphone
data_template:
title: "Batteriestatus"
message: >-
{% for entity_id in states.group.batterie_sub.attributes.entity_id if states(entity_id) | int < 34 %}
{%- if loop.first -%}
{{ "Batterie "+ states[entity_id.split(".")[0]][ entity_id.split(".")[1]].attributes.friendly_name +" auf "+states(entity_id) +"% gefallen" }}
{%- endif -%}
{% endfor %}
data:
push:
category: "battery"
I don’t know if its ‘best practice’, but hey it works for me.