growatt_api_client icon indicating copy to clipboard operation
growatt_api_client copied to clipboard

Storage API returns 504 error

Open Sjord opened this issue 5 years ago • 16 comments

The storage API doesn't seem to work well for everyone. There are two reports of it returning 504:

  • @wynandmyriota here
  • @schimmelbirne here

Sjord avatar Sep 15 '20 09:09 Sjord

get_storage_params only takes a storage serial number. That method still works for certain storage_sns, so it's not always broken. It doesn't work for some other storage_sns, which make me suspect the storage_sn is incorrect. Could it be that the serial returned by get_all_device_list is incorrect, or doesn't correspond to the storage unit?

Could you take a look at the screenshots in this comment? There, TEE194904F is the storage sn which seems to work correctly with the API. What does it say for you there? Is it the same serial as returned by get_all_device_list?

Sjord avatar Sep 15 '20 09:09 Sjord

Hi Sjord,

Thank you very much for responding.

I can confirm that the serial number I get from get_all_device_list is the same as what is displayed on the web server.

This is what I get from the command:

[{'lost': False, 'location': '', 'datalogSn': 'NAC5A142E4', 'batteryType': 1, 'deviceSn': 'BKE6A19067', 'deviceStatus': '6', 'pCharge': '0', 'deviceAilas': 'BKE6A19067', 'deviceType': 'SPA3000', 'eChargeToday': '6.7', 'capacity': '100%', 'energy': '0', 'vbat': ''}]} image

An this is the web server:

WynandPrivate avatar Sep 16 '20 04:09 WynandPrivate

Apparently, the SPA3000 doesn't use the storage API, but the newSpaApi.do endpoint. Currently there are no methods in this project that call that endpoint.

Sjord avatar Sep 21 '20 14:09 Sjord

I have made a few methods. Please check out the storage branch, and try something like this:

with GrowattApi() as api:
    api.login(username, password)
    spa = api.spa(plant_id, device_sn)
    print(spa.get_energy_overview())
    print(spa.get_system_status())

Sjord avatar Sep 21 '20 15:09 Sjord

I've tried the two API calls and it works perfectly!!!! Thank you very much. Can I ask how did you manage to figure this out?

I can't get the get_energy_prod_and_cons_data call to work though.

print(spa.get_energy_prod_and_cons_data(datetime.date.today(), Timespan.day))

I get the following error: File "/home/wdewit/growatt_api_client/growatt/__init__.py", line 310, in get_energy_prod_and_cons_data return _obj_success_response(response) File "/home/wdewit/growatt_api_client/growatt/__init__.py", line 32, in _obj_success_response raise GrowattApiError("Request failed: %s" % response) growatt.GrowattApiError: Request failed: <Response [500]>

I have another question regarding the data packets received from the ShinLan box, but don't think this is the place to have the discussion. Is there another way for me to contact you?

WynandPrivate avatar Sep 22 '20 01:09 WynandPrivate

I've tried the two API calls and it works perfectly!!!!

Nice to hear it works.

Can I ask how did you manage to figure this out?

I intercepted the traffic from the mobile app, and replaced your data in the response to get_all_device_list. That made the app think I have a SPA3000, and it performs the calls to the SPA endpoint.

I can't get the get_energy_prod_and_cons_data call to work though.

Apparently, this uses a different value for type/timespan than the other methods. I updated this function, please pull the change and try again.

I have another question regarding the data packets received from the ShinLan box

I don't think I can help you with this, but you are free to send me an email.

Sjord avatar Sep 23 '20 08:09 Sjord

Hi,

Thank you very much for your time! I've tried the new get_energy_prod_and_cons_data call as follow:

date = datetime.date.today() print(date) print(spa.get_energy_prod_and_cons_data(date, Timespan.day))

But still get the following error: raise GrowattApiError("Request failed: %s" % response) growatt.GrowattApiError: Request failed: <Response [500]>

I will have a look at the interception of the app as I'm also having issues to get my solar inverter energy storage (deviceType = tlx)

WynandPrivate avatar Sep 25 '20 04:09 WynandPrivate

Hi,

I've been using the hybrid API calls (newMixApi) for a few months without any issues. A few days ago this stopped working and none of my API calls work.

Is anyone experiencing the same issue with any other API call? I've checked the network captured data and nothing seems to have change.

Any help will be greatly appreciate.

WynandPrivate avatar Sep 23 '21 05:09 WynandPrivate

Yes, other people were having the same problem. I fixed it in the master branch, but you didn't get the fix because you are on another branch. I'll fix this soon.

Sjord avatar Sep 23 '21 06:09 Sjord

Thank you for letting me know. May I ask what the issue was?

On Thu, 23 Sep 2021, 4:28 pm Sjoerd Langkemper, @.***> wrote:

Yes, other people were having the same problem https://github.com/Sjord/growatt_api_client/issues/10#issuecomment-918495860. I fixed it in the master branch, but you didn't get the fix because you are on another branch. I'll fix this soon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Sjord/growatt_api_client/issues/16#issuecomment-925550457, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHY5H4GH3F4IHCNWUDZLXZ3UDLFZ3ANCNFSM4RM25PWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

WynandPrivate avatar Sep 23 '21 12:09 WynandPrivate

It is the API for logging in to the server.

I changed my code to use newLoginAPI and it's working again!

On Thu, 23 Sep 2021, 10:00 pm Wynand de Wit, @.***> wrote:

Thank you for letting me know. May I ask what the issue was?

On Thu, 23 Sep 2021, 4:28 pm Sjoerd Langkemper, @.***> wrote:

Yes, other people were having the same problem https://github.com/Sjord/growatt_api_client/issues/10#issuecomment-918495860. I fixed it in the master branch, but you didn't get the fix because you are on another branch. I'll fix this soon.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Sjord/growatt_api_client/issues/16#issuecomment-925550457, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHY5H4GH3F4IHCNWUDZLXZ3UDLFZ3ANCNFSM4RM25PWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

WynandPrivate avatar Sep 23 '21 12:09 WynandPrivate

That's right. I merged the changes from master into the storage branch, so this should now work correctly on both branches.

Sjord avatar Sep 23 '21 14:09 Sjord

Thank you very much!

On Thu, 23 Sept 2021 at 23:59, Sjoerd Langkemper @.***> wrote:

That's right. I merged the changes from master into the storage branch, so this should now work correctly on both branches.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Sjord/growatt_api_client/issues/16#issuecomment-925869590, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHY5H4HJWYVR7IGVGSBJVFLUDM2UZANCNFSM4RM25PWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

WynandPrivate avatar Sep 24 '21 01:09 WynandPrivate

Hi,

I am having issues login into the growatt server. It all worked until a few days ago and I am trying to figure out what has changed. Do you have any info on the Login API that recently changed?

Thank you, Wynand

On Fri, 24 Sept 2021 at 10:48, Wynand de Wit @.***> wrote:

Thank you very much!

On Thu, 23 Sept 2021 at 23:59, Sjoerd Langkemper @.***> wrote:

That's right. I merged the changes from master into the storage branch, so this should now work correctly on both branches.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Sjord/growatt_api_client/issues/16#issuecomment-925869590, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHY5H4HJWYVR7IGVGSBJVFLUDM2UZANCNFSM4RM25PWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

WynandPrivate avatar Oct 11 '22 08:10 WynandPrivate

Hi @Sjord Thank you for letting me know. So far so good for me. I've not experienced any issues yet. Will keep an eye out!

WynandPrivate avatar Nov 11 '22 04:11 WynandPrivate