Skip to content

Commit

Permalink
Fix for issue markruys#8
Browse files Browse the repository at this point in the history
It appears that GetPowerStationPowerAndIncomeByDay returns figures for multiple dates.
Hence this "fix" in order to ensure that the correct one is taken into account.
The code could probably be cleaner but knowing that it is not 100% sur how the GoodWe API works, it is robust as such.
  • Loading branch information
vijghph authored Jan 20, 2019
1 parent 1147253 commit d30c262
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gw2pvo/gw_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ def getDayReadings(self, date):
return result

eday_kwh = data[0]['p']

# added a loop to select correct day in case the GoodWe API unexpectedly returns figures for multiple dates
if len(data) > 1:
date_s_expected = date.strftime("%m/%d/%Y")
for idata in data:
if(idata['d'] == date_s_expected):
eday_kwh = idata['p']

payload = {
'id' : self.system_id,
Expand Down

0 comments on commit d30c262

Please sign in to comment.