growatt_api_client icon indicating copy to clipboard operation
growatt_api_client copied to clipboard

Expose storage API

Open Sjord opened this issue 5 years ago • 6 comments

New methods:

  • get_energy_prod_and_cons_data(self, plant_id, storage_sn, date, type=0)
  • get_storage_energy_data(self, plant_id, storage_sn, date)
  • get_system_status_data(self, plant_id, storage_sn)
  • get_energy_overview_data(self, plant_id, storage_sn)
  • get_storage_params(self, storage_sn)

Sjord avatar Apr 25 '20 14:04 Sjord

These need some more testing and at least some documentation before I am going to merge this. If you use these, please let me know which functions work best for you, and which data from each function is useful for you.

Sjord avatar May 10 '20 12:05 Sjord

This other project also has some storage functions.

Sjord avatar May 17 '20 11:05 Sjord

Hi. I'm trying to use your storage API calls, but none of them are working for me.

Example: storage_data = api.get_storage_energy_data(plant_id,"BKE6A19067", datetime.date.today())

I get the following error message:

raise GrowattApiError(data)

growatt.GrowattApiError: {'result': 0, 'obj': None, 'msg': '504'}

I've used the get_all_device_list API call to get the AC coupled inverter serial number.

WynandPrivate avatar Sep 15 '20 05:09 WynandPrivate

Thanks @wynandmyriota. I have created a separate issue for this problem: Storage API returns 504 error #16

Sjord avatar Sep 15 '20 09:09 Sjord

These methods need better names or namespaces. get_energy_overview_data currently calls newStorageAPI.do?op=getEnergyOverviewData, but this is very similar to newSpaApi.do?op=getEnergyOverview, and I expect the same to exist for other device types.

Sjord avatar Sep 21 '20 14:09 Sjord

I moved the storage and spa calls to their own class. It now works like this:

with GrowattApi() as api:
    api.login(username, password)
    s = api.storage(plant_id, storage_sn)
    print(s.get_system_status_data())

So api.storage returns a storage object with additional storage specific methods.

Sjord avatar Sep 21 '20 15:09 Sjord