davidrapan / ha-solarman

โšก Solarman Stick Logger integration for ๐Ÿ  Home Assistant
MIT License
110 stars 25 forks source link

Total Battery Life Cycles and Battery SOH show low/high values #81

Closed PV-Joe closed 3 months ago

PV-Joe commented 3 months ago

Hi David,

The sensor โ€žTotal Battery Life Cyclesโ€œ and Battery SOH shows low/high values in my opinion.

IMG_5688

My battery: 1x Pytes E-Box 5,12 KW (running since two years)

Config Solarman: IMG_5689

Did I misconfigure or is it a bug?

davidrapan commented 3 months ago

What is your "Corrected Capacity" from Battery attributes?

Edit: And also set "Battery Capacity" in configuration for the reccord..

PV-Joe commented 3 months ago

Sorry, I might be dumb but really donโ€™t know what to do.

I did not correct anything and donโ€™t know where I have to.

Battery Capacity is: IMG_5690

davidrapan commented 3 months ago

So Battery Capacity is set ~ correctly (according info you provided).

And the Corrected Capacity can be seen here: detail_battery_attributes_capacity

PV-Joe commented 3 months ago

Here is mine:

IMG_5697

Did I miss something?

davidrapan commented 3 months ago

So yeah your inverter thinks you have 10 kWh battery. You can correct that by switching your inverter battery control to: "Use Batt %" and let it run in that mode until your Corrected Capacity value does not correct itself to ~ your set Battery Capacity. But it's kinda important you also have correctly set other values about your batt for inverter to work properly in that mode.

8EECB8B0-998B-4802-98E4-EFEB1776EF4E

And after you switch it then the values should be cca like this: 68040DC2-0602-4373-B50A-D09A53662C70

I have Float lowered cause otherwise my Battery is somewhat messed up and shows OVP when there is anything higher than 52.2 V.

I have Automation setup which is switching my inverter automatically into this mode when is Battery fully charged cause my Battery keeps cycling charging and discharging when left in Lithium mode and is fully charged cause one of the packs is returning OVP. And then when the charged SOC drops under 98% Automation does switch back to Lithium mode. As I said there is something wrong with the BMS controller in my battery.

PV-Joe commented 3 months ago

Thanks for explaining!

My solar technician chose the battery settings and I never changed anything. As I donโ€™t really know what exactly Iโ€™m doing by changing values Iโ€™d rather leave it like he set it up.

My battery cycles when it is full from 99% to 100% and back to 99% and so on if you mean that.

I there another way of getting the sensor going?

davidrapan commented 3 months ago

My solar technician chose the battery settings and I never changed anything.

If that's the case I don't understand why is your Battery Corrected Capacity not showing +- the same value as it's setup in Battery Capacity. Battery Corrected Capacity is just value which is set by the device itself according setup value in the setting and Battery balancing which should be done during the installation.

My battery cycles when it is full from 99% to 100% and back to 99% and so on if you mean that.

Really? It shouldn't do that. If there is enough PV and battery is not needed it should stay idle.

What is your Battery BMS Alarm doing during that cycling?

Does this "cycling" also affects Grid Import/Export? Meaning do you see that it cycling means charging/discharging from/to grid?

PV-Joe commented 3 months ago

No, no charging or discharging from grid at all. Experts told me, that it is normal for Lithium batteries and is because of cell balancing.

So is there a way to get the sensors running by modifying something in the integration or Home Assistant itself?

If yes, how exactly should I do it?

davidrapan commented 3 months ago

No, no charging or discharging from grid at all. Experts told me, that it is normal for Lithium batteries and is because of cell balancing.

Oh yeah that in fact is normal but not really every time or all the time. It should stop after is the balancing somehow done.

I still do wonder what is your Battery BMS Alarm showing when is your battery full? Does it stays Inactive the whole time?

But anyway mine do that cycling of charging/discharging from/to grid when full so that's why I have setup that "hack".

So is there a way to get the sensors running by modifying something in the integration or Home Assistant itself?

I'll see what I can do about it. ๐Ÿ˜‰

PV-Joe commented 3 months ago

Battery BMS Alarm says โ€œinactiveโ€ since switching to your integration.

Maybe you could make the installed battery capacity configurable in the setup menue?

Otherwhise I could help myself with template sensor for Battery SOH.

Just asked ChatGPT and this is the result:

sensor:
  - platform: template
    sensors:
      battery_soh:
        friendly_name: "Battery SOH"
        unit_of_measurement: "%"
        value_template: >
          {% set battery_capacity = 5.12 %}
          {% set life_cycle = 6000 %}
          {% set total_capacity_kwh = battery_capacity * life_cycle %}
          {% set consumed_kwh = states('sensor.solarman_total_battery_charge') | float(0) %}
          {% set soh_percentage = (consumed_kwh / total_capacity_kwh) * 100 %}
          {% set result_soh = 100 - soh_percentage %}
          {{ result_soh | round(2) }}
davidrapan commented 3 months ago

Maybe you could make the installed battery capacity configurable in the setup menue?

I really want this to be tied to a data from the inverter. As there are two values, one set by configuring of the inverter and the other which inverter provides using one of the registers.

Maybe I could somehow detect when the provided values is way off and used the set one instead.

Just asked ChatGPT and this is the result:

Haha! That's funny! And still so scary though! ๐Ÿ˜† He will take all the jobs from us one day. ๐Ÿ˜‰

davidrapan commented 3 months ago

fix: Battery SOH when wrong corrected capacity

davidrapan commented 3 months ago

So how is it in new version?

PV-Joe commented 3 months ago

This is the result for my 5,12 kWh battery with 6000 lifecycles:

grafik

grafik grafik

Can you validate?

davidrapan commented 3 months ago

I forgot to also do the changes for cycles: fix: Battery cycles when wrong corrected capacity

What about SOH? That should be correct for some time already.

PV-Joe commented 3 months ago

Here it is:

image

Do I just have to overwrite the *.py and it will be permanently fixed with the next update?

davidrapan commented 3 months ago

Do I just have to overwrite the *.py and it will be permanently fixed with the next update?

Yes. If you replace the content of sensor.py with this: https://github.com/davidrapan/ha-solarman/blob/main/custom_components/solarman/sensor.py

You have to restart HA after that, though.

PV-Joe commented 3 months ago

Will do it today and send my feedback here.

Thank you for your continuous and extra fast support!

PV-Joe commented 3 months ago

Here ist the value after replacing the sensor.py:

image

Are the values constistent in your opinion? If yes, we can close as completed :-)

davidrapan commented 3 months ago

Yes it should double as it did after the changes. So seems now okay to me. ๐Ÿ˜‰

PV-Joe commented 3 months ago

Yes it should double as it did after the changes. So seems now okay to me. ๐Ÿ˜‰

But the Battery SOH in % doesn't fit to the Lifecycles?

image image

It should be 93,8%

davidrapan commented 3 months ago

6000 cycles and you are at 80% so I don't think so, hehe.

PV-Joe commented 3 months ago

Ahh you are setting 80% as the limit. ๐Ÿ˜‚ That confused me.

I think we should add and explain that in the description to make it clear. Maybe together with the formula that is used.

It should be clear for non-experts I think and will reduce silly questions like mine ๐Ÿ˜‚

davidrapan commented 3 months ago

There is no limit... And that is a literal description of a life cycles of the battery. 80% at 6000 cycles as the worst case scenario.

It will go past the 80%, but in the linear fashion which does not really describe the real world physics.

It's still a guess nevertheless.

PV-Joe commented 3 months ago

There is no limit... And that is a literal description of a life cycles of the battery. 80% at 6000 cycles as the worst case scenario.

Yes I know "limit" was the wrong word. I know these buddies can live longer.

Thinking about adding another Pytes 5.12 kWh after 2 years just because of greedyness.

This will make the calculation useless, right?

davidrapan commented 3 months ago

How did you calculate your number anyway? 93% after just almost 400 cycles would be really bad battery, though.

This will make the calculation useless, right?

Not necessarily. Just less precise. It is tied to the inverter anyway so replacing the battery would be the act which could render this calculation as useless. You have to keep in mind that it's just for a "having idea" about the state of the battery. Nothing you should be willing to put your hand in the fire for, though. ๐Ÿ˜†

I added this feature cause I'm charging the battery during T2 (cheaper electricity), means I'm using the battery a lot, so I wanted to know how fast is my battery proly degrading cause of that. So you should be treating the values from POV as it changes with time (delta in other words) rather than current value. You know what I mean? ๐Ÿ˜‰

PV-Joe commented 3 months ago

How did you calculate your number anyway? 93% after just almost 400 cycles would be really bad battery, though.

I thought:

6000 cycles = 100% 372 cycles = 93,8%

... but that was rubbish as I learned ๐Ÿ˜‚

This will make the calculation useless, right?

Not necessarily. Just less precise. It is tied to the inverter anyway so replacing the battery would be the act which could render this calculation as useless. You have to keep in mind that it's just for a "having idea" about the state of the battery. Nothing you should be willing to put your hand in the fire for, though. ๐Ÿ˜†

I would add not replace.

I added this feature cause I'm charging the battery during T2 (cheaper electricity), means I'm using the battery a lot, so I wanted to know how fast is my battery proly degrading cause of that. So you should be treating the values from POV as it changes with time (delta in other words) rather than current value. You know what I mean? ๐Ÿ˜‰

Yeah, I like monitoring it as well. I'm mostly autark but as you have seen I don't need much energy. I'm more an enthusiast and like the technology.

davidrapan commented 2 months ago

I would add not replace.

I wasn't talking about your case but giving an example of what would render the values useless.

Yeah, I like monitoring it as well. I'm mostly autark but as you have seen I don't need much energy. I'm more an enthusiast and like the technology.

Maybe there could be a way of solving it by adding some kind of a offset which you would change with your battery addition. Let me know when you'll do that and we can try something. ๐Ÿ˜‰

PV-Joe commented 2 months ago

Great news. Thank you. I will see when my technician has time for it. The Battery firmwares need to be updated to match each other and he probably wants to update the Deye Hybrid as well. Don't know if I want a Deye Update as some of them are reported as not very good.