ProudElm / packaging_solaredgeoptimizers

MIT License
3 stars 3 forks source link

Historical panel data #6

Closed gjdv closed 1 year ago

gjdv commented 1 year ago

I am trying to add to your code the ability to retrieve historical data on panel level. Unfortunately not successful yet. Perhaps you have some experience to help me further.

By monitoring calls being made when viewing https://monitoring.solaredge.com/solaredge-web/p/site/{siteID}/#/charts, I see that this data is retrieved by doing a GET request to the following url:

url = 'https://monitoring.solaredge.com/solaredge-web/p/chartData?reporterId={}&fieldId={}&reporterType=&startDate={}&endDate={}&uom=W&parameterName={}'.format(
            itemId, self.siteid,
            starttime, endtime, parameter
        )

When I try to do such a call from Python, checking that the headers sent are the same as in the browser, I can't get a valid answer back, only status code 500. I do see a difference in the cookie(jar) content, as the browser also has e.g., a SolarEdge_SSO-1.4 cookie, which I don't see when running your python module.

Could it be that SE uses different levels of security for various subpages (e.g., /solaredge-web/p/publicSystemData vs /solaredge-web/p/chartData)? (which makes that your module is able to login 'sufficiently' to get the latest panel data, but not the historical data)

ProudElm commented 1 year ago

What historical data are you after, something else then the total energy produced i gues?

I had a lot off trial and error with the getting that part of this code working. I had to make a request with all off those headers. It was really annoying. It was working from the browser but not python indeed. That's why at the end i had to request the cookie and use that one in combination with all of the headers.

What i did, was using Postman quit a lot, that was quicker then python in figuring out if i had a correct url or not..

gjdv commented 1 year ago

Thanks for the pointers. I guess there is some more trial and error to go then :)

The values available are "Power", "Current", "Voltage", "Energy", "PowerBox Voltage"

It would enable just polling once a day to get e.g., all power values of that day, rather than polling every 15 minutes or so for just the most recent value. Also, one could retrieve in hindsight values that might be missing due to the SE service being down (once again) for some time.

ProudElm commented 1 year ago

ah so. Yes, if you dont need 'live' data then polling once a day and requesting all the data in one go that would be also nice.

But yes, it's a lot of trail and error.. :(

gjdv commented 1 year ago

Solved by #8