CharlesGillanders / homeassistant-alphaESS

Monitor your energy generation, storage, and usage data using the official API from Alpha ESS.
MIT License
101 stars 22 forks source link

No Data since today's Alpha ESS Update #76

Closed cpmueller closed 1 year ago

cpmueller commented 1 year ago

Hi, Since the update from Alpha ESS, the data query no longer works. I get the following error:

2023-11-04 09:46:13.375 ERROR (MainThread) [alphaess.alphaess] 'data'
2023-11-04 09:46:13.376 ERROR (MainThread) [custom_components.alphaess] Unexpected error fetching alphaess data: 'data'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
self.data = await self._async_update_data()

File "/config/custom_components/alphaess/coordinator.py", line 30, in _async_update_data
jsondata: json = await self.api.getdata()

File "/usr/local/lib/python3.11/site-packages/alphaess/alphaess.py", line 154, in getdata
units = await self.__get_data("Account/GetCustomMenuESSList")

File "/usr/local/lib/python3.11/site-packages/alphaess/alphaess.py", line 176, in __get_data
if not await self.__connection_check():

File "/usr/local/lib/python3.11/site-packages/alphaess/alphaess.py", line 147, in __connection_check
return await self.authenticate(self.username, self.password)

File "/usr/local/lib/python3.11/site-packages/alphaess/alphaess.py", line 67, in authenticate
if "AccessToken" in json_response["data"]:

KeyError: 'data'
2023-11-04 09:46:13.379 DEBUG (MainThread) [custom_components.alphaess] Finished fetching alphaess data in 0.525 seconds (success: False)

Thank you for looking into that issue!

MorneSaunders360 commented 1 year ago

It appears that Alpha ESS has updated its API authentication protocol, transitioning from a simple password-based login to a more secure method that involves hashing the password prior to login. Additionally, the login endpoint has been modified; what was previously accessed via https://cloud.alphaess.com/api/Account/Login has now been changed to https://cloud.alphaess.com/api/base/user/login.

Thank you for looking into that issue!

MorneSaunders360 commented 1 year ago

Code responsible for creating the encrypted password that the website use. Hope this helps.

export function encrypt(password, username) { let aeskey = CryptoJS.SHA256(username) let iv = CryptoJS.MD5(username) let encrypted = CryptoJS.AES.encrypt(password, aeskey, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7, }) return encrypted.toString() }

ckarrie commented 1 year ago
weissjuergen commented 1 year ago

It seems some of you know how to get the integration to work again. I am a bloody user only. Can anyone advise what I would need to do in my home Assistent or in the integration files to fix the issue, greatly appreciated.

Poshy163 commented 1 year ago

Someone needs to make a pull request with these changes, and hopefully it gets pulled, packaged and updated by the repo owner

strickersuk commented 1 year ago

If it's doable then Charles is usually pretty quick to fix, just hang tight.

matt-oneill commented 1 year ago

I’ve posted a quick fix on an issue to the alphaess library, hopefully Charles can publish a new version which will sort it temporarily. Alpha are trying to push people to use their new public api but from what I’ve seen is still unstable and doesn’t have all functionality

CharlesGillanders commented 1 year ago

Thanks Matt! I can get this pulled and an update out later today. Much appreciated.

DavidqStokes commented 1 year ago

Charles and other contributors all do this voluntarily and are usually very good and diagnosing issues, updating libraries, testing and issuing an update to the HA integration.

Everyone needs to be respectful of their time and efforts. If people don't understand that this is the way that open source software works then HA is probably the wrong home automation solution for them.

Charles, Matt et al - thank you so much for your continued work on this integration and for putting up with the challenges of working with AlphaESS.

CharlesGillanders commented 1 year ago

I've pushed a beta update to through HACS that uses @matt-oneill 's temporary workaround of changing the base URL for the API. I'm going to work on incorporating the changes identified by @MorneSaunders360 and @ckarrie

ckarrie commented 1 year ago

Nice workaround! Thank you!

matt-oneill commented 1 year ago

Nice one Charles. I had a look at the other apis earlier and a lot of them have changed the path so not a simple blanket change to the login endpoint. Maybe it’s time to re visit the new api

strickersuk commented 1 year ago

Thanks folks, it’s working for me.

CharlesGillanders commented 1 year ago

Nice one Charles. I had a look at the other apis earlier and a lot of them have changed the path so not a simple blanket change to the login endpoint. Maybe it’s time to re visit the new api

I've found several equivalents, most of them in fact but the missing one for me is the Discharge numbers - I used to grab them from system statistics but I cannot see any mention of discharge in any of the results I'm getting back in the web interface now.....

braindeadmalc commented 1 year ago

I'm sorry to be a pain but what do I need to do to get the fix applied? I'm not an expert at the internals of HA, just an enthusiastic amateur.

weissjuergen commented 1 year ago

I'm sorry to be a pain but what do I need to do to get the fix applied? I'm not an expert at the internals of HA, just an enthusiastic amateur.

Same for me, I have the same question.

CharlesGillanders commented 1 year ago

If you deployed using HACS then should just be a matter of finding the AlphaESS repo in HACS and click on update information in the three dots menu. Navigate back to the main list of HACS integrations and you should see an update button for AlphaESS.

braindeadmalc commented 1 year ago

If you deployed using HACS then should just be a matter of finding the AlphaESS repo in HACS and click on update information in the three dots menu. Navigate back to the main list of HACS integrations and you should see an update button for AlphaESS.

Thanks, you put me on the right track, sort of. I went into HACS, clicked on the Alpha Integration then from the Menu selected Redownload with the "show Betas" option, then selected the latest Beta you released. An HA restart and all seems good.

Thanks for your help and the integration. much appreciated.

@weissjuergen , hope this helps

weissjuergen commented 1 year ago

@weissjuergen , hope this helps

Yes, it did, I can see my entities again. Thank you Charles !

Rasenkardinal commented 1 year ago

Amazing! Thank you so much! Ist there any oportunity to support your work with money? Would be a pleasure for me.

CharlesGillanders commented 1 year ago

Amazing! Thank you so much! Ist there any oportunity to support your work with money? Would be a pleasure for me.

No need for any cash - I do this because I have my own solar system to manage. This fix is only temporary, so don't be alarmed if it doesn't last for long - it's dependent on Alpha being slow to update another URL but I think we all know that's unlikely to last forever.

wallus commented 1 year ago

I downloaded the beta version (v0.3.4beta) and it is working correctly again. Thanks Charles!

foylema commented 1 year ago

Just updated to the BETA and it's all working again. Thanks for fixing this so quickly.

ceeessbee commented 1 year ago

+1, BETA looks good. To all the experts who know what they're doing with this, big thumbs up, and to you Charles for the time and effort to bring this to us all. HA is great but nothing without people to bring us the goodies!

Poshy163 commented 1 year ago

Appears to be working, check your systems connection to the cloud, seems to be a issue on your end.

tasranson commented 1 year ago

Unfortunately I still can't get it to Configure the integration, It gives Unknown Error after entering UserName and Password and the logs show the following:

Logger: custom_components.alphaess.config_flow Source: custom_components/alphaess/config_flow.py:66 Integration: Alpha ESS (documentation) First occurred: 14:21:23 (3 occurrences) Last logged: 14:24:50

Unexpected exception Traceback (most recent call last): File "/config/custom_components/alphaess/config_flow.py", line 66, in async_step_user info = await validate_input(self.hass, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/alphaess/config_flow.py", line 44, in validate_input if not await client.authenticate(data["username"],data["password"]): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/alphaess/alphaess.py", line 60, in authenticate if "AccessToken" in json_response["data"]:


KeyError: 'data'

I expect I still have remants of the old version on my system, but I can not seem to find out how to clean it out and start again.  I have removed the integration previously and added the repository back in today, but setting up the integration gives the same error.   I must be doing something wrong, but have not idea what.   Any hints on how to get the new version sorted in this scenario?
CharlesGillanders commented 1 year ago

scenario?

It's maybe worth trying to completely remove the component and the associated library manually and then trying again.

I think the library can be deleted by removing the entire folder /usr/local/lib/python3.11/site-packages/alphaess

The component can be deleted by removing the sub-folder custom_components/alphaess/ under your home assistant configuration folder.

ElevenFan commented 1 year ago

Our next version of Web API will add anti-crawling function. Please move to OpenAPI, otherwise you will update with us every time.Thanks。Open api we are slowly optimizing the request limit。

ckarrie commented 1 year ago

Challenge accepted

CharlesGillanders commented 1 year ago

I have a working version of the component using the AlphaESS OpenAPI running in test. Before I consider pushing it out as an updated release I want to give everyone a heads up that the Open API will require you to register with the Alpha ESS developer portal and obtain an AppID and an AppSecret for yourself and to also bind your own inverter to that AppID in the portal.

If anyone hasn't already registered with the AlphaESS OpenAPI portal then this component will stop working when I push the updated release.

I will put a notification on the main page of the GitHub repository as well but for everyone following this thread - please register with https://open.alphaess.com/ as soon as you are able.

thospe commented 1 year ago

done, looking forward to a more reliable and stable connection.

It looks like they (AlphaESS) are having other software problems as well in their monitoring. Currently my wallbox usage isn’t reported properly anymore - and haha, they told me to check the correct cabling.

Am 07.11.2023 um 13:37 schrieb CharlesGillanders @.***>:

I have a working version of the component using the AlphaESS OpenAPI running in test. Before I consider pushing it out as an updated release I want to give everyone a heads up that the Open API will require you to register with the Alpha ESS developer portal and obtain an AppID and an AppSecret for yourself and to also bind your own inverter to that AppID in the portal.

If anyone hasn't already registered with the AlphaESS OpenAPI portal then this component will stop working when I push the updated release.

I will put a notification on the main page of the GitHub repository as well but for everyone following this thread - please register with https://open.alphaess.com/ https://open.alphaess.com/ as soon as you are able.

— Reply to this email directly, view it on GitHub https://github.com/CharlesGillanders/homeassistant-alphaESS/issues/76#issuecomment-1798418356, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABCHOA6NMO2LZXFQYQGC5FDYDITQFAVCNFSM6AAAAAA65N3WICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJYGQYTQMZVGY. You are receiving this because you are subscribed to this thread.

Rasenkardinal commented 1 year ago

That really gets things moving. The registration is complete. Ready when you are!

And again: Thanks a lot!

braindeadmalc commented 1 year ago

Registration complete but how the heck do you bind your system? When I try and add mine it asks for the system S/N which I guess is the one beginning AL rather than the actual Inverter S/N? I have both. But then it wants CheckCode which is where I get unstuck. Anyone any idea what this is pls? I assume after entering that I may get the Verification Code.

strickersuk commented 1 year ago

It’s on the side of the unit.

braindeadmalc commented 1 year ago

It’s on the side of the unit.

Well I'll be! Never thought to look at the hardware itself. Doh!

Thanks for that. Binding complete.

ceeessbee commented 1 year ago

Registered. Thanks for the ongoimng work

ZeeDK commented 1 year ago

Looking very much forward to the fix. Realized (for the last ~week it has been down) that this is the most important integration in my HA setup :D

Didn't try the "beta", but will try out the fix as soon as HACS gets the update :)

CharlesGillanders commented 1 year ago

I have published release 0.4.0 of the HomeAssistant custom component - this is the switch to using the official OpenAPI.

There are some details on how to switch an existing deployment to use the new API in the Github README https://github.com/CharlesGillanders/homeassistant-alphaESS/blob/main/README.md

jasonwins commented 1 year ago

Downloaded and it works for me. Huge thanks Charles

umrath commented 1 year ago

Works like a charm. One minor issue: The dialog to add the credentials does not have any kind of description for me. All I saw were 2 unnamed input fields.

kinektek commented 1 year ago

Working like a dream, thank you for all the efforts!

On Tue, Nov 14, 2023 at 12:41 PM CharlesGillanders @.***> wrote:

I have published release 0.4.0 of the HomeAssistant custom component - this is the switch to using the official OpenAPI.

There are some details on how to switch an existing deployment to use the new API in the Github README https://github.com/CharlesGillanders/homeassistant-alphaESS/blob/main/README.md

— Reply to this email directly, view it on GitHub https://github.com/CharlesGillanders/homeassistant-alphaESS/issues/76#issuecomment-1809957508, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZ6DF4RGZIJ4CEITBKZN5J3YENDFZAVCNFSM6AAAAAA65N3WICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBZHE2TONJQHA . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>

-- Kind regards Reece

Reece BotesCTO

Office 7 | Inospace | 5 Sunrise Circle | Ndabeni O +27 21 424 8511 <+27%2021%20424%208511> M +27 82 9303130 <+27%2082%20930%203130> E @.** W* www.kinektek.com

strickersuk commented 1 year ago

Thanks Charles, all working.

CharlesGillanders commented 1 year ago

Works like a charm. One minor issue: The dialog to add the credentials does not have any kind of description for me. All I saw were 2 unnamed input fields.

I don't understand that - the temp home assistant deployment I setup to test with showed the correct input details but my own production environment had the same issue you had. Something odd somewhere that I will need to try to chase down....

matt-oneill commented 1 year ago

Thanks @CharlesGillanders great work. Same for me - but its working again hopefully we won't have to keep chasing api changes image

braindeadmalc commented 1 year ago

Thanks for this update I think I've found a problem when calling the Alpha ESS: Set Battery Charge service, It just returns an unknown error when I call it.

On Tue, 14 Nov 2023 at 10:41, CharlesGillanders @.***> wrote:

I have published release 0.4.0 of the HomeAssistant custom component - this is the switch to using the official OpenAPI.

There are some details on how to switch an existing deployment to use the new API in the Github README https://github.com/CharlesGillanders/homeassistant-alphaESS/blob/main/README.md

— Reply to this email directly, view it on GitHub https://github.com/CharlesGillanders/homeassistant-alphaESS/issues/76#issuecomment-1809957508, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5GM6ZCNIPQVMJCP2MNAGGTYENDFTAVCNFSM6AAAAAA65N3WICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBZHE2TONJQHA . You are receiving this because you commented.Message ID: @.***>

DavidqStokes commented 1 year ago

I haven't yet tried to call the battery services (I use an automation later in the evening)

CharlesGillanders commented 1 year ago

Thanks for this update I think I've found a problem when calling the Alpha ESS: Set Battery Charge service, It just returns an unknown error when I call it. On Tue, 14 Nov 2023 at 10:41, CharlesGillanders @.> wrote: I have published release 0.4.0 of the HomeAssistant custom component - this is the switch to using the official OpenAPI. There are some details on how to switch an existing deployment to use the new API in the Github README https://github.com/CharlesGillanders/homeassistant-alphaESS/blob/main/README.md — Reply to this email directly, view it on GitHub <#76 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A5GM6ZCNIPQVMJCP2MNAGGTYENDFTAVCNFSM6AAAAAA65N3WICVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBZHE2TONJQHA . You are receiving this because you commented.Message ID: @.>

Would you mind opening a new issue to track that separately please?

braindeadmalc commented 1 year ago

Issue opened as requested.

DarkSlice1 commented 1 year ago

im using the new API (outside of home assistant), the set charge is a PUT call now https://github.com/DarkSlice1/AlphaEss_Monitor/blob/dumpZappi/src/main/scala/api/alpha/alpha.scala#L108

ZeeDK commented 1 year ago

AWESOME to have this integration running again! As matt-oneill mentioned I also didn't have any labels in the "credentials prompt". image

But the most important thing is that it works. I went from having 21 to 23 entities after adding the new "integration entry", don't know what the new ones are but everything works as before :)

Thanks for the great work Charles!