From 07ab6bdfb3a01c041afa01f9b2f884a1a5fb8ecc Mon Sep 17 00:00:00 2001 From: Nick Clayton Date: Sat, 20 Feb 2021 13:12:41 +0000 Subject: [PATCH 1/2] Added inventory and inverter detail queries --- README.md | 18 ++++++++++++++---- solaredge/solaredge.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 19e94d6..22349c1 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,18 @@ # Solaredge + API wrapper for Solaredge monitoring service. -See https://www.solaredge.com/sites/default/files/se_monitoring_api.pdf +See ## Create a new connection by supplying your Solaredge API key + ``` s = solaredge.Solaredge("APIKEY") ``` ## API Requests -11 API requests are supported. The methods return the parsed JSON response as a dict. + +14 API requests are supported. The methods return the parsed JSON response as a dict. ``` def get_list(self, size=100, startIndex=0, searchText="", sortProperty="", sortOrder='ASC', status='Active,Pending'): @@ -33,8 +36,15 @@ def get_energyDetails(self, site_id, startTime, endTime, meters=None, timeUnit=" def get_currentPowerFlow(self, site_id): def get_storageData(self, site_id, startTime, endTime, serials=None): + +get_componentList(self, site_id): + +get_inventory(self, site_id): + +def get_invertorDetails(self, site_id, invertor_id, startTime, endTime): ``` ## TODO -* Add support for bulk requests -* Add API documentation + +- Add support for bulk requests +- Add API documentation diff --git a/solaredge/solaredge.py b/solaredge/solaredge.py index bb0ee1c..a9463d3 100644 --- a/solaredge/solaredge.py +++ b/solaredge/solaredge.py @@ -201,6 +201,38 @@ def get_storageData(self, site_id, startTime, endTime, serials=None): r.raise_for_status() return r.json() + def get_componentList(self, site_id): + url = urljoin(BASEURL, "equipment", site_id, "list") + params = { + 'api_key': self.token + } + + r = requests.get(url, params) + r.raise_for_status() + return r.json() + + def get_inventory(self, site_id): + url = urljoin(BASEURL, "site", site_id, "inventory") + params = { + 'api_key': self.token + } + + r = requests.get(url, params) + r.raise_for_status() + return r.json() + + def get_inverterDetails(self, site_id, invertor_id, startTime, endTime): + url = urljoin(BASEURL, "equipment", site_id, invertor_id, "data") + params = { + 'api_key': self.token, + 'startTime': startTime, + 'endTime': endTime, + } + + r = requests.get(url, params) + r.raise_for_status() + return r.json() + def urljoin(*parts): """ From 7837eac576530e783eceafbde171dce925d6095a Mon Sep 17 00:00:00 2001 From: Nick Clayton Date: Sat, 20 Feb 2021 13:31:07 +0000 Subject: [PATCH 2/2] formatting --- solaredge/solaredge.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/solaredge/solaredge.py b/solaredge/solaredge.py index a9463d3..2f0f1fd 100644 --- a/solaredge/solaredge.py +++ b/solaredge/solaredge.py @@ -204,7 +204,7 @@ def get_storageData(self, site_id, startTime, endTime, serials=None): def get_componentList(self, site_id): url = urljoin(BASEURL, "equipment", site_id, "list") params = { - 'api_key': self.token + 'api_key': self.token } r = requests.get(url, params) @@ -221,8 +221,8 @@ def get_inventory(self, site_id): r.raise_for_status() return r.json() - def get_inverterDetails(self, site_id, invertor_id, startTime, endTime): - url = urljoin(BASEURL, "equipment", site_id, invertor_id, "data") + def get_inverterDetails(self, site_id, inverter_id, startTime, endTime): + url = urljoin(BASEURL, "equipment", site_id, inverter_id, "data") params = { 'api_key': self.token, 'startTime': startTime,