diff --git a/soliscloud/soliscloud.py b/soliscloud/soliscloud.py
--- a/soliscloud/soliscloud.py
+++ b/soliscloud/soliscloud.py
#
@@ -177,6 +177,79 @@ class SolisCloud:
#
+ def fetchInverterList(self, station_id=False):
#
+ ''' Fetch the list of inverters.
#
+ TODO: may want to implement iterating through pages at some
#
+ # Construct the request body
#
+ req_body_d['stationId'] = station_id
#
+ req_body = json.dumps(req_body_d)
#
+ req_path = "/v1/api/inverterList"
#
+ # Construct an auth header
#
+ auth_header = self.doAuth(self.config['api_id'], self.config['api_secret'], req_path, req_body)
#
+ # Construct headers dict
#
+ "Authorization" : auth_header,
#
+ "Content-Type" : "application/json"
#
+ self.printDebug(f'Built request - Headers {headers}, body: {req_body}, path: {req_path}')
#
+ self.printDebug('Returning mocked response')
#
+ "stationStatusVo" : {
#
+ # Note: The API doc says this is a long
#
+ # but, the value returned to a similar call made by the cloud UI is a string
#
+ # 1:Online 2:Offline 3:Alarm
#
+ "dataTimeStamp" : 1234567891011,
#
+ "collectorSn" : "181920",
#
+ "series" : "Solis Acme Inverter",
#
+ r = self.postRequest(
#
+ f"{self.config['api_url']}{req_path}",
#
def fetchStationList(self):
#
@@ -215,32 +288,33 @@ class SolisCloud:
#
self.printDebug('Returning mocked response')
#
- # Note: The API doc says this is a long
#
- # but, the value returned to a similar call made by the cloud UI is a string
#
- "capacityStr": "kWp",
#
- "installerId" : 4567,
#
- "dataTimestamp" : "1683905510946",
#
- "dayEntergyStr" : "kWh",
#
- "batteryTotalDischargeEnergy" : 0,
#
- "batteryTotalChargeEnergy" : 0,
#
- "condTxtD": "Cloudy",
#
+ # Note: The API doc says this is a long
#
+ # but, the value returned to a similar call made by the cloud UI is a string
#
+ "capacityStr": "kWp",
#
+ "installerId" : 4567,
#
+ "dataTimestamp" : "1683905510946",
#
+ "dayEntergyStr" : "kWh",
#
+ "batteryTotalDischargeEnergy" : 0,
#
+ "batteryTotalChargeEnergy" : 0,
#
+ "condTxtD": "Cloudy",
#
@@ -328,3 +402,22 @@ if __name__ == "__main__":
#
stations = soliscloud.fetchStationList()
#
+ if not stations or "page" not in stations or "records" not in stations['page']:
#
+ # Now get a list of inverters
#
+ for station in stations["page"]["records"]:
#
+ # Get a list of inverters at the station
#
+ inverters = soliscloud.fetchInverterList(station_id=station['id'])
#
+ # The list detail doesn't tell us anything about batteries, so we need
#
+ # to iterate through and get details
#
+ if not inverters or "page" not in inverters or "records" not in inverters['page']:
#
+ # TODO: do we _really_ want to exit at this point, or should we return