various tidyups
This commit is contained in:
@@ -1,17 +1,24 @@
|
||||
#:########################################################################################:#
|
||||
# Low Battery Device Summary Package #
|
||||
# Low Battery Monitoring Package #
|
||||
#:########################################################################################:#
|
||||
#
|
||||
# TITLE:
|
||||
# Low Battery Device Summary
|
||||
# Low Battery Monitoring
|
||||
#
|
||||
# FILE:
|
||||
# packages/low_battery_device_quantity.yaml
|
||||
#
|
||||
# VERSION:
|
||||
# V1.1 2026-07-20
|
||||
# V1.2 2026-07-23
|
||||
#
|
||||
# VERSION HISTORY:
|
||||
# V1.3 2026-07-24
|
||||
# - Truncated list sensor state to count-only summary; full list stays in attributes.
|
||||
#
|
||||
# V1.2 2026-07-23
|
||||
# - Moved the weekly low-battery blueprint automation into this package.
|
||||
# - Preserved the Monday 21:00 schedule and Zorruno Pushover notification.
|
||||
#
|
||||
# V1.1 2026-07-20
|
||||
# - Changed the low-battery threshold from 97% to 20%.
|
||||
# - Added structured documentation for scope, exclusions, and outputs.
|
||||
@@ -21,17 +28,19 @@
|
||||
#
|
||||
# PURPOSE:
|
||||
# Finds numeric sensor entities with device_class battery whose value is 20%
|
||||
# or lower, then exposes a count and a human-readable device list.
|
||||
# or lower, exposes count and list sensors, and runs a weekly notification.
|
||||
#
|
||||
# SCOPE AND EXCLUSIONS:
|
||||
# - Only entities in the sensor domain with device_class battery are checked.
|
||||
# - Unknown, unavailable, non-numeric, and "Ok" states are excluded.
|
||||
# - Battery entities in other domains are not included.
|
||||
# - Battery entities in other domains are not included in the summaries.
|
||||
# - The notification blueprint also checks battery binary sensors.
|
||||
#
|
||||
# OUTPUTS:
|
||||
# - sensor.devices_with_low_battery reports the number of matching sensors.
|
||||
# - sensor.devices_with_low_battery_list reports names and percentages.
|
||||
# - The list sensor also exposes count, entities, and names attributes.
|
||||
# - A Pushover notification runs each Monday at 21:00 when batteries are low.
|
||||
#
|
||||
#:########################################################################################:#
|
||||
|
||||
@@ -69,21 +78,11 @@ template:
|
||||
mdi:battery-alert
|
||||
{% endif %}
|
||||
state: >
|
||||
{% set ns = namespace(names=[]) %}
|
||||
{% for s in states.sensor %}
|
||||
{% if s.attributes.device_class == 'battery' %}
|
||||
{% set st = s.state %}
|
||||
{% if st not in ['unknown', 'unavailable', 'Ok'] %}
|
||||
{% if st | int(-1) != -1 and (st | int(0)) <= 20 %}
|
||||
{% set ns.names = ns.names + [s.name ~ ' (' ~ (st | int(0)) ~ '%)'] %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if ns.names | length == 0 %}
|
||||
{% set count = states('sensor.devices_with_low_battery') | int(0) %}
|
||||
{% if count == 0 %}
|
||||
None
|
||||
{% else %}
|
||||
{{ ns.names | join(', ') }}
|
||||
{{ count }} devices
|
||||
{% endif %}
|
||||
attributes:
|
||||
count: "{{ states('sensor.devices_with_low_battery') | int(0) }}"
|
||||
@@ -113,3 +112,22 @@ template:
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ ns.n }}
|
||||
|
||||
automation:
|
||||
- id: "1635929281159"
|
||||
alias: "Weekly Low battery level detection"
|
||||
description: >
|
||||
Checks battery-class entities each Monday and notifies Zorruno when any
|
||||
are below the blueprint threshold.
|
||||
use_blueprint:
|
||||
path: sbyx/low-battery-level-detection-notification-for-all-battery-sensors.yaml
|
||||
input:
|
||||
day: 1
|
||||
time: "21:00:00"
|
||||
actions:
|
||||
- action: notify.pushover_zorruno
|
||||
data:
|
||||
title: "View Road Sensors"
|
||||
message: >
|
||||
Weekly Battery Check. Low Devices:
|
||||
{{ sensors }}
|
||||
|
||||
Reference in New Issue
Block a user