Skip to content

Commit

Permalink
Improve Fronius exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ngardiner committed Oct 12, 2019
1 parent fbf7f43 commit c33b235
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lib/TWCManager/EMS/Fronius.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,25 @@ def update(self):

inverterData = self.getInverterData()
if (inverterData):
self.generatedW = inverterData['Body']['Data']['PAC']['Value']
self.voltage = inverterData['Body']['Data']['UAC']['Value']
try:
self.generatedW = inverterData['Body']['Data']['PAC']['Value']
except (KeyError, TypeError) as e:
self.debugLog(4, "Exception during parsing Inveter Data (PAC)")
self.debugLog(10, e)

try:
self.voltage = inverterData['Body']['Data']['UAC']['Value']
except (KeyError, TypeError) as e:
self.debugLog(4, "Exception during parsing Inveter Data (UAC)")
self.debugLog(10, e)

meterData = self.getMeterData()
if (meterData):
self.consumedW = float(meterData['Body']['Data']['PowerReal_P_Sum'])
try:
self.consumedW = float(meterData['Body']['Data']['PowerReal_P_Sum'])
except (KeyError, TypeError) as e:
self.debugLog(4, "Exception during parsing Meter Data (Consumption)")
self.debugLog(10, e)

# Update last fetch time
if (self.fetchFailed is not True):
Expand Down

0 comments on commit c33b235

Please sign in to comment.