Battery model/type field

It would be nice to have a metadata field to register the model/type of a battery, for example CR2032 or AAA+ etc.

You might be interested in Notes on device pages

1 Like

For now, you can actually add a custom attribute to any entity via your customize.yaml.

sensor.some_battery:
  battery_type: CR2032

Access it like so:

{{ states.sensor.some_battery.attributes.battery_type }}

Maybe this will work too (I can’t test it right now):

{{ state_attr('sensor.some_battery', 'attributes.battery_type') }}

No, access it like any attribute:

{{ state_attr('sensor.some_battery', 'battery_type') }}

Right you are! I never went back after my comment to test the bit I was unsure of.

I think I was remembering this syntax when I use it to filter, e.g.:

states.sensor | selectattr('attributes.monitor', 'eq', True)

Or then for this use case:

states.sensor | selectattr('attributes. battery_type', 'eq', 'AAA+')

The custom attribute thing is a useful workaround, thanks for flagging that. But if I understand correctly, the attribute would need to be added to every device individually. If I add a new motion sensor to my system that’s the same model as all my other motion sensors, I’d have to add the battery info to it.

One reason this feature would be great would be the ability for the battery type to be part of the metadata of the device type.

You might be able to use customize_glob to add attributes in bulk.

1 Like

Oh that’s a good tip. I found docs for it here: Customizing entities - Home Assistant

Hi,
Good idea, and voted.
The battery information would also fit well in a new battery control panel, as requested here:

I think both ideas could be realized together.

I would like to see a Battery Type field or a text field for Devices. This would allow us to put in the battery type for battery powered devices. Lacking that -OR- a text field wherein we can place the Battery type and any other data that we would have to track it outside HA.

Often, I / We do not have a good method for keeping track of the battery types for our devices. When the battery level starts to get close to depletion, we can check the Device and glean the battery type that we need to order. It would allow automation to say device x battery is getting low, time to order more type X batteries.

Thanks
Randy

Use the Battery Notes integration from HACS. Most of your battery-powered devices will be auto discovered.

1 Like

I’d like to submit an amendment to the OP, have HA make the Battery Notes integration part of the standard offerings and not have to install it via HACS.

This integration does exactly what you want and also allows for setting low battery flags at a device level plus some other handy features.

It may be the developer’s choice offer it through HACS - submission/testing/documentation procedures are more flexible.