Skip to content

Commit

Permalink
Merge pull request openWB#1307 from benderl/fix-sungrow-divisionByZero
Browse files Browse the repository at this point in the history
catch exception in component_state.py
  • Loading branch information
benderl authored Dec 22, 2023
2 parents 1eb25a6 + c93da91 commit 2d75c65
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/modules/common/component_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ def _calculate_powers_and_currents(currents: Optional[List[float]],
else:
powers = [currents[i]*voltages[i] for i in range(0, 3)]
if currents is None and powers:
currents = [powers[i]/voltages[i] for i in range(0, 3)]
try:
currents = [powers[i]/voltages[i] for i in range(0, 3)]
except ZeroDivisionError:
# some inverters (Sungrow) report 0V if in standby
currents = [0.0]*3
if currents and powers:
currents = [currents[i]*-1 if powers[i] < 0 and currents[i] > 0 else currents[i] for i in range(0, 3)]
return currents, powers, voltages
Expand Down

0 comments on commit 2d75c65

Please sign in to comment.