Last active
August 25, 2025 16:07
-
-
Save Geek-MD/e79ed1aec5f527cb2c11e223110e31d9 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint: Low Battery Notificator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: Low Battery Notificator (Include List) | |
| description: Notifies when any selected battery sensor drops below a threshold. Only the chosen entities are monitored (allow-list). Executes periodically and at defined times, with optional logging. | |
| domain: automation | |
| author: Edison Montes @_GeekMD_ | |
| homeassistant: | |
| min_version: 2024.6.0 | |
| input: | |
| start_time: | |
| name: Start Time | |
| description: Start of the notification window. | |
| default: '08:00:00' | |
| selector: | |
| time: {} | |
| end_time: | |
| name: End Time | |
| description: End of the notification window. | |
| default: '22:00:00' | |
| selector: | |
| time: {} | |
| battery_level: | |
| name: Battery Level Threshold | |
| description: Notify when battery is below this percentage. | |
| default: 20 | |
| selector: | |
| number: | |
| min: 0 | |
| max: 100 | |
| step: 1 | |
| unit_of_measurement: '%' | |
| mode: slider | |
| interval_minutes: | |
| name: Execution Interval (Minutes) | |
| description: Run every N minutes during the time window. | |
| default: 30 | |
| selector: | |
| number: | |
| min: 1 | |
| max: 120 | |
| step: 1 | |
| unit_of_measurement: min | |
| included_entities: | |
| name: Included Entities | |
| description: Battery sensors to include in monitoring. | |
| default: [] | |
| selector: | |
| entity: | |
| multiple: true | |
| domain: sensor | |
| device_class: battery | |
| enable_logging: | |
| name: Enable Logging | |
| description: Show a persistent notification every time low battery is detected. | |
| default: false | |
| selector: | |
| boolean: {} | |
| actions: | |
| name: Actions | |
| description: > | |
| Actions to run when low battery is detected. | |
| Use `{{ low_battery_list | join('\n') }}` in your message to list devices. | |
| selector: | |
| action: {} | |
| trigger: | |
| - platform: time | |
| at: !input start_time | |
| - platform: time | |
| at: !input end_time | |
| - platform: homeassistant | |
| event: start | |
| - platform: template | |
| value_template: > | |
| {% set minutes = now().minute %} | |
| {% set interval = interval_minutes | int %} | |
| {{ (minutes % interval) == 0 }} | |
| variables: | |
| battery_level: !input battery_level | |
| interval_minutes: !input interval_minutes | |
| enable_logging: !input enable_logging | |
| included_entities: !input included_entities | |
| low_battery_devices: > | |
| {% set umbral = battery_level | int %} | |
| {% set out = namespace(lst=[]) %} | |
| {% for entity_id in included_entities %} | |
| {% set val = states(entity_id) %} | |
| {% if val not in ['unknown', 'unavailable', 'none'] %} | |
| {% set nivel = val | int(default=100) %} | |
| {% if 0 <= nivel < umbral %} | |
| {% set nombre = state_attr(entity_id, 'friendly_name') or entity_id %} | |
| {% set out.lst = out.lst + [ nombre ~ ' (' ~ nivel ~ '%)' ] %} | |
| {% endif %} | |
| {% endif %} | |
| {% endfor %} | |
| {{ out.lst }} | |
| condition: | |
| - condition: and | |
| conditions: | |
| - condition: time | |
| after: !input start_time | |
| before: !input end_time | |
| - condition: template | |
| value_template: "{{ low_battery_devices | length > 0 }}" | |
| action: | |
| - variables: | |
| low_battery_list: "{{ low_battery_devices }}" | |
| - choose: | |
| - conditions: | |
| - "{{ low_battery_devices | length > 0 }}" | |
| sequence: | |
| - choose: [] | |
| default: !input actions | |
| - service: logbook.log | |
| data: | |
| name: Low Battery Notificator | |
| message: > | |
| Executed at {{ now().strftime('%Y-%m-%d %H:%M:%S') }}. | |
| Devices below {{ battery_level }}%: {{ low_battery_devices | length }} | |
| - conditions: | |
| - "{{ low_battery_devices | length == 0 }}" | |
| sequence: | |
| - service: logbook.log | |
| data: | |
| name: Low Battery Notificator | |
| message: > | |
| Automation executed at {{ now().strftime('%Y-%m-%d %H:%M:%S') }}. | |
| No devices below threshold — no action taken. | |
| - choose: | |
| - conditions: | |
| - "{{ enable_logging }}" | |
| sequence: | |
| - service: persistent_notification.create | |
| data: | |
| title: "Low Battery Check Executed" | |
| message: > | |
| Execution time: {{ now().strftime('%Y-%m-%d %H:%M:%S') }} | |
| Interval: every {{ interval_minutes }} minutes | |
| Devices below threshold: {{ low_battery_devices | length }} | |
| {% if low_battery_devices | length > 0 %} | |
| {{ low_battery_devices | join('\n') }} | |
| {% else %} | |
| No devices with low battery. | |
| {% endif %} | |
| mode: single |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment