Sjord / growatt_api_client

Use indykoning/PyPi_GrowattServer instead of this project.
https://github.com/indykoning/PyPi_GrowattServer
MIT License
66 stars 28 forks source link

Growatt API Add Data #14

Open NathanealV opened 4 years ago

NathanealV commented 4 years ago

How would I add more data to the JSON read out that is not already available there?

I see there are things like "PlantList.do" but where do I find these .do files or tags

Thank you so much for the API btw.

Sjord commented 4 years ago

I found the URLs by reverse engineering the Android app, and intercepting traffic between the Android app and the server. Is there particular data you are looking for? I recently added many storage functions, these just need some more testing.

NathanealV commented 4 years ago

Would you be able to share the different URLs? Or share how you reverse engineered it? I tried looking at the website + 'PlantList.do' but it said I don't have permission. I guess I just need the entire stack of data that is there on the website - like the entire thing.

NathanealV commented 4 years ago

I have managed to find these URLs and have been getting the data that I need. Just one question, would you be able to help me with a json parsing error with one of the pages? It's with NewTwoPlantList.do and with parameter

"op": "getUserCenterEnertyDataByPlantid",

Python seems to return an error parsing the json

Edit: It seems that I somehow cannot get authorised for this Api part but I can for the other ones which doesn't make sense to me. Would you know anything about this?

Sjord commented 4 years ago

Did you provide the plantId and language parameters? Try this:

def get_user_center_energy_data_by_plant_id(self, plant_id):
    response = self.session.post(
        self.get_url("newTwoPlantAPI.do"),
        params={"op": "getUserCenterEnertyDataByPlantid"},
        data={"plantId": plant_id, "language": 1},
    )
    return response.json()
NathanealV commented 4 years ago

Yes, that seems to work! Thank you for that.

NathanealV commented 4 years ago

Is there any way to login and complete a GET/POST request all in the same go/same url?

Sjord commented 4 years ago

No, I don't think so. You first need to login and then you can use the session to retrieve information.

NathanealV commented 4 years ago

Ah ok. I was planning to use a third-party interface that gets JSON data but it only provides 1 URL and so I don't know if I can do this. Thank you. I was planning to do it without the use of Python.