Skip to content

Commit 3db5556

Browse files
committed
calculate battery currents
1 parent 769300a commit 3db5556

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

  • packages/modules/devices/sonnen/sonnenbatterie

packages/modules/devices/sonnen/sonnenbatterie/api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,15 @@ def update_battery(self, sim_counter: SimCounter) -> BatState:
336336
battery_state = self.__read_status()
337337
battery_power = -battery_state["Pac_total_W"]
338338
battery_soc = battery_state["USOC"]
339+
# try to calculate the individual line currents as no data is provided by the API
340+
# we assume that the voltage is the same for all three phases
341+
# this is not correct, but we have no other way to get the currents
342+
# the current is calculated as apparent power / voltage
343+
battery_ac_voltage = battery_state["Uac"]
344+
currents = [battery_state[f"Sac{phase}"] / battery_ac_voltage for phase in range(1, 4)]
339345
imported, exported = sim_counter.sim_count(battery_power)
340346
return BatState(power=battery_power,
347+
currents=currents,
341348
soc=battery_soc,
342349
imported=imported,
343350
exported=exported)

0 commit comments

Comments
 (0)