Sjord/growatt_api_client

How can I read the individual inversers?

Peterpc58 opened this issue · 11 comments

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

Sjord commented

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?

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

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.

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.

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

Sjord commented

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

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?

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

Sjord commented

I may have a fix: #24
Could you test it?

confirmed fixed 👍

Sjord commented

I have merged that PR and made a new release.