Skip to content

Batteries

Jenx edited this page Mar 2, 2022 · 1 revision

With 52 devices and growing, batteries power the majority of them. So far I have not had to replace any, but its getting close to the time when the original devices will need replacement batteries. Some devices also have rechargeable batteries (my ring cameras are a good example). These need recharging regularly. This automation provides a notification when the battery state, as reported by the device, drops below a threshold.

In the yaml file you will see that I have grouped the batteries, this is no longer in use because when the automation triggers I wanted the device showing as a problem to be included in the notification. So now all devices are maintained in a yaml file called "group_batteries.yml" and that is included in the list of entities in the automation so the code can capture which device is a problem.

AUTOMATIONS

Power levels

The trigger for this automation is the reported power level of the battery falling below 20%. This is accomplished with a numeric state trigger. It creates a persistent notification on the Lovelace dashboard, I also have an entity card which lists those devices that have a battery level below 20% on the main screen.

`trigger:
  - platform: numeric_state
    entity_id: !include ../group_batteries.yaml
    below: "20"
action:
  - service: persistent_notification.create
    data_template:
      message: "{{ trigger.entity_id }} less than 20% - Battery needs replacing"
      title: "Warning: Low Battery, please replace"`

Note the data template captures the trigger entity and incorporates it into the message.

SCRIPTS

None

FUTURE

No current plans for changes.

OTHER

Clone this wiki locally