Skip to content

Commit

Permalink
catch exception in component_state.py
Browse files Browse the repository at this point in the history
  • Loading branch information
benderl committed Dec 21, 2023
1 parent e024ad5 commit c93da91
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 c93da91

Please sign in to comment.