Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down
10 changes: 7 additions & 3 deletions growattServer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server-api.growatt.com is still the URL being used by the app, as not everyone is having issues with the current URL and the new URL might respond differently.
It could cause issues in currently running code.
It's best to overwrite this URL in the scripts using it

Suggested change
server_url = 'https://server.growatt.com/'
server_url = 'https://server-api.growatt.com/'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outdated, see #77

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):
Expand Down Expand Up @@ -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:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you reorder the if statement to have %Y at the top, %Y-%m after the and %Y-%m-%d at the bottom? Helps with reading through the code faster 🙂

date_str = date.strftime('%Y')

return date_str

Expand Down Expand Up @@ -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
Expand Down