Manage batteries - how do you do it?

Hi Team

Would like to hear how you manage your batteries level in devices… so they don’t suddenly stop working.

Tried to build a ‘battery dashboard’ where I added all batteries, but it dies… Then tried to tag all relevant batteries…. but also died….

Would like to have a function like the ‘SW update’ just for batteries… or some other function…

What do you do ?

/Joern

I use Grocy to keep track of battery changes. I only use it for tracking, but you can also set up schedules.

1 Like

There are several blueprints that may work for you. But succes may vary on different devices.

Do you have a sensor for battery level for each device you want to monitor?

How about Battery notes ?

4 Likes

I’d be curious what you mean by “it dies” for both the dashboard and the tags. I’ve used both strategies with good success. I’ve ended up getting rid of the dashboards, but I still use tags (it’s the easiest way to identify which things are batteries I want to track).

First, I tag all the batteries with “Battery Tracking.”

Second, I have a template binary_sensor to figure out if ANY battery is below 20%. The state template for that is:

{{ (label_entities('Battery Tracking') |
          expand() |
          map(attribute='state') |
          map('int', 100) |
          select('<=', 20) |
          list |
          count) > 0 }}

Third, I have HA create a notification that lists all the batteries that are low.

alias: Notify on Low Batteries
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.batteries_low
    to: "on"
    for:
      hours: 0
      minutes: 5
      seconds: 0
conditions: []
actions:
  - action: persistent_notification.create
    metadata: {}
    data:
      title: Low Batteries
      message: >-
        {% set s = label_entities('Battery Tracking') | expand() |
        selectattr('state', 'is_number') | list -%} {% set n = s |
        map(attribute='name') | list -%} {% set v = s | map(attribute='state') |
        map('int', 100) | list -%} {% set l = zip(n, v) | selectattr(1, '<', 20)
        %} {% for i in l %}{{ i[0] }} {% endfor %}
mode: queued

Does that integration have the option to select 'Cheap Chinese batteries bought from cheapest vendor"? Guessing on battery life without sensing, based on passage of time, may not be consistently reliable.

When saying ‘dies’ - more mening me remembering to ‘tag’ all the new devices.

I where hopeing for some smart automated functions in HA that I had missed…
But i think your solution is the next best :wink: … I will try to set it up like you have described.

Thanks to all that have commented.

/Joern

Did you ever saw / use this integration?

Whynwpuld you Neede to tag entities?
Device class battery should cover all. Select the sensors for % and the binaries for ’ replace soon’

Battery notes (hacs addon) and 🪫 Low Battery Notifications & Actions (blueprint).

both are great, similar but different, and can be used together.

For me, that battery device class would include things like my phone battery that I don’t want to track. Thus why I tag the ones I want.

Fair enough, though I would reverse it. Tag excluding entities, so you won’t need to maintain new devices until you want it excludes

2 Likes

I do a riff on this. Device class + a specific ‘exclude’ label for a lot of things. I just add a filter - not in label_entities(foo) befoyi get the result and it drops all the ones I want excluded for… Whatever. It’s pretty flexible.

Battery notes is my goto. It’s pretty good.
The templates are more for information to the llm and I’m looking at grocy as future solution.

But… Grocy is HEAVY it’s a great home erp solution but you need to commit to grocy I wouldn’t do it just for batteries. (fun side note I’m doing a ton of llm work with grocy specifically the battery integration this weekend funny enough… and my recommendation will likely change from battery notes to Grocy IF you use an AI to drive it AND have a good LLM tool for Grocy)

It was about everything I could do to figure out the YAML to do the list of things in the tag. I think my head might explode if I try and subtract one list from another. :rofl: Although I do like that with the exclude tag things get tracked by default. I might have to risk a brain aneurism and try that out.

1 Like

recognizable, been on syntax wars for years, thats where a forum can help out ofcourse.

I think somehting like below, but @NathanCu can definitely share a sample or improvement on this

{{ states.sensor 
  | selectattr('attributes.device_class', 'defined')
  | selectattr('attributes.device_class', 'eq', 'battery')
  | rejectattr('entity_id', 'in', label_entities('no_tracking'))
  | map(attribute='state')
  | select('is_number')
  | map('int', 100)
  | select('<=', 20)
  | list 
  | count > 0 
}}
2 Likes