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

Add support for devices that don't report battery levels in percentages #2202

Closed
3 tasks done
almirus opened this issue Oct 7, 2024 · 9 comments
Closed
3 tasks done
Assignees

Comments

@almirus
Copy link

almirus commented Oct 7, 2024

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.

Currently, you can't add devices that don't provide a percentage-based battery level, like a smoke detector. It only reports battery status as: low, medium, or high.

Describe the solution you'd like

I want support for devices without percentage-based battery levels to be added. It could be possible to emulate the battery level with dummy percentages: low = 10%, medium = 50%, high = 100%.

Describe alternatives you've considered

Additional context

image

@zoechi
Copy link

zoechi commented Oct 8, 2024

I was just trying to accomplish something like that. I added an entity (door sensor of my Nuki smart lock) with a "battery low template", but it doesn't show up in states (Developer tools).

I have configured the battery state card with

filter:
  include:
    - name: entity_id
      value: '*_battery_plus'

To get the new battery shown I can add

    - name: entity_id
      value: '*_battery_critical'

But it gets shown with state On which isn't too helpful and a question mark as icon and also there is no secondary info about the the battery type shown like with the other batteries.

I thought I might be lacking some knownledge, but then I found this issue. So, it looks like I'm not the only one struggling with this.

@andrew-codechimp
Copy link
Owner

You can't add a battery state like this as a battery plus, but you can add a template for the boolean battery low to reflect a low battery and trigger events. I'm not sure if I'll ever add this into battery plus as there are a lot of permutations for these unusual devices.
https://andrew-codechimp.github.io/HA-Battery-Notes/#battery-low-template

@zoechi
Copy link

zoechi commented Oct 8, 2024

I had the template a bit wrong but fixing it didn't change anything.

Also using '*_battery_plus_low' for the filter doesn't help.

So there is no way to get the battery type shown as secondary info for such batteries?

@andrew-codechimp
Copy link
Owner

Unfortunately not, the template only affects the binary sensor, not the battery plus one, so it's no use in dashboards the way you are wanting to use it.
If I can ever think of a nice way of handling this I will, but it's got to be flexible and easy to configure/understand for me to add it.

@zoechi
Copy link

zoechi commented Oct 8, 2024

I understand.
Thanks a lot anyway for this cool integration 🚀

@almirus
Copy link
Author

almirus commented Oct 8, 2024

I'm not sure if I'll ever add this into battery plus as there are a lot of permutations for these unusual devices.

The algorithm could be as follows:

  1. Allow adding all devices (at your own risk): The integration will serve as a source of information about the type of batteries used and when they were last replaced.

  2. Add all devices containing the attribute .*battery.* and analyze: If it's a number, process it as a percentage. If it's a string, process it as low, medium, or high.

  3. Add devices with a user-defined template for extracting battery percentage: Users can specify a custom template to extract the battery level from devices that don't provide standard percentages.

@andrew-codechimp
Copy link
Owner

Thanks for your suggestion but there are also batteries with voltages, ones with Normal or Low and also ones that just display a binary low natively, that we'd also want to have as a sudo percentage.
I'm not forgetting about this, but as stated there are a lot of things to consider and also make it easy to use.

@andrew-codechimp
Copy link
Owner

So I've been experimenting with ideas around this and it turns out without any code changes you can create a Template Helper and have Battery Notes pick it up and create a Battery+ sensor.

I've documented how to do this here, feedback appreciated if you have issues.

https://andrew-codechimp.github.io/HA-Battery-Notes/entities/#adding-a-battery-percentage

@almirus
Copy link
Author

almirus commented Nov 26, 2024

@andrew-codechimp success! thank you!
image

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

No branches or pull requests

3 participants