vincentwolsink / home_assistant_enphase_envoy_installer

This is a HACS custom integration for Enphase Envoys with firmware version 7 and up.
Apache License 2.0
61 stars 12 forks source link

[BUG] Unknown error occurred #36

Closed Battiegoal closed 1 year ago

Battiegoal commented 1 year ago

Describe the bug Error code in Home Assistant when trying to connect: Unknown error occurred. Tried it both for Installer and Owner account

Account type

Envoy

Home Assistant

Additional context

Relevant snippet of Home Assistant error log.

vincentwolsink commented 1 year ago

Apart from the "Unknown Error" we have another serious issue here. wattHoursToday is 0, and the inverters block in production.json does not contain whToday. Since you don't have CTs we cannot use the whToday value under eim, so basically, there is no way to get this measurement...

catsmanac commented 1 year ago

That's typical with ENVOY metered without CT. Only wNow and whLifetime in production[0] are available. numbers in production[1] are all over the place. Part of many discussions in other threats and where the test for ismetered is in the code.

Unknown error occurs often during first install getting token and enphase website isn't reacting. Does this happen during initial configuration? If so keep on trying is most found solution.

vincentwolsink commented 1 year ago

@Battiegoal Can you check if the latest beta fixes your "Unknown Error", and if not, enable debug logging in Home Assistant and check if there is an error in the logs while setting up the integration.

# configuration.yaml
logger:
  default: debug
Battiegoal commented 1 year ago

Latest beta did not fix the issue. I was able to login with my owner account (one lucky shot, did not manage to replicate this afterwards again). Thx again for putting effort in this.

Log from when I try to login with installer account:

Logger: homeassistant.config_entries Source: custom_components/enphase_envoy/envoy_reader.py:281 Integration: Enphase Envoy (Installer) (documentation, issues) First occurred: 10:12:30 (1 occurrences) Last logged: 10:12:30

Error setting up entry Envoy XXXXXXXXXXX for enphase_envoy Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/anyio/streams/tls.py", line 131, in _call_sslobject_method result = func(*args) ^^^^^^^^^^^ File "/usr/local/lib/python3.11/ssl.py", line 921, in read v = self._sslobj.read(len) ^^^^^^^^^^^^^^^^^^^^^^ ssl.SSLWantReadError: The operation did not complete (read) (_ssl.c:2576)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 390, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/enphase_envoy/init.py", line 191, in async_setup_entry await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 251, in async_config_entry_first_refresh await self._async_refresh( File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 242, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/enphase_envoy/init.py", line 83, in async_update_data await envoy_reader.getData() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 608, in getData await self.detect_model() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 631, in detect_model await self._update_from_pc_endpoint() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 226, in _update_from_pc_endpoint await self._update_endpoint( File "/config/custom_components/enphase_envoy/envoy_reader.py", line 262, in _update_endpoint response = await self._async_fetch_with_retry( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/enphase_envoy/envoy_reader.py", line 281, in _async_fetch_with_retry resp = await client.get( ^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1757, in get return await self.request( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1530, 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 1617, in send response = await self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1645, in _send_handling_auth response = await self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_client.py", line 1719, in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpx/_transports/default.py", line 353, 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 261, in handle_async_request raise exc File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection_pool.py", line 245, in handle_async_request response = await connection.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/connection.py", line 96, in handle_async_request return await self._connection.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 120, in handle_async_request raise exc File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 99, in handle_async_request ) = await self._receive_response_headers(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 163, in _receive_response_headers event = await self._receive_event(timeout=timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/_async/http11.py", line 199, in _receive_event data = await self._network_stream.read( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/httpcore/backends/asyncio.py", line 34, in read return await self._stream.receive(max_bytes=max_bytes) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/anyio/streams/tls.py", line 196, in receive data = await self._call_sslobject_method(self._ssl_object.read, max_bytes) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/anyio/streams/tls.py", line 138, in _call_sslobject_method data = await self.transport_stream.receive() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 1203, in receive await self._protocol.read_event.wait() File "/usr/local/lib/python3.11/asyncio/locks.py", line 213, in wait await fut asyncio.exceptions.CancelledError

vincentwolsink commented 1 year ago

This looks like a communication issue between Home Assistant and the local Envoy. Can you try to restart your Envoy?

Battiegoal commented 1 year ago

I did this. Still no result. I can connect via my home owner account, so envoy is up and running. Also via internal ip I can connect. Log that I have when trying again:

This error originated from a custom integration.

Logger: custom_components.enphase_envoy Source: custom_components/enphase_envoy/envoy_reader.py:673 Integration: Enphase Envoy (Installer) (documentation, issues) First occurred: 14:23:16 (1 occurrences) Last logged: 14:23:16

Unexpected error fetching envoy Envoy XXXXXXXXX data: Could not connect or determine Envoy model. Check that the device is up at 'https://192.168.2.28'. Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 242, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/enphase_envoy/init.py", line 83, in async_update_data await envoy_reader.getData() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 608, in getData await self.detect_model() File "/config/custom_components/enphase_envoy/envoy_reader.py", line 673, in detect_model raise RuntimeError( RuntimeError: Could not connect or determine Envoy model. Check that the device is up at 'https://192.168.2.28'.

mnederlof commented 1 year ago

Can you please post the contents of :

mnederlof commented 1 year ago

also, which version is installed on your envoy? (the info.xml should reveal this 😄 )

Battiegoal commented 1 year ago

UPDATE: I regained access to the system, now while using the option to get a token for a commission gateway (before it worked with uncommisioned gateway)

Of course, sorry for the delay (holidays...)

info.xml:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<envoy_info>
<time>1690309296</time>
<device>
<sn>122207090169</sn>
<pn>800-00654-r07</pn>
<software>D7.6.175</software>
<euaid>4c8675</euaid>
<seqnum>0</seqnum>
<apiver>1</apiver>
<imeter>true</imeter>
</device>
<web-tokens>true</web-tokens>
<package name="rootfs">
<pn>500-00001-r01</pn>
<version>02.00.00</version>
<build>1210</build>
</package>
<package name="kernel">
<pn>500-00011-r02</pn>
<version>04.04.225</version>
<build>3eb4d3</build>
</package>
<package name="boot">
<pn>590-00019-r01</pn>
<version>02.00.01</version>
<build>1f421b</build>
</package>
<package name="app">
<pn>500-00002-r01</pn>
<version>07.06.175</version>
<build>f79c8d</build>
</package>
<package name="devimg">
<pn>500-00005-r01</pn>
<version>01.02.346</version>
<build>b1b724</build>
</package>
<package name="geo">
<pn>500-00008-r01</pn>
<version>02.01.24</version>
<build>a74d96</build>
</package>
<package name="backbone">
<pn>500-00010-r01</pn>
<version>07.00.20</version>
<build>176d57</build>
</package>
<package name="meter">
<pn>500-00013-r01</pn>
<version>03.02.08</version>
<build>eaa252</build>
</package>
<package name="agf">
<pn>500-00012-r01</pn>
<version>02.02.00</version>
<build>40061a</build>
</package>
<package name="security">
<pn>500-00016-r01</pn>
<version>02.00.00</version>
<build>54a6dc</build>
</package>
<package name="full">
<pn>500-00001-r01</pn>
<version>02.00.00</version>
<build>1210</build>
</package>
<build_info>
<build_id>ec2-user-envoy_uber-pkg_master:pkg-Jun-22-23-18:55:22</build_id>
<build_time_gmt>1687460237</build_time_gmt>
<release_ver>02.00.4238</release_ver>
<release_stage>700-GA</release_stage>
</build_info>
</envoy_info>

info from /api/v1/production:

{
  "wattHoursToday": 0,
  "wattHoursSevenDays": 0,
  "wattHoursLifetime": 0,
  "wattsNow": 0
}

and info from production.json:

{"production":[{"type":"inverters","activeCount":16,"readingTime":1690567217,"wNow":770,"whLifetime":52592},{"type":"eim","activeCount":0,"measurementType":"production","readingTime":1690567218,"wNow":-1.836,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.487,"rmsVoltage":251.259,"reactPwr":0.0,"apprntPwr":4.949,"pwrFactor":-0.51,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0,"lines":[{"wNow":0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.0,"rmsVoltage":230.846,"reactPwr":0.0,"apprntPwr":-0.0,"pwrFactor":0.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"wNow":-0.7,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.261,"rmsVoltage":9.264,"reactPwr":-0.0,"apprntPwr":2.41,"pwrFactor":0.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"wNow":-1.136,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.226,"rmsVoltage":11.149,"reactPwr":-0.0,"apprntPwr":2.538,"pwrFactor":-1.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0}]}],"consumption":[{"type":"eim","activeCount":0,"measurementType":"total-consumption","readingTime":1690567218,"wNow":-1.846,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.563,"rmsVoltage":241.887,"reactPwr":0.0,"apprntPwr":2.756,"pwrFactor":-0.91,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0,"lines":[{"wNow":0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.0,"rmsVoltage":230.79,"reactPwr":0.0,"apprntPwr":0.0,"pwrFactor":0.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"wNow":-0.613,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.454,"rmsVoltage":4.489,"reactPwr":-0.0,"apprntPwr":2.038,"pwrFactor":-0.3,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"wNow":-1.232,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.109,"rmsVoltage":6.608,"reactPwr":-0.0,"apprntPwr":0.718,"pwrFactor":-1.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0}]},{"type":"eim","activeCount":0,"measurementType":"net-consumption","readingTime":1690567218,"wNow":-0.01,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.076,"rmsVoltage":241.887,"reactPwr":0.0,"apprntPwr":0.092,"pwrFactor":0.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0,"lines":[{"wNow":-0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":-0.0,"rmsVoltage":230.79,"reactPwr":0.0,"apprntPwr":-0.0,"pwrFactor":-1.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0},{"wNow":0.086,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.193,"rmsVoltage":4.489,"reactPwr":0.0,"apprntPwr":0.867,"pwrFactor":0.1,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0},{"wNow":-0.096,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":-0.117,"rmsVoltage":6.608,"reactPwr":0.0,"apprntPwr":-0.776,"pwrFactor":-1.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}]}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}
Battiegoal commented 1 year ago

UPDATE above :)

mnederlof commented 1 year ago

Well that information is all correct, maybe you just entered the wrong enlighten credentials during setup of the integration?

As detect_model is basically fetching those three URL's and they seem to be fine, it should select EnvoyMetered as model.

Could you retry using the latest version? (and also remove the integration from HA, download latest version from HACS, restart HA and re-add it, if you've not already removed it)

Battiegoal commented 1 year ago

Removed the HACS integration from HA, restarted, re-installed the integration and added it. Used the right credentials (email and password only) and it created a configuration. But in the integration it keeps saying 'installation failed' and starts again to 'initializing'...

vincentwolsink commented 1 year ago

Since everything seems ok when you download the files from your browser, could it be there is a firewall in between the Home Assistant host and the Envoy?

Battiegoal commented 1 year ago

Not that I am aware of. My installation is a modem from KPN with standard settings and a Home Assistant running on a RPi which also runs AdGuard Home. Disabling this last one did not help either.

Battiegoal commented 1 year ago

Just installed latest version (3.3.0) and it works now 👍🏼