[Custom Component] Battery Notes

I’ve installed it and found it only discovers a handful of the batteries in my HA instance. For example, I’ve got 6 Eufy cameras but Battery Notes only discovered two of them. I’ve got about a dozen Aqara battery-powered sensors integrated via Matter (over wifi via Aqara hub) but Battery Notes doesn’t discover any of them.

If I try to add a device to Battery Notes manually I get “Want to add these discovered devices?” with none of the devices I want to add listed.

What am I doing wrong?

How do I uninstall Battery Notes? Nothing wrong with it but I haven’t a need for it but I don’t anywhere where I can remove the integration.

Go to HACS, find the Battery Notes Integration, three dot menu, Remove.

In addition to what Jeff has detailed you will also want to remove the battery_notes section within your configuration.yaml and restart Home Assistant.
I’ve written up an FAQ here
https://andrew-codechimp.github.io/HA-Battery-Notes/faq/#how-do-i-uninstall-battery-notes

Thanks! The weird thing was that I didn’t have a “remove” option in HACS until I reinstalled the integration again and then I could “remove” it through HACS.

1 Like

That’s very strange, maybe you installed it manually originally rather than through HACS.

Love this integration, and thanks for the support on this forum.

I’ve been tracking batteries for over a year now and starting to replace a few batteries a second time. Curious now if there’s any interest or possibility of a new entity such as “Battery average lifetime” that begins updating upon the second replacement, and adjusts each time the battery is replaced? I assume it would need attributes somewhere to track the timestamps of each button press since this isn’t logged anywhere long-term I’m aware of. If it is, perhaps I can gen up a template sensor.

Hi, thanks for the kind words.

I’ve been asked about this a few times, due to different battery chemistry/brands I’ve not implemented it yet as it’s a lot of effort for what I think is probably not that useful in practice.
I do keep coming back to the idea, so it’s not a never, I’ve just not found it that compelling yet.

1 Like

I would use it to help tell what sensors not to buy from certain vendors. Right now it is just a feeling that certain sensors “eat” batteries where the identical sensor type from a different vendor has great battery life. It would be nice to be able to confirm this.

Hi and thank you for the integration. I was trying to add historical battery replacements which I was tracking just by making note on my phone, but it doesn’t I got unexpected results.
Firstly I was trying to do this by editing the state and ended up with below


I’ve tried deleting device to wipe the data but after readding device data returns - how can I delete all the data assigned to study_sensor_battery and try again?
Then I’ve looked at documentation and found I should have used action, this turned out better on other device

So dates seems to be correct, but in historical chart I was expected it to be from the date of battery replacement in 2024, but instead it reads 19min - is that expected? Is this only problem for past dates, e.g. once integration is running I would be able to see that one battery lasted 11 month and the other one lasted 19 months?
Thank you in advance!

Hi,
So changing state within developer tools (on any integration) does not save the data as you have seen, it’s always really confusing.
What you are seeing in the logbook is the recorder history of when you changed it, this is relatively short lived, default of 10 days, so that will clear itself up automatically in time now you have used the action which does a proper save of the value.

For your second question on those that you have used the action on, the logbook shows when you changed the value, it doesn’t know about the value being a date. Just ignore the logbook and look at the entity itself on the device page or a dashboard and that will show the correct x days/weeks etc, again these logbook entries will disappear in 10 days unless you’ve changed the default.

Don’t look at History/Logbook for entities with dates ever and you’ll be fine :slight_smile:

Awesome, thank you for the quick reply Andrew. One more question - will I be able to tell when multiple battery replacements happened once log history disappears or just when the last one happened? E.g. I’ve replaced batteries on thermostat on
2024-08-16
2024-12-09
2025-06-18

It’ll just be the last date you’ll be able to see once the history has expired. I don’t store that in long term statistics.

1 Like

My problem is that I have a lot of Tado thermostats and they don’t provide a percentage value. They don’t have a battery+ attribute. I think the only attribute that can be used to show the battery condition is the battery_plus_low.
But I haven’t manage to get that value yet.

This is my code:

type: custom:auto-entities
card:
  type: vertical-stack
card_param: cards
filter:
  template: |
    {% for state in states.sensor if "battery_plus" in state.entity_id 
     or ("tado" in state.entity_id and "battery" in state.entity_id and "T" not in state.state) -%}
      {{
        {
          "type": "custom:bubble-card",
          "card_type": "button",
          "button_type": "slider",
          "entity": state.entity_id,
          "name": state.attributes.friendly_name.split(' Battery')[0],          
          "icon": "mdi:battery" if "tado" in state.entity_id else None,
          "show_last_changed": false,
          "show_state": false if "tado" in state.entity_id else true,
          "read_only_slider": true,
          "scrolling_effect": false,
          "styles": ".bubble-range-fill {  \n  background-color: rgba(${state > 50.0 ?  '39, 174, 96' : state > 20.0 ? '243, 156, 18' : '192, 57, 43'}, 0.4) !important;\n}",
          "sub_button": [
            {
              "show_state": true,
              "show_state": true if "tado" in state.entity_id else None,
              "show_icon": false,
              "state_background": false,
              "show_background": false,
            },
             {
              "show_state": false,
              "show_icon": false,
              "state_background": false,
              "show_background": false,
              "show_attribute": true,
              "attribute": "battery_type_and_quantity",
            },
          ],
          "modules": [
            "default"
          ]
        }
      }},
    {%- endfor %}
sort:
  method: state
  numeric: true
  reverse: false
show_empty: true

I’m happy with everything else but it won’t help if Tados don’t show the battery condition, which should be Normal or Low.

Hopefully, someone can help me to fix that.

I found this in the documentation:

Battery Low Template#

This is for advanced use where a device does not have a typical battery percentage or battery low boolean (or it is innacurate) but still provides an indication of the level, such as a string, boolean or voltage.
You can specify a template that must return true when the battery is deemed low.

Example templates

{{ states('sensor.mysensor_battery_low') }}
{{ states('sensor.mysensor_battery_level') == "Low" }}
{{ states('sensor.mysensor_battery_voltage') | float(5) < 1 }}

But not sure how to implement that.

The battery low template won’t help, what you will need to do is create a fake battery percentage based on the devices battery low (not the battery plus low)
You should then get a battery+ percentage, I’d recommend removing the battery note from this device and re-adding it once you have created the helper though.
https://andrew-codechimp.github.io/HA-Battery-Notes/entities/#adding-a-battery-percentage

1 Like

Thanks @codechimp. I was able to fix the issue by referring to your link.

I’ve also implemented the snippet for the battery type search, which works really well. The only problem is that when I search for Rechargeable batteries, it doesn’t return any results.

Do you have any idea why that might be?

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: input_text.battery_search
        name: Search by battery type
        icon: mdi:magnify
        secondary_info: none
    state_color: false
  - type: markdown
    content: |-
      {% set search_term = states('input_text.battery_search') | upper %}
      {% if search_term != "" %}
        {% set devices = states | selectattr('attributes.battery_type', 'defined') 
                                  | selectattr('entity_id', 'search', '_battery_type$') | list %}
        {% set matching_devices = devices | selectattr('attributes.battery_type', 'string') 
                                            | selectattr('attributes.battery_type', 'eq', search_term) 
                                            | map(attribute='name') | unique | list %}
        {% if matching_devices | length > 0 %}
          {{ matching_devices | join('\n') }}
        {% else %}
          No devices with such battery type
        {% endif %}
      {% else %}
        Search result
      {% endif %}

Hi, that was a community contributed search, it had a small issue with its search, as it was aimed at just searching for true battery types.
I’ve just updated the docs with a new version here which does work for most cases.
https://andrew-codechimp.github.io/HA-Battery-Notes/community/#search-for-devices-with-a-particular-battery

1 Like

Hi Andrew, thanks for updating the docs and sharing the new version. I just checked and it works like a charm. Thanks again.

You were too quick, spotted an issue and there’s a new new one!

1 Like

@codechimp I installed the HA app on my MacBook today and, after restarting the HA server, Battery Note successfully recognised it and I was able to add it to the integration.

However, as shown in the screenshot below, the MacBook’s battery percentage is displayed as Unknown.

Do you know what might be causing this? Should I create a template sensor helper for the MacBook?

Thanks a lot for your help!