diff --git a/soliscloud/soliscloud.py b/soliscloud/soliscloud.py
--- a/soliscloud/soliscloud.py
+++ b/soliscloud/soliscloud.py
#
@@ -211,6 +211,10 @@ class SolisCloud:
#
self.printDebug(f'Fetched inverter {resp}')
#
+ if not resp or "success" not in resp or not resp['success']:
#
@@ -247,6 +251,10 @@ class SolisCloud:
#
self.printDebug(f'Fetched inverter list: {resp}')
#
+ if not resp or "success" not in resp or not resp['success']:
#
@@ -286,6 +294,9 @@ class SolisCloud:
#
self.printDebug(f'Got station list: {resp}')
#
+ if not resp or "success" not in resp or not resp['success']:
#
@@ -511,11 +522,10 @@ if __name__ == "__main__":
#
stations = soliscloud.fetchStationList()
#
- # TODO: lets not do this:
#
- if not stations or "data" not in stations or "page" not in stations['data'] or "records" not in stations['data']['page']:
#
+ # Check we got a successful response
#
# Line protocol will be written into here as it's generated
#
@@ -527,14 +537,20 @@ if __name__ == "__main__":
#
# The list detail doesn't tell us anything about batteries, so we need
#
# to iterate through and get details
#
- if not inverters or "data" not in inverters or "page" not in inverters['data'] or "records" not in inverters['data']['page']:
#
# TODO: do we _really_ want to exit at this point, or should we return
#
for inverter in inverters['data']['page']['records']:
#
- inverter_details = soliscloud.fetchInverterDetail(inverter['id'])['data']
#
+ inv = soliscloud.fetchInverterDetail(inverter['id'])
#
+ inverter_details = inv['data']
#
lp = extractBatteryStats(inverter_details, config)
#
inverter_lp = extractInverterStats(inverter_details, station, config)