briancmpbll/home_assistant_custom_envoy

Authorisation issue with firmware 8.2.4264

otterlo opened this issue · 20 comments

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?

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/ ?

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

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:

  • navigate to the HA config folder where the configuration.yaml file is.
  • In that folder there's a folder .storage, navigate into it
  • In there there will be a file like envoy.1cc04dea6776540521e6aeff2cf1d25b
    • the part after the . will be different in your case.
    • this file contains the current token in use, content looks like
{
  "version": 1,
  "minor_version": 1,
  "key": "envoy.1cc04dea6776540521e6aeff2cf1d25b",
  "data": {
    "token": "a very long string which is the token"
  }
}
  • Stop Home Assistant
  • Replace the a very long string which is the token in the token file by the new token.
    • Make sure the token is surrounded by "
  • Save the file
  • Restart Home Assistant

To enable debug:
afbeelding

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

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

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

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]>

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?

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.

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?

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.

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...

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

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...

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

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

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

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