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). diff --git a/growattServer/__init__.py b/growattServer/__init__.py index 5983644..c09dd7a 100755 --- a/growattServer/__init__.py +++ b/growattServer/__init__.py @@ -22,9 +22,11 @@ class Timespan(IntEnum): hour = 0 day = 1 month = 2 + year = 3 + all = 4 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): @@ -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 @@ -157,7 +161,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