{%- for item in states[domain] if ((item.attributes.battery_level is defined and item.attributes['battery_level'] | int < threshold) or ("battery" in item.name | lower and ((item.state | int < threshold and item.state|int != 0) or item.state | lower == "low" or item.state | lower == "unknown"))) -%}
{{item.attributes.friendly_name }} (
{%- if item.attributes.battery_level is defined -%}
{{item.attributes.battery_level}}
{%- else -%}
{{item.state}}
{%- endif -%}%)
{%- if not loop.last -%}
{{', '}}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
automation:
- alias:'Battery Alert'
initial_state:'on'
trigger:
- platform:time
at:'10:00:00'
- platform:time
at:'18:00:00'
condition:
condition:template
value_template:"{% if states('sensor.low_battery') %}true{% endif %}"