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

How can I read the individual inversers? #10

Open Peterpc58 opened 4 years ago

Peterpc58 commented 4 years ago

I have 2 inverters. How can I read the individual inverter values?

Sjord commented 4 years ago

Thanks, @Peterpc58. This is kind of hard to test for me, since my environment only has one inverter. Could you try out the new get_all_device_list function?

Peterpc58 commented 4 years ago

Do I call it like this: all_device_list = api.get_all_device_list() It gives me this error: AttributeError: 'GrowattApi' object has no attribute 'get_all_device_list'

I am new to this....

Sjord commented 4 years ago

I added the get_all_device_list on a separate branch. First, you have to switch to that branch, using git.

If you haven't got a git repo yet, clone it like this:

git clone https://github.com/Sjord/growatt_api_client

If you have, update it like this:

git fetch

Then switch to the branch with the new function:

git checkout get-all-device-list

Then, change growatt/__main__.py or your own script to call get get_all_device_list, and pass it a plant_id:

device_list = api.get_all_device_list(plant_id)
print(device_list)

I would expect that to print information for each inverter.

Peterpc58 commented 4 years ago

I get this error: AttributeError: 'GrowattApi' object has no attribute 'get_all_device_list' I also tried replacing plant_id with the pant id number, but same error.

Peterpc58 commented 4 years ago

Did it all over again and now it is working! Thanks! I have all the data I need now.

Sjord commented 4 years ago

Indy Koning's Growatt script uses newPlantAPI.do?op=getAllDeviceListThree, while I use newTwoPlantAPI.do?op=getAllDeviceList. It would be interesting to compare these.

Peterpc58 commented 3 years ago

a few days ago my script stpped working. I think the device_list = api.get_all_device_list(plant_id) gives he problem. This is returned: Traceback (most recent call last): File "testing.py", line 25, in device_list = api.get_all_device_list(plant_id) File "/home/pi/growatt_api_client/venv/lib/python3.7/site-packages/growatt-0.0.2-py3.7.egg/growatt/init.py", line 141, in get_all_device_list return response.json() File "/home/pi/growatt_api_client/venv/lib/python3.7/site-packages/requests-2.23.0-py3.7.egg/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 7 column 1 (char 19)

can you help?

DanielBroad commented 3 years ago

It seems newTwoPlantAPI.do?op=getAllDeviceList now gives an error 500

Sjord commented 3 years ago

I may have a fix: https://github.com/Sjord/growatt_api_client/pull/24 Could you test it?

DanielBroad commented 3 years ago

confirmed fixed 👍

Sjord commented 3 years ago

I have merged that PR and made a new release.