From 15720657087026092d609b13bb59a8b9527bfa68 Mon Sep 17 00:00:00 2001 From: alissonzima Date: Wed, 10 May 2023 16:29:42 -0300 Subject: [PATCH 1/6] =?UTF-8?q?Altera=C3=A7=C3=A3o=20da=20URL=20do=20serve?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- growattServer/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/growattServer/__init__.py b/growattServer/__init__.py index 5983644..4bdcd9a 100755 --- a/growattServer/__init__.py +++ b/growattServer/__init__.py @@ -24,7 +24,7 @@ class Timespan(IntEnum): month = 2 class GrowattApi: - server_url = 'https://server-api.growatt.com/' + server_url = 'https://server.growatt.com/' agent_identifier = "Dalvik/2.1.0 (Linux; U; Android 12; https://github.com/indykoning/PyPi_GrowattServer)" def __init__(self, add_random_user_id=False, agent_identifier=None): From e30ebffc58ebb799b1bb59eafe88d79bbe56c302 Mon Sep 17 00:00:00 2001 From: alissonzima Date: Wed, 24 May 2023 16:45:58 -0300 Subject: [PATCH 2/6] Changed plant_detail endpoint to newPlantDetailAPI.do --- growattServer/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/growattServer/__init__.py b/growattServer/__init__.py index 4bdcd9a..679a686 100755 --- a/growattServer/__init__.py +++ b/growattServer/__init__.py @@ -157,7 +157,7 @@ def plant_detail(self, plant_id, timespan, date=None): """ date_str = self.__get_date_string(timespan, date) - response = self.session.get(self.get_url('PlantDetailAPI.do'), params={ + response = self.session.get(self.get_url('newPlantDetailAPI.do'), params={ 'plantId': plant_id, 'type': timespan.value, 'date': date_str From de0f8e9c01735e5ca0676c32871fba3a153a36cc Mon Sep 17 00:00:00 2001 From: alissonzima Date: Wed, 24 May 2023 16:51:28 -0300 Subject: [PATCH 3/6] Added dataType param to PlantDetail --- growattServer/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/growattServer/__init__.py b/growattServer/__init__.py index 679a686..4af2425 100755 --- a/growattServer/__init__.py +++ b/growattServer/__init__.py @@ -160,7 +160,8 @@ def plant_detail(self, plant_id, timespan, date=None): response = self.session.get(self.get_url('newPlantDetailAPI.do'), params={ 'plantId': plant_id, 'type': timespan.value, - 'date': date_str + 'date': date_str, + 'dataType' : 0 }) data = json.loads(response.content.decode('utf-8')) return data['back'] From 0d2e51120da765b714ce6b8ded16f1b47630e955 Mon Sep 17 00:00:00 2001 From: alissonzima Date: Wed, 24 May 2023 17:02:59 -0300 Subject: [PATCH 4/6] Removed dataType param to PlantDetail for test --- growattServer/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/growattServer/__init__.py b/growattServer/__init__.py index 4af2425..679a686 100755 --- a/growattServer/__init__.py +++ b/growattServer/__init__.py @@ -160,8 +160,7 @@ def plant_detail(self, plant_id, timespan, date=None): response = self.session.get(self.get_url('newPlantDetailAPI.do'), params={ 'plantId': plant_id, 'type': timespan.value, - 'date': date_str, - 'dataType' : 0 + 'date': date_str }) data = json.loads(response.content.decode('utf-8')) return data['back'] From 55c4e6f445d99cdab00528897c6c5ae7ce5484bc Mon Sep 17 00:00:00 2001 From: alissonzima Date: Wed, 24 May 2023 17:12:56 -0300 Subject: [PATCH 5/6] Added more timespan choices, retrieving now data from year and all data. --- growattServer/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/growattServer/__init__.py b/growattServer/__init__.py index 679a686..c09dd7a 100755 --- a/growattServer/__init__.py +++ b/growattServer/__init__.py @@ -22,6 +22,8 @@ class Timespan(IntEnum): hour = 0 day = 1 month = 2 + year = 3 + all = 4 class GrowattApi: server_url = 'https://server.growatt.com/' @@ -54,8 +56,10 @@ def __get_date_string(self, timespan=None, date=None): date_str="" if timespan == Timespan.month: date_str = date.strftime('%Y-%m') - else: + elif timespan == Timespan.day or timespan == Timespan.hour: date_str = date.strftime('%Y-%m-%d') + else: + date_str = date.strftime('%Y') return date_str From e7b10fb42e6d527e6170ecd40f8c937a5bf6a0b3 Mon Sep 17 00:00:00 2001 From: alissonzima Date: Wed, 24 May 2023 17:28:52 -0300 Subject: [PATCH 6/6] Update to list 4 more timespan choices in plant_detail --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6886ae7..cf2afbc 100755 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Any methods that may be useful. `api.plant_info(plant_id)` Get info for specified plant. -`api.plant_detail(plant_id, timespan<1=day, 2=month>, date)` Get details of a specific plant. +`api.plant_detail(plant_id, timespan<1=day, 2=month, 3=year, 4=all>, date)` Get details of a specific plant. `api.inverter_list(plant_id)` Get a list of inverters in specified plant. (May be deprecated in the future, since it gets all devices. Use `device_list` instead).