Skip to content

Commit

Permalink
Pass is dataList key is missing (#28) (#38)
Browse files Browse the repository at this point in the history
In some occasions, the `dataList` keys is missing from the API data.
  • Loading branch information
mpepping authored Oct 9, 2022
1 parent 844b2e2 commit d1a16a5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion solarman/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ def construct_data(self):
Return restructured and separated device current data
"""
new_data_list = {}
if self.data["dataList"]:
try:
for i in self.data["dataList"]:
del i["key"]
name = i["name"]
name = name.replace(" ", "_")
del i["name"]
new_data_list[name] = i["value"]
del self.data["dataList"]
except KeyError:
pass
return new_data_list

0 comments on commit d1a16a5

Please sign in to comment.