andrew-codechimp / HA-Battery-Notes

A Home Assistant integration to provide battery notes of devices
MIT License
529 stars 92 forks source link

Add battery_quantity attribute to battery_type entity #375

Closed nechry closed 9 months ago

nechry commented 9 months ago

Checklist

Is your feature request related to a problem? Please describe.

first of all thank you for this integration. I previously built my battery information base using customization (customize.yaml) like this:

sensor.first_floor_landing_motion_sensor_battery_level:
  battery_type: CR123A
sensor.first_floor_landing_smoke_sensor_battery_level:
  battery_type: CR123A
sensor.first_floor_landing_lcd_battery:
  battery_type: LR03/AAA
  quantity: 2
sensor.aqara_opple_switch_2x2_battery:
  battery_type: CR2032
sensor.anemometer_battery:
  battery_type: LR06/AA
sensor.attic_staircase_motion_sensor_battery:
  battery_type: CR2450

This way I added the battery type and quantity to the device's existing battery. You can find more details on my github https://github.com/nechry/ha-battery-inventory

The goal is to reproduce a list of batteries by battery type with the total number of batteries by type and % charge remaining. This is very useful for planning battery ordering.

Describe the solution you'd like

If it would be possible to add the quantity to the battery_type information as an attribute it would be very useful for producing battery reports

Describe alternatives you've considered

it is possible to parse the text sensor with a regex to cut the quantity of the type but I think it would still be cumbersome

Additional context

nothing to add at first but remains available to discuss it

andrew-codechimp commented 9 months ago

Nice idea, I can add some attributes to split the quantity and type, ironically I'll have to write a regex as well as I have it as one combined string when it is assigned to the device but better to do it in the integration than make everyone do it themselves.

nechry commented 9 months ago

great thank for your positive feedback, next step will be to mix information of the battery level with type to reproduce my previous battery remplacement report.

andrew-codechimp commented 9 months ago

I have a rough version working with a bit of regex

CleanShot 2024-01-06 at 11 47 44@2x

And yes I always test with Sun & Forecast because they are always in a fresh HA install 😄

andrew-codechimp commented 9 months ago

This is now available in version 1.4.0 which is in pre-release

nechry commented 9 months ago

thank-you I will try it soon