Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Additional optional entity for the date of the last battery replacement #23

Closed
3 tasks done
jimmhead opened this issue Dec 4, 2023 · 22 comments · Fixed by #147
Closed
3 tasks done
Assignees
Labels
enhancement New feature or request

Comments

@jimmhead
Copy link

jimmhead commented Dec 4, 2023

Checklist

  • I have filled out the template to the best of my ability.
  • This only contains 1 feature request (if you have multiple feature requests, open one feature request for each feature request).
  • This issue is not a duplicate feature request of previous feature requests.

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

No way to keep track of when a battery is replaced against the device in HA

Describe the solution you'd like

Suggestion: Optionally add a second entity to go alongside the battery type, where the user can define the date of the last time the battery was replaced as a date selector field (similar to the date helper).

Describe alternatives you've considered

I tried setting up helpers, but not having the helper entity added to the device made it difficult to keep track of everything.

I also tried setting the 'Battery type' entity from this integration to the battery type followed by the last change date, but doing this don't get the history of the changes you would get from a date entity.

Additional context

Keeping track of when batteries are changed can be a bit of a nightmare when you have a lot of devices, being able to record the last time a battery was changed helps identify devices that are draining battery's too fast and how many replacement batteries needed per year etc.

@andrew-codechimp andrew-codechimp added the enhancement New feature or request label Dec 4, 2023
@andrew-codechimp
Copy link
Owner

This is something I want to do as well and will try and get it into a future release.

@magicus
Copy link

magicus commented Dec 7, 2023

I wonder if it is possible to track this automatically? If the battery level rises sharply from a low figure up to close to 100%, this should be possible to detect and store the date automatically.

A derived sensor could also use this to predict how long the battery is going to last.

@andrew-codechimp
Copy link
Owner

The automatic tracking of a battery change is a nice idea, I think at the moment my plan is to provide a button/service to set the battery changed date so there will be options to automate it in the future.

@teranex
Copy link

teranex commented Dec 8, 2023

Automatically tracking could certainly be a nice idea, but should you implement it, I think it is best to make it configurable per device. I have some zigbee devices for which the reported battery switches a lot. One moment they report 60%, then they report 30% an hour later, and then a bit later they report 70%... for those devices the automatic tracking would not work.

@andrew-codechimp
Copy link
Owner

Not seen any of mine fluctuate that wildly but noted, I've still got to work out how to store/update/display a date sensor so a long way off :)

@magicus
Copy link

magicus commented Dec 8, 2023

It sounds like the upcoming IoT Battery DB needs a "unreliable" flag. So if it is a device with a known issue about reporting correct battery level, they can by default can have the automatic tracking disabled.

@andrew-codechimp andrew-codechimp self-assigned this Dec 10, 2023
@animalillo
Copy link
Contributor

animalillo commented Dec 14, 2023

This is complicated, i have a set of zigbee devices bought on the same batch from the same vendor, type and brand which one behaves weird and the others as you would expect, one reports 17% battery despite the battery being new and working perfectly (i have tried replacing it) and the others 100% with new batteries and slowly declining.

So i guess either adding a switch for the automatic change detection or making it fully manual would be required.

I also have some bluetooth devices that vary wildly the battery level, which is strange, the mi flora ones

@jimmhead
Copy link
Author

I've had the same experience as those above, some ZigBee devices will accurately report battery changes while others will fluctuate up and down, even for the same device model and manufacturer. One reason I started looking for a last battery changed add-on originally was to make a better judgement of whether the battery level shown is actually accurate and needs to be changed or just a false alarm.

@magicus
Copy link

magicus commented Dec 15, 2023

It's a bit sad if all the good devices can not have this functionality due to the bad ones. But if it is too common with bad devices, then this needs to be handled somehow. One idea I had was to use the "Notification" system in HA. If a battery is detected to have increased the charge from below e.g. 30% to above e.g. 90%, then a notification pops up saying "It seems like you have changed battery in device XXX? What do you want to do: [Mark battery as replaced] [Mark the battery level as unreliable on this device] [Ignore]"

@hilsonp
Copy link

hilsonp commented Dec 22, 2023

This is great ! I came here (after reading this thread https://community.home-assistant.io/t/is-there-a-way-to-add-a-last-battery-change-custom-attribute-to-all-devices-with-a-battery/637570) exactly for this.

I need a way to store the history of battery change. I don't care having to set the date or push a button as, as of now, hopefully, I do not change batteries daily ;-)

In my user experience, keeping an history of battery changes is a must. Knowing the battery type is a plus ;-)
So I would LOVE to see this implemented !

I second other feedback. Many of my zigbee sensors report crazy battery levels and some change up and down for no reason.

For the time being, I change the battery of a device when it stops working.
This is a pity... I know... This is bad for the WAF factor...

Thank you in advance !

@magicus
Copy link

magicus commented Dec 24, 2023

@hilsonp I really like the idea of having a history of battery changes. I guess the normal HA log is purged too frequently in this regard, since battery changes are (ideally) months or years apart, so a separate system is likely needed.

@hilsonp
Copy link

hilsonp commented Dec 24, 2023

Or maybe, instead of storing the date(s) of last change, the number of seconds (or minutes or hours or days) since last change could be stored in a sensor with a state_class set. This way, it is kept in the long terms statistics without anything to be done by the user.
The last change date can be easily computed from this elapsed time counter sensor.

https://developers.home-assistant.io/docs/core/entity/sensor/?_highlight=state_class#long-term-statistics

@andrew-codechimp
Copy link
Owner

I am actively working on this at the moment, I'm going with HA's custom storage components to store the value, it seems the most reliable for long term storage of a value. Battery Notes isn't like a typical sensor as there's no retrieving a value from an API or anything so examples to follow for doing this are thin on the ground but pretty sure I'm on the right track now after a few false starts.
Still finding my way with it though so no promises on when this will be available.

@andrew-codechimp andrew-codechimp linked a pull request Dec 26, 2023 that will close this issue
@andrew-codechimp
Copy link
Owner

A Beta version has now been released with the both Battery Last Replaced sensor, button & service plus the device picker when manually adding now only shows devices with batteries (can be changed, see FAQ).

If you wish to try this version please go into HACS, select Battery Notes and in the top right menu choose Redownload, switch on Show Beta Versions and select the latest version (starts with 1.3)

@we5
Copy link
Contributor

we5 commented Dec 26, 2023

Hey @andrew-codechimp, thanks for that integration. Finally a good way of keeping track of the usage of the batteries.

However I tried both the 1.2.0 and beta 1.3.0 and both do not work for me.

1.2.0 states an error after adding a new device.
1.3.0 is unable to start the config flow.

I tend to create a bug for this to keep track of this, unless you say that’s a known thing and I should not bother you with this :)

@andrew-codechimp
Copy link
Owner

andrew-codechimp commented Dec 26, 2023

Hi @we5 did you add battery_notes: to your configuration.yaml and restart?
Anything in HA logs for Battery Notes?

@we5
Copy link
Contributor

we5 commented Dec 26, 2023

I am so sorry @andrew-codechimp, I misread that and assumed this is only for manual installations as i normally never add any configuration manually to the configuration. Works flawlessly. I will now add some of the devices I own to your list. I mainly have Z-Wave devices and especially the TRVs are interesting to monitor more detailed.

@jimmhead
Copy link
Author

A Beta version has now been released with the both Battery Last Replaced sensor, button & service plus the device picker when manually adding now only shows devices with batteries (can be changed, see FAQ).

If you wish to try this version please go into HACS, select Battery Notes and in the top right menu choose Redownload, switch on Show Beta Versions and select the latest version (starts with 1.3)

I've installed the beta version 1.3.0 and it's working perfectly, thanks a lot for adding this.

@AnthonyBe
Copy link

I am so sorry @andrew-codechimp, I misread that and assumed this is only for manual installations as i normally never add any configuration manually to the configuration. Works flawlessly. I will now add some of the devices I own to your list. I mainly have Z-Wave devices and especially the TRVs are interesting to monitor more detailed.

I did exactly the same.
@andrew-codechimp - this isn't an obvious or expected step when performing a HACS installation. Can it be removed/automated, or the install steps made clearer? It does literally need to be in BOLD ALL CAPs to ensure it catches attention. :)

@andrew-codechimp
Copy link
Owner

I am so sorry @andrew-codechimp, I misread that and assumed this is only for manual installations as i normally never add any configuration manually to the configuration. Works flawlessly. I will now add some of the devices I own to your list. I mainly have Z-Wave devices and especially the TRVs are interesting to monitor more detailed.

I did exactly the same. @andrew-codechimp - this isn't an obvious or expected step when performing a HACS installation. Can it be removed/automated, or the install steps made clearer? It does literally need to be in BOLD ALL CAPs to ensure it catches attention. :)

This is required for initial discovery, I can't remove it or automate it but I'll make it more obvious and handle it better.

@ThomDietrich
Copy link
Contributor

ThomDietrich commented Dec 28, 2023

Hey guys! This is a great addition generally speaking... but I personally can't see the use case.
The addition however brings an unwanted issue with it. From now on I will have to remember to press the button or else will be troubled by an incorrect "battery last replaced 5 years ago" information.

It would be great if you considered adding a config option to disable this feature (I am fine with enabled by default).

@andrew-codechimp
Copy link
Owner

Hey guys! This is a great addition generally speaking... but I personally can't see the use case. The addition however brings an unwanted issue with it. From now on I will have to remember to press the button or else will be troubled by an incorrect "battery last replaced 5 years ago" information.

It would be great if you considered adding a config option to disable this feature (I am fine with enabled by default).

Pretty sure I can make a config option to hide the sensor/button, I've created a new issue to track that.
#167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants