Skip to content

Commit c3eb2d3

Browse files
committed
sonnenbatterie: fix SacX None values
1 parent 7f5f63b commit c3eb2d3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • packages/modules/devices/sonnen/sonnenbatterie

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,12 @@ def update_battery(self, sim_counter: SimCounter) -> BatState:
341341
# this is not correct, but we have no other way to get the currents
342342
# the current is calculated as apparent power / voltage
343343
battery_ac_voltage = battery_state["Uac"]
344-
currents = [battery_state[f"Sac{phase}"] / battery_ac_voltage for phase in range(1, 4)]
344+
currents = [float(battery_state[f"Sac{phase}"]) / battery_ac_voltage
345+
if battery_state[f"Sac{phase}"] else None
346+
for phase in range(1, 4)]
345347
imported, exported = sim_counter.sim_count(battery_power)
346348
return BatState(power=battery_power,
347-
currents=currents,
349+
currents=currents if None not in currents else None,
348350
soc=battery_soc,
349351
imported=imported,
350352
exported=exported)

0 commit comments

Comments
 (0)