Open dpoitou-tlse opened 1 year ago
Hello Is there any chance to add these data (month and year) ?
Regards
Yeah, I will check it once get some time. Also, feel free to make a pull request if you can modify the mode to add this feature.
I do know how to make a pull request.
I have modified the following function
def get_device_current_data(url, device_sn, token):
"""
Return device current data
:return: current data
"""
print(f"{time_stamp()}: 🕵️ Fetching data for device: {device_sn}")
try:
conn = http.client.HTTPSConnection(url)
payload = json.dumps({"deviceSn": device_sn})
headers = {"Content-Type": "application/json", "Authorization": "bearer " + token}
conn.request("POST", "//device/v1.0/currentData?language=en", payload, headers)
res = conn.getresponse()
data = json.loads(res.read())
if device_sn==config["inverterId"] :
# Get month data
current_year_month = datetime.now().strftime("%Y-%m")
payload = json.dumps({"timeType": 3,"startTime": current_year_month,"endTime": current_year_month,"deviceSn": device_sn}) #get current year...
conn.request("POST", "//device/v1.0/historical?language=en", payload, headers)
res = conn.getresponse()
data2 = json.loads(res.read())
for item in data2['paramDataList'][0]['dataList']:
item['name'] = f"Month {item['name']}"
data['dataList'].extend(data2['paramDataList'][0]['dataList'])
# Get year data
current_year = datetime.now().year
payload = json.dumps({"timeType": 4,"startTime": current_year,"endTime": current_year,"deviceSn": device_sn})
conn.request("POST", "//device/v1.0/historical?language=en", payload, headers)
res = conn.getresponse()
data2 = json.loads(res.read())
for item in data2['paramDataList'][0]['dataList']:
item['name'] = f"Year {item['name']}"
data['dataList'].extend(data2['paramDataList'][0]['dataList'])
print(f"{time_stamp()}: 🔥 Device data received successfully")
return data
except Exception as error: # pylint: disable=broad-except
print(f"{time_stamp()}: 😡 Unable to fetch device current data: {str(error)}")
return None
Hello, Thanks a lot for your job to retrieve data from solarman.
I used to do it using a connection with the cookies from the browser but it does not work anymore. In the data that I used to got I had the statistics by day/month/year/total.
By default your script get day and total energy. would it be possible to add month and year statics ?
In the doc SolarmanOpenAPI-global(v1.1.6)-EN.pdf of the API it seems to be possible (sec 3.4) -> historical data https://globalapi.solarmanpv.com/ device/ v1.0 / historical => timeType Value Type 1. Frame: Frame data someday 2. Day: Daily statistics ( Less than 30 days) 3. Month: Monthly statistics ( Less than 12 months) 4. Year:Yearly statistics
Best regards