briancmpbll / home_assistant_custom_envoy

176 stars 77 forks source link

Authorisation issue with firmware 8.2.4264 #202

Closed otterlo closed 2 weeks ago

otterlo commented 3 weeks ago

Hi,

since 19-aug my integration stops working, reporting Authorisation failure "could not authenticate with enlighten, statuys 401"

i am suspicious that it is related to the new firmware 8.2.4264 that was pushed to my system recently. it is even not described on the enlighten firmware page, so perhaps very new

could this be the issue that the integration would not load?

catsmanac commented 3 weeks ago

That error means the specified username or password failed when connecting to the Enphase website to get a token.

Relation to the new firmware is probably that it forces to get a new token which surfaces the issue with username or password. Therefore the integration won't load as it needs the token to access the Envoy.

Do the username and password work when going to https://enlighten.enphaseenergy.com/ ?

catsmanac commented 3 weeks ago

That firmware is for the California NEM 3 with AI Optimization replacing savings mode. (https://enphase.com/download/ai-optimization-california-net-billing-tariff-nem-30-user-guide , https://support.enphase.com/s/article/how-does-my-enphase-energy-system-with-iq-batteries-work)

otterlo commented 3 weeks ago

HI, thanks for the replies. yes, the authorisation works normally for enlighten, everything works including the app. system is fully functional. it is only the integration that does not load

catsmanac commented 3 weeks ago

Anything in the log file aside from that error? If you enable debug in HA on the Envoy and let it run for some time there maybe some more info on what is going on.

I've seen similar reports in the past where the issue mysteriously disappeared again. In most of these cases the Enlighten web-site was suspected to be overloaded. Can't say if that is the case here too.

If the issue persists, one work-around to attempt is getting a token manually. Visit https://entrez.enphaseenergy.com/ to get a token using your credentials. Test the token by opening the envoy local web-page https://envoy.local and pasting it in there.

afbeelding

Once you have the token you can update it in the HA file that holds the token:

To enable debug: afbeelding

When you disable debug again, the logfile will download to your PC.

catsmanac commented 3 weeks ago

As for the firmware, that can also be pushed out due to recently discover vulnarabilities in the Envoy firmware

otterlo commented 3 weeks ago

Hi, i confirm that above procedure of generating new token has worked for me, it is operatational now.

not sure if this procedure is written down somewhere but will be very valuable perhaps for other users having same issue

i thank you so much for your help

i forgot to take snapshot from the log, but basically the error was: could not authenticate.

all is working now

otterlo commented 3 weeks ago

I was a little too early i guess. It stoppen working today. Some 2 hours ago. So not from midnight exactly.

I have the same error again.

I will copy log output below. Perhaps the system wrote back the old token. I can not check this richt now but will do later.

Logboek Details (FOUT) Deze fout is ontstaan door een aangepaste integratie. Logger: custom_components.enphase_envoy Bron: helpers/update_coordinator.py:354 integratie: Enphase Envoy (DEV) (documentatie) Eerst voorgekomen: 06:49:23 (154 gebeurtenissen) Laatst gelogd: 09:17:28

Unexpected error fetching envoy Envoy 122243062107 data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 271, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/enphase_envoy/init.py", line 66, in async_update_data await envoy_reader.getData() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 587, in getData await self._getEnphaseToken() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 502, in _getEnphaseToken self._token = await self._fetch_owner_token_json() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/enphase_envoy/envoy_reader.py", line 485, in _fetch_owner_token_json raise RuntimeError(f"Could not Authenticate with Enlighten, status: {resp.status_code}, {resp}") RuntimeError: Could not Authenticate with Enlighten, status: 401, <Response [401 Unauthorized]>

catsmanac commented 3 weeks ago

So it worked for couple of hours and then failed again? What type of account do you have, homeowner or diy/ installer? The last one expires in couple of hours and nerds refresh then. Might be the Reason you are back in same situation.

Op 22 aug. 2024 om 09:21 heeft otterlo @.***> het volgende geschreven:



I was a little too early i guess. It stoppen working today. Some 2 hours ago. So not from midnight exactly.

I have the same error again.

I will copy log output below. Perhaps the system wrote back the old token. I can not check this richt now but will do later.

Logboek Details (FOUT) Deze fout is ontstaan door een aangepaste integratie. Logger: custom_components.enphase_envoy Bron: helpers/update_coordinator.py:354 integratie: Enphase Envoy (DEV) (documentatiehttps://github.com/briancmpbll/home_assistant_custom_envoy#readme) Eerst voorgekomen: 06:49:23 (154 gebeurtenissen) Laatst gelogd: 09:17:28

Unexpected error fetching envoy Envoy 122243062107 data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 271, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/enphase_envoy/init.py", line 66, in async_update_data await envoy_reader.getData() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 587, in getData await self._getEnphaseToken() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 502, in _getEnphaseToken self._token = await self._fetch_owner_token_json() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/enphase_envoy/envoy_reader.py", line 485, in _fetch_owner_token_json raise RuntimeError(f"Could not Authenticate with Enlighten, status: {resp.status_code}, {resp}") RuntimeError: Could not Authenticate with Enlighten, status: 401, <Response [401 Unauthorized]>

— Reply to this email directly, view it on GitHubhttps://github.com/briancmpbll/home_assistant_custom_envoy/issues/202#issuecomment-2303960086, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A4XI5JHW3CKSNC5R2MIUYG3ZSWGPJAVCNFSM6AAAAABMZ7X4RWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBTHE3DAMBYGY. You are receiving this because you commented.Message ID: @.***>

otterlo commented 3 weeks ago

Hi, i installed the system myself, so i guess installer. i dont do it for profession, just this installation at home. then why would it have been working for the last year? it was working fine.

when i went to the site for the token, it asked whether it was for commissioned systems or uncommissioned if you select commissioned, you can then select your system, when selecting uncommissioned i also got a token, but did not work

so i think i did it right way but as you mention: it may be a token for a short duration

then i probably have to create a account for me being the home owner?

catsmanac commented 3 weeks ago

Really don’t know. You asked the right question, it worked before, why not anymore.

Is something changed in that Enlighten login page for installers? Getting a token is documented by Enphase so you could ask their support about this.

@vincentwolsink has a custom integration for installers, but switching might break your stored history, not sure.

I’ll have another look at the code just to be sure.

Op 22 aug. 2024 om 10:54 heeft otterlo @.***> het volgende geschreven:



Hi, i installed the system myself, so i guess installer. i dont do it for profession, just this installation at home. then why would it have been working for the last year? it was working fine.

when i went to the site for the token, it asked whether it was for commissioned systems or uncommissioned if you select commissioned, you can then select your system, when selecting uncommissioned i also got a token, but did not work

so i think i did it right way but as you mention: it may be a token for a short duration

then i probably have to create a account for me being the home owner?

— Reply to this email directly, view it on GitHubhttps://github.com/briancmpbll/home_assistant_custom_envoy/issues/202#issuecomment-2304131620, or unsubscribehttps://github.com/notifications/unsubscribe-auth/A4XI5JFTR3AT5POCXCEUJYDZSWRMLAVCNFSM6AAAAABMZ7X4RWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBUGEZTCNRSGA. You are receiving this because you commented.Message ID: @.***>

catsmanac commented 3 weeks ago

Another simple check you can do is to have a look in the file /config/.storage/core.config_entries. (Don't change the file while HA is running!) Look for Envoy in there and validate username and password are correct. These are only used upon token expiration.

otterlo commented 3 weeks ago

thanks again for your support, much appreciated. i was able to have a look now and indeed, the password in this file differs from the password i am currently using. so this may have triggered it. i change my password now and then...

what is your advise: stop HA and change the file?

catsmanac commented 3 weeks ago

Either edit the file or remove the Envoy and re-add it. When editing the file, first stop HA and make a copy of the original file before editing it. Since editing the token file worked fine, this one will probably be fine too. Only change the password part.

otterlo commented 3 weeks ago

i stopped HA and changed the password section only and restarted HA< it did not work unfortunately.

so what i did is requested new token and changed the enjoy conf file with the new token and rebooted. it works now.
let see if this will make a change...

catsmanac commented 3 weeks ago

Hmm, not what I had hoped for. Fingers crossed, but wouldn't be surprised if it fails again.

otterlo commented 3 weeks ago

so far so good, 24 hours later. . i also manually reloaded the integration just now to seeif it would stop working but it is still OK...

catsmanac commented 3 weeks ago

Nice, pleasant surprise. Not speculating yet on plausible reasons why ;-)

otterlo commented 2 weeks ago

Today also still working. Let me monitor for week or so and let you know if still ok

catsmanac commented 2 weeks ago

Ok, good to hear it seems to be fine now.

otterlo commented 2 weeks ago

still stable so i think we can close this issue. thanks a lot for the support! really great