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.44k stars 30.67k forks source link

Integration: Enphase Envoy - Unexpected error #62782

Closed mbalfour closed 2 years ago

mbalfour commented 2 years ago

The problem

I just got a new Enphase Envoy installed at my house. I'm trying to set it up in Home Assistant, but get "Unexpected error". Home Assistant: v2021.12.5 Steps:

  1. Configuration->Devices and Services->Add Integration
  2. Select "Enphase Envoy"
  3. Select my Envoy in the provided list
  4. Press "Submit" with the default username and password
  5. Home Assistant prints "Unexpected error" on the username / password screen.

From looking at the logs, my best guess is that envoy_reader needs to be updated to ignore SSL verification results.

What version of Home Assistant Core has the issue?

core-2021.12.5

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 Envoy

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2021-12-25 14:45:59 ERROR (MainThread) [homeassistant.components.enphase_envoy.config_flow] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/config_flow.py", line 168, in async_step_user
    envoy_reader = await validate_input(self.hass, user_input)
  File "/usr/src/homeassistant/homeassistant/components/enphase_envoy/config_flow.py", line 46, in validate_input
    await envoy_reader.getData()
  File "/usr/local/lib/python3.9/site-packages/envoy_reader/envoy_reader.py", line 136, in getData
    await self.detect_model()
  File "/usr/local/lib/python3.9/site-packages/envoy_reader/envoy_reader.py", line 166, in detect_model
    await self.get_serial_number()
  File "/usr/local/lib/python3.9/site-packages/envoy_reader/envoy_reader.py", line 218, in get_serial_number
    full_serial = await self.get_full_serial_number()
  File "/usr/local/lib/python3.9/site-packages/envoy_reader/envoy_reader.py", line 228, in get_full_serial_number
    response = await self._async_fetch_with_retry(
  File "/usr/local/lib/python3.9/site-packages/envoy_reader/envoy_reader.py", line 128, in _async_fetch_with_retry
    return await client.get(url, timeout=30, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1736, in get
    return await self.request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1513, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1600, in send
    response = await self._send_handling_auth(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1628, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1665, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1702, in _send_single_request
    response = await transport.handle_async_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 291, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 248, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 232, in handle_async_request
    response = await connection.handle_async_request(request)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
    raise exc
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 67, in handle_async_request
    stream = await self._connect(request)
  File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 146, in _connect
    stream = await stream.start_tls(**kwargs)
  File "/usr/local/lib/python3.9/site-packages/httpcore/backends/asyncio.py", line 62, in start_tls
    ssl_stream = await anyio.streams.tls.TLSStream.wrap(
  File "/usr/local/lib/python3.9/site-packages/anyio/streams/tls.py", line 94, in wrap
    await wrapper._call_sslobject_method(ssl_object.do_handshake)
  File "/usr/local/lib/python3.9/site-packages/anyio/streams/tls.py", line 102, in _call_sslobject_method
    result = func(*args)
  File "/usr/local/lib/python3.9/ssl.py", line 944, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)

Additional information

Possibly related to https://github.com/home-assistant/core/issues/60109 . It looks like there was a different problem happening recently that resulted in envoy_reader getting updated to support newer versions of httpx. Maybe the SSL default settings changed in the version bump as well?

mbalfour commented 2 years ago

Might also be related to https://github.com/jesserizzo/envoy_reader/issues/78 , in which it mentions that newer Enphase Envoy firmware changed how it authenticates.

probot-home-assistant[bot] commented 2 years ago

enphase_envoy documentation enphase_envoy source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @gtdiehl, 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! (message by CodeOwnersMention)

gtdiehl commented 2 years ago

@mbalfour What firmware version is your Enphase Envoy running?

mbalfour commented 2 years ago

It’s running D7.0.68.

(sent from an iPhone, which encourages brevity)

On Dec 27, 2021, at 8:51 PM, Greg @.***> wrote:

 @mbalfour What firmware version is your Enphase Envoy running?

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.

gtdiehl commented 2 years ago

At this point the envoy_reader API does not support Envoys running firmware D7.x.x.

I would say this is a duplicate of Issue #61524. Though this is not a Home Assistant issue but the downstream API which is tracked by Issue #78

BillyFKidney commented 2 years ago

I'm experiencing the same issue with my IQ Envoy Firmware R5.0.55

image

`Logger: homeassistant.config_entries Source: config_entries.py:344 First occurred: 10:10:09 AM (1 occurrences) Last logged: 10:10:09 AM

Config entry 'Enphase Envoy' for enphase_envoy integration not ready yet: Error communicating with API: All connection attempts failed; Retrying in background`

I tried removing the integration and re-adding it manually but that failed as well.

gtdiehl commented 2 years ago

@BillyFKidney This appears to be a different issue than the original one @mbalfour posted. I'm not sure how others feel about changing the PR from one issue to another. I personally would want a new PR to track the issue, but that's just me and dealing with defect reports for years on end.

In either case, it appears the code is failing at some point when the integration is working with HA internals? Can you post some details regarding the steps, logs, screenshots, and HA version.

Kinda why I was thinking about a new PR since more details are needed to determine the failure

gtdiehl commented 2 years ago

For the Envoy firmware 7.x.x issue please see this comment for Issue #78 on the envoy_reader repo. I have some code that supports the new firmware.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.