SBMS0 has just two shunts one measures battery current and the other PV current.
SBMS60 had 3 build in shunts measuring PV1, PV2 and battery current and an external shunt measuring an external Load (that was unidirectional so can only measure a load).
Yes Load as calculated internally by the SBMS0 is done as the difference between the battery current and PV current. This only works correctly if your only charge source is PV solar.
Code seems correct
# need to determine if current is going into or out of the battery
if PV_current <= 0:
Load_current = abs(Battery_current)
elif PV_current > 0: (else should be sufficient here)
if Battery_current <= 0:
Load_current = PV_current + abs(Battery_current)
elif Battery_current > 0:
Load_current = PV_current - abs(Battery_current) (you already know that Battery_current is positive no need for abs function).
Gemini has suggested this simpler two lines of code
Load_current = PV_current - Battery_current
Load_current = max(0, Load_current)
I do not write in python but I think this is correct.
Case 1
PV_current = 40A
Battery_current = +30A
Load_current = 40 - 30 = 10A (correct)
Case 2
PV_current = 40A
Battery_current = -30A
Load_current = 40 - (-30) = +70A (correct)
Case 3
PV_current = 40A
Battery_current = +50A
Load_current = 40 - 50 = -10A I think this Load_current = max(0, Load_current) will not allow negative value so result will be 0A and is so then it is (correct)