atbore-phx / sbam

Smart Battery Advanced Manager
MIT License
10 stars 2 forks source link

Charge logic question #26

Open andreapalisca opened 7 hours ago

andreapalisca commented 7 hours ago

Hi @atbore-phx,

I've been using SBAM for a few weeks and really appreciate your work - thank you.

I have a question on the charge logic. Due to bad weather, the forecast for today was very low solar production. Even so, SBAM decided not to fully charge my 16 kWh battery in the nighttime hours and only went from 8% to 27% charge. Why is that? I would expect SBAM to charge almost to 100% in order to get through the next day. Here is the log, a graph of my charge state, and settings:

{"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Forecast Solar Power for 3/10/2024: 932 W"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Battery Capacity to charge: 13801 W"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Battery Capacity Max: 16588 W"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"your Daily consumption is:18000 W"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Net Forecast Power is not enough: -17067.300000 W"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Battery Capacity is not enough: 2786.784000 W"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Setting Fronius Storage Force Charge at 15%"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Reading register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Reading register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Reading register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Reading register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Reading register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Writing register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Writing register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Writing register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Writing register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Writing register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Setting Fronius Storage Force Charge done."}

Screenshot 2024-10-03 at 10 14 47 Screenshot 2024-10-03 at 10 18 05

Thank you!

andreapalisca commented 5 hours ago

I think I understood my issue: It is not charging more than 15% because I set max_charge=2500. I understood the description of this setting to mean "maximum draw in W from the grid" (i.e. do not draw more than 2500 W from the grid to charge the battery) instead you mean "maximum amount of battery to charge using grid power" (i.e. do not charge the battery more than x Wh using grid power).

I inferred the above from this code:

func SetChargePower(max float64, load float64, limit float64) int16 {
    return int16(min(load*100/max, limit*100/max))
}

I think I can fix this by setting max_power = 16588. I will try tonight...

atbore-phx commented 5 hours ago

Hi @andreapalisca, max_charge is the max amount of energy you draw from the grid during the charge event so for eg. If you set it to 2500W and sbam decides to charge the battery (when Net Forecast Power is a negative amount of power) the battery will be charged at 2.5KWh so in 1 hour sbam will refill your battery with an additional 15% (2500Wh are ~15% of 16KWh).

Sbam makes this calculation every hour in your crontab till 6am

It could be interesting see what's happened after midnight and till 6am In theory sbam should continue to charge.

The maximum limit for max_charge is the max amount of power you have subscribed with your electricity provider. I suggest not setting it to the max but just leave some KW for your home consumption to avoid a grid disconnection or penalty if you go over the provider threshold.

Another factor to consider is the battery charging is limited by fronius like a fraction of the inverter power and it depends also from the number of elements you have.

In my configuration I have a 6kw electricity contract, my fronius is 6kw and my battery is 11kw, I set max_charge at 3500w with a crontab similar to your.

Enjoy sbam!!! And thanks a lot for sharing your experience !!!

andreapalisca commented 3 hours ago

Hi @atbore-phx, if that is the case, to charge 15% of 16588 Wh in one hour, it should have charged at 2488 W, instead it was charging only at 470 W:

Screenshot 2024-10-03 at 13 39 19

In fact, over the whole window, it went only from 8 to 27%, so 19% in seven hours.

atbore-phx commented 3 hours ago

In fact, over the whole window, it went only from 8 to 27%, so 19% in seven hours.

Yes I agree, it's not the normal behavior. Send me please the full crontab logs every hour from midnight to 6am.

andreapalisca commented 3 hours ago

This is all I have from last night (rest got deleted):

{"level":"info","ts":"2024-10-03T03:00:01+02:00","msg":"Setting Fronius Storage Force Charge done."} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Forecast Solar Power for 3/10/2024: 932 W"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Battery Capacity to charge: 13353 W"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Battery Capacity Max: 16588 W"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"your Daily consumption is:18000 W"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Net Forecast Power is not enough: -17067.300000 W"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Battery Capacity is not enough: 3234.660000 W"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Setting Fronius Storage Force Charge at 15%"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Reading register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Reading register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Reading register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Reading register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Reading register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Writing register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Writing register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Writing register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Writing register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Writing register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T04:00:03+02:00","msg":"Setting Fronius Storage Force Charge done."} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Forecast Solar Power for 3/10/2024: 932 W"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Battery Capacity to charge: 12905 W"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Battery Capacity Max: 16588 W"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"your Daily consumption is:18000 W"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Net Forecast Power is not enough: -17067.850000 W"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Battery Capacity is not enough: 3682.536000 W"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Setting Fronius Storage Force Charge at 15%"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Reading register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Reading register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Reading register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Reading register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Reading register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Writing register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Writing register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Writing register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Writing register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Writing register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T05:00:02+02:00","msg":"Setting Fronius Storage Force Charge done."} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Forecast Solar Power for 3/10/2024: 883 W"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Battery Capacity to charge: 12474 W"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Battery Capacity Max: 16588 W"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"your Daily consumption is:18000 W"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Net Forecast Power is not enough: -17116.900000 W"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Battery Capacity is not enough: 4113.824000 W"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Setting Fronius Storage Force Charge at 15%"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Reading register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Reading register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Reading register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Reading register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Reading register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Writing register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Writing register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Writing register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Writing register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Writing register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T06:00:03+02:00","msg":"Setting Fronius Storage Force Charge done."} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Setting Fronius Storage Defaults start..."} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Reading register: 40349 ; value: 2"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Reading register: 40356 ; value: 64036"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Reading register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Reading register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Reading register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Writing register: 40349 ; value: 0"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Writing register: 40356 ; value: 10000"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Writing register: 40357 ; value: 10000"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Writing register: 40351 ; value: 0"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Writing register: 40361 ; value: 1"} {"level":"info","ts":"2024-10-03T06:55:00+02:00","msg":"Setting Fronius Modbus Defaults done."}

I can send full log tomorrow....

Thank you!