home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.61k stars 30.77k forks source link

Enphase Energy keeps initializing #109299

Closed daantjuuh1992 closed 9 months ago

daantjuuh1992 commented 9 months ago

The problem

The Enphase Energy integration no longer retrieves data from the envoy. The integration remains in initializing for a while, then displays a setup failed message. Occasionally, it does read the data for a while, but then it stops again.

What version of Home Assistant Core has the issue?

core-2024.1.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Enphase Energy

Link to integration documentation on our website

No response

Diagnostics information

home-assistant_enphase_envoy_2024-02-01T09-50-42.043Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 9 months ago

Hey there @bdraco, @cgarwood, @dgomes, @joostlek, @catsmanac, mind taking a look at this issue as it has been labeled with an integration (enphase_envoy) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `enphase_envoy` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign enphase_envoy` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


enphase_envoy documentation enphase_envoy source (message by IssueLinks)

catsmanac commented 9 months ago

Hi @daantjuuh1992,

The Enphase Energy integration no longer retrieves data from the envoy

suggests it was working before. Can you share some background if and what has changed right before this issue surfaced?

Also, can you enable enable debug logging on the envoy and let it run for some time, best capturing when the issue occurs. Then disable it again and the log file will download to your computer so you can inspect details on what is going on. Feel free to upload the log file here (after cleaning any sensitive data you don't want to share). And use the `Download Diagnostics' button to download the diagnostics report.

How is the Envoy connected, WiFi or Ethernet cabled?

daantjuuh1992 commented 9 months ago

It used to work through the DEV integration, downloaded via HACS. This worked for a while. In the meantime, I noticed many updates coming through for the standard integration, so I removed the DEV integration and used the standard one. It was initially quite stable, except for some hours of missing data.

I added debug logging under Diagnostic Information. Here is the entire debug logging.

The Envoy is Ethernet wired connected to the network.

catsmanac commented 9 months ago

Here is the entire debug logging.

Is not included here. If you uploaded it, best zip it or rename to a .txt file before using: afbeelding

If you meant to say it's now collecting then no issue.

daantjuuh1992 commented 9 months ago

I made a new debug logging. Is this something you can work with? 2024-02-01 10:19:37.744 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: enphase_envoy 2024-02-01 10:20:37.851 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: enphase_envoy 2024-02-01 10:21:37.955 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: enphase_envoy 2024-02-01 10:22:38.056 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: enphase_envoy 2024-02-01 10:23:38.177 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: enphase_envoy 2024-02-01 10:23:40.185 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Envoy 122304086600 for enphase_envoy Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 406, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/__init__.py", line 24, in async_setup_entry await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 265, in async_config_entry_first_refresh await self._async_refresh( File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 300, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/coordinator.py", line 145, in _async_update_data await self._async_setup_and_authenticate() File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/coordinator.py", line 100, in _async_setup_and_authenticate await envoy.setup() File "/usr/local/lib/python3.11/site-packages/pyenphase/envoy.py", line 109, in setup await self._firmware.setup() File "/usr/local/lib/python3.11/site-packages/pyenphase/firmware.py", line 51, in setup result = await self._get_info() ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped return await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/tenacity/_asyncio.py", line 47, in __call__ do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/tenacity/__init__.py", line 314, in iter return fut.result() ^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 449, in result return self.__get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result raise self._exception File "/usr/local/lib/python3.11/site-packages/tenacity/_asyncio.py", line 50, in __call__ result = await fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/pyenphase/firmware.py", line 36, in _get_info return await self._client.get( ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1786, in get return await self.request( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1559, in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1646, in send response = await self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1674, in _send_handling_auth response = await self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1711, in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1748, in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 371, in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 268, in handle_async_request raise exc File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 251, in handle_async_request response = await connection.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection.py", line 76, in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection.py", line 124, in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/auto.py", line 30, in connect_tcp return await self._backend.connect_tcp( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_backends/anyio.py", line 114, in connect_tcp stream: anyio.abc.ByteStream = await anyio.connect_tcp( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/anyio/_core/_sockets.py", line 217, in connect_tcp async with create_task_group() as tg: File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 668, in __aexit__ raise cancelled_exc_while_waiting_tasks File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 648, in __aexit__ await asyncio.wait(self.cancel_scope._tasks) File "/usr/local/lib/python3.11/asyncio/tasks.py", line 428, in wait return await _wait(fs, timeout, return_when, loop) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/tasks.py", line 535, in _wait await waiter asyncio.exceptions.CancelledError: Global task timeout

cgarwood commented 9 months ago

What firmware version is your Envoy running? You can find the firmware version at envoy.local/info.xml (or replace envoy.local with your Envoy's IP address.

Firmware version is under <device> -> <software>

daantjuuh1992 commented 9 months ago

Softwareversie 7.6.172

I've updated it to try if that helps, but unfortunately not.

catsmanac commented 9 months ago

The log shows that there's no reply when it tried to read exactly that envoy.local/info.xml. If you click the download diagnostics and view the file, what is listed as host?

      "domain": "enphase_envoy",
      "title": "**REDACTED**",
      "data": {
        "host": "192.168.3.112",

and is that correct?

daantjuuh1992 commented 9 months ago

image Where can I find the download diagnostics button? I don't see it in Enphase...

catsmanac commented 9 months ago

Instellingen / Apparaten / Envoy ....

afbeelding

daantjuuh1992 commented 9 months ago

image

As you see in the picture above, I don't have that option... On different devices that option is available, on Enphase it's not...

catsmanac commented 9 months ago

Ah, right it didn't initialize, think that is the issue of no diagnostics button yet, my mistake. Can you edit the config/configuration.yaml fil and add:

logger:
  default: warning
  logs:
    homeassistant.components.enphase_envoy: debug
    httpx: debug
    httpcore: debug

And then restart home assistant. Let it run for couple of minutes and see if there is more detail in home-assistant.log in that same folder.

(EDIT: added httpx and httpcore lines)

daantjuuh1992 commented 9 months ago

Debug tells me a little more. Looks like Envoy has 2 IP addresses; 192.168.2.240 / Ethernet, 192.168.4.8 / WiFi IoT.

2024-02-01 19:19:37.156 DEBUG (MainThread) [httpcore.connection] connect_tcp.started host='192.168.4.8' port=443 local_address=None timeout=10.0 socket_options=None 2024-02-01 19:19:39.554 DEBUG (MainThread) [httpcore.connection] connect_tcp.failed exception=ConnectError(OSError('All connection attempts failed')) 2024-02-01 19:19:39.558 DEBUG (MainThread) [httpcore.connection] connect_tcp.started host='192.168.4.8' port=80 local_address=None timeout=10.0 socket_options=None 2024-02-01 19:19:42.638 DEBUG (MainThread) [httpcore.connection] connect_tcp.failed exception=ConnectError(OSError('All connection attempts failed'))

2024-02-01 19:21:40.185 DEBUG (MainThread) [httpcore.connection] start_tls.started ssl_context=<ssl.SSLContext object at 0x7f14a98ab530> server_hostname='192.168.2.240' timeout=10.0 2024-02-01 19:21:40.313 DEBUG (MainThread) [httpcore.connection] start_tls.complete return_value=<httpcore._backends.anyio.AnyIOStream object at 0x7f146fd87650> 2024-02-01 19:21:40.314 DEBUG (MainThread) [httpcore.http11] send_request_headers.started request=<Request [b'GET']> 2024-02-01 19:21:40.315 DEBUG (MainThread) [httpcore.http11] send_request_headers.complete 2024-02-01 19:21:40.315 DEBUG (MainThread) [httpcore.http11] send_request_body.started request=<Request [b'GET']> 2024-02-01 19:21:40.315 DEBUG (MainThread) [httpcore.http11] send_request_body.complete 2024-02-01 19:21:40.315 DEBUG (MainThread) [httpcore.http11] receive_response_headers.started request=<Request [b'GET']> 2024-02-01 19:21:40.436 DEBUG (MainThread) [httpcore.http11] receive_response_headers.complete return_value=(b'HTTP/1.1', 200, b'OK', [(b'Server', b'openresty/1.17.8.1'), (b'Date', b'Thu, 01 Feb 2024 18:22:05 GMT'), (b'Content-Type', b'text/xml'), (b'Content-Length', b'2056'), (b'Connection', b'keep-alive'), (b'Pragma', b'no-cache'), (b'Expires', b'1'), (b'Cache-Control', b'no-cache'), (b'Strict-Transport-Security', b'max-age=63072000; includeSubdomains'), (b'X-Frame-Options', b'DENY'), (b'X-Content-Type-Options', b'nosniff')]) 2024-02-01 19:21:40.436 INFO (MainThread) [httpx] HTTP Request: GET https://192.168.2.240/info "HTTP/1.1 200 OK"

So looks like the connection only works on Ethernet. How do I remove the IoT IP from Home Assistant?

catsmanac commented 9 months ago

Is there 2 Envoy devices configured? In one of your screenshots I see '8 apparaten', Is that 1 Envoy and 7 solar panel inverters?

daantjuuh1992 commented 9 months ago

Is there 2 Envoy devices configured? In one of your screenshots I see '8 apparaten', Is that 1 Envoy and 7 solar panel inverters?

There is 1 Envoy device. It is both connected by WiFi and Ethernet on different VLAN's. (didn't know that till now) Yes, it's 1 Envoy and 7 micro inverters.

catsmanac commented 9 months ago

in config/.storage folder there is core.config_entries file. It contains the HA configuration. Be careful with it, best copy to to other place. DO NOT CHANGE THE FILE !!!!!

In the file look for

        "domain": "enphase_envoy",
        "title": "Envoy <serial>",
        "data": {
          "host": "192.168.3.112",

The host is the configured IP to use. Verify is it is the right one and there's only 1

This information shows in the diagnostics if that would work.

Be aware there is confidential data like usernames and token in there so do not publish the file either.

daantjuuh1992 commented 9 months ago

In this file the IP is set to 192.168.4.8. How do I edit it?

catsmanac commented 9 months ago

Before you do that, how did you switch from the Enphase DEV? Delete the Envoy, remove Enphase DEV from HACS and then the Envoy again. Or just delete Enphase DEV in HACS and restart Home Assistant?

daantjuuh1992 commented 9 months ago

I first deleted the Envoy, remove DEV and then add the Envoy again.

bdraco commented 9 months ago

Side note: if its flipping from the ethernet to wifi interface, we can borrow the code from powerwall config flow which prevents doing that

catsmanac commented 9 months ago

I first deleted the Envoy, remove DEV and then add the Envoy again.

Do you recall what IP it showed then?

daantjuuh1992 commented 9 months ago

I first deleted the Envoy, remove DEV and then add the Envoy again.

Do you recall what IP it showed then?

Unfortunately not...

catsmanac commented 9 months ago

Ok, changing the IP might or might not work.

If the Wifi address is the one autodetected and you change it to the ethernet one, then the auto discovery will set it back to the Wifi one sometime later. That's the mechanism to deal with ip address changes in dhcp environments.

The best solution is to get the Envoy off the Wifi.

As @bdraco mentioned in his reply, we can change the code to always prefer the Ethernet connection, and we best do that, but that will take some time to add it.

daantjuuh1992 commented 9 months ago

Thank you, I'll remove the Envoy from the Wifi, so it's only connected to Ehternet. See if that fixes the problem. Thanks so far!

daantjuuh1992 commented 9 months ago

The problem is fixed, no more initializing. Thanks everyone!