Files
zorruno-homeassistant/automations/zigbee_low_battery_notifications_2.yaml
2023-10-20 13:27:48 +13:00

33 lines
1.2 KiB
YAML

- id: notify_if_batteries_are_low
alias: Daily alert that zigbee batteries Are Low
initial_state: true
trigger:
- platform: time
at: "19:00:00"
condition:
- condition: or
conditions:
- condition: template
value_template: >
{% set min_battery_level = 20 -%}
{% set ns = namespace(found=false) -%}
{% for entity_id in states.group.battery_levels.attributes.entity_id -%}
{% set parts = entity_id.split('.') -%}
{% if (states(entity_id) | replace("%","") | int) < min_battery_level -%}
{% set ns.found = true -%}
{% endif -%}
{% endfor -%}
{{ ns.found }}
action:
- service: notify.pushover_2
data:
title: View Road Sensors
message: >
{%- set min_battery_level = 20 -%}
{%- for entity_id in states.group.battery_levels.attributes.entity_id -%}
{%- set parts = entity_id.split('.') -%}
{%- if (states(entity_id) | replace("%","") | int) < min_battery_level -%}
{{ states[parts[0]][parts[1]].name }} level is {{ states(entity_id) }}%.{{ '\n' }}
{%- endif -%}
{%- endfor -%}