initial commit
This commit is contained in:
75
battery-monitor.yaml
Normal file
75
battery-monitor.yaml
Normal file
@ -0,0 +1,75 @@
|
||||
blueprint:
|
||||
name: Battery Monitor
|
||||
description: Monitors battery levels of selected entities and exposes a low battery summary
|
||||
domain: automation
|
||||
input:
|
||||
battery_sensors:
|
||||
name: Battery Sensors
|
||||
description: List of battery level sensors to monitor
|
||||
selector:
|
||||
entity:
|
||||
domain: sensor
|
||||
multiple: true
|
||||
threshold:
|
||||
name: Low Battery Threshold
|
||||
description: Battery percentage threshold to consider "low"
|
||||
default: 20
|
||||
selector:
|
||||
number:
|
||||
min: 1
|
||||
max: 100
|
||||
step: 1
|
||||
unit_of_measurement: "%"
|
||||
notify_service:
|
||||
name: Notification Service (Optional)
|
||||
description: Service to call if any battery is low (e.g., notify.mobile_app_pixel)
|
||||
default: ""
|
||||
selector:
|
||||
text:
|
||||
|
||||
mode: single
|
||||
|
||||
trigger:
|
||||
- platform: time_pattern
|
||||
minutes: "/30" # Check every 30 minutes
|
||||
|
||||
variables:
|
||||
threshold: !input threshold
|
||||
battery_sensors: !input battery_sensors
|
||||
notify_service: !input notify_service
|
||||
|
||||
condition: []
|
||||
|
||||
action:
|
||||
- variables:
|
||||
low_batteries: >
|
||||
{% set low = namespace(devices=[]) %}
|
||||
{% for entity_id in battery_sensors %}
|
||||
{% set level = states(entity_id) | int(100) %}
|
||||
{% if level <= threshold %}
|
||||
{% set name = state_attr(entity_id, 'friendly_name') or entity_id %}
|
||||
{% set low.devices = low.devices + [name ~ ' (' ~ level ~ '%)'] %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{{ low.devices }}
|
||||
|
||||
- choose:
|
||||
- conditions: "{{ low_batteries | length > 0 }}"
|
||||
sequence:
|
||||
- service: input_text.set_value
|
||||
target:
|
||||
entity_id: input_text.devices_with_low_battery
|
||||
data:
|
||||
value: "{{ low_batteries | join(', ') }}"
|
||||
- condition: "{{ notify_service != '' }}"
|
||||
- service: "{{ notify_service }}"
|
||||
data:
|
||||
message: >
|
||||
Low battery detected: {{ low_batteries | join(', ') }}
|
||||
default:
|
||||
- service: input_text.set_value
|
||||
target:
|
||||
entity_id: input_text.devices_with_low_battery
|
||||
data:
|
||||
value: "All batteries healthy"
|
||||
|
Reference in New Issue
Block a user