I am a rookie in home assistant, and trying to figure out this:
Using “Battery State Card / Entity Row” card, it works perfectly, but one of the entities has battery level as voltage, not percentage, so it looks like this now:
That is 2,78 volt, the max is 3 volt.
How can I configure the card to show the battery percentage?
Thank you for your reply. I already found that thread, but wasn’t able to get anything out of it that works
Could you give me any parts of a template to start with? Sorry, I’m dumber than I thought…
My 3d printer has a sensor that reports the estimated finish time (sensor.mk3s_02_estimated_finish_time) but by default it displays a long UTC timestamp such as 2021-11-08T00:21:02.135422+00:00. I use a template sensor to make it more human-readable in the UI.
Before creating your custom sensor, you can test your templates within the Dev Tools Template Editor.
For example, I use the following template to display the printer’s finish time in 24-hour format instead of the long UTC timestamp:
The problem with batteries are the way the discharge.
They are made to keep their voltage up for a long time and then suddenly die, so you will see hardly no change between 90% full and 20% full and at 15% the voltage might be so low already that there is not enough power to drive the electronic, so the true 0% is actually when the battery have 15% capacity left.
A typical graph for a battery discharging would be like this:
I have a LIFEPO4 battery.
Charging min 23.9V max 28.8V
0% 23.9V
100% 27.2V
I used a sample template, but after exceeding the voltage of 27.2V, the value is 0%. Up to 27.2V works well.
Can you advise?
I took a bit of a different approach… Instead of the if/else statements, I created a filtered version of the voltage entity that enforces the upper and lower bounds and also smoothes the voltage out by averaging it over a time window. The new voltage is used for the percentage calculation which now cannot go above 100% or below 0%.
I’ve been having this problem too. I was using a giant if else structure but I knew it wasn’t inferring the real percentages correctly. After doing a lot of research, and I’ll confess, enquiring with chat GPT to help me figure out that maths, I’ve managed to create a template that takes the known data points for a battery (in my case a LiFePO₄ battery) and use a Linear Interpolation algorithm to infer the correct percentage from any point in the defined data. Obviously the more known points in the voltage, the better the accuracy, but I’m working with the chart provided from the manufacturer of my battery and putting my trust in the inferences made using this algorithm for any in-between points.
Please do feel free to copy this template, and if anyone is clever enough to turn this into an integration so we can quickly specify the curve and input entity faster in future, go for it!
Please note that I have very specifically designed this to show 0% minimum and 100% maximum. If your voltage drops above or below these values, don’t expect it to start showing negative values or values above 100%
I can’t begin to describe the pain of how much googling and discussion in support groups I have had with no one able to provide help with this problem, only to finally create a solution and you point to a built in integration that does it all for us. Eugh.