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
70.99k stars 29.64k forks source link

APSysttem integration - solar_max_output update fails with TimeoutError #121419

Open alfwro13 opened 1 month ago

alfwro13 commented 1 month ago

The problem

This error is logged every 30 seconds at night when the inverter is offline:

Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1122, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1104, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1007, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.1.100', 8050)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1296, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/apsystems/number.py", line 48, in async_update
    self._attr_native_value = await self._api.get_max_power()
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/__init__.py", line 239, in get_max_power
    response = await self._request("getMaxPower")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/__init__.py", line 86, in _request
    async with ses.get(url, timeout=self.timeout) as resp:
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1197, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 581, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 944, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.1.100:8050 ssl:default [Connect call failed ('192.168.1.100', 8050)]````

### What version of Home Assistant Core has the issue?

core-2024.7.1

### What was the last working version of Home Assistant Core?

core-2024.6.x

### What type of installation are you running?

Home Assistant OS

### Integration causing the issue

APSystems

### Link to integration documentation on our website

https://www.home-assistant.io/integrations/apsystems

### Diagnostics information

_No response_

### Example YAML snippet

_No response_

### Anything in the logs that might be useful for us?

```txt
see above

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @mawoka-myblock, @sonnenladengmbh, mind taking a look at this issue as it has been labeled with an integration (apsystems) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `apsystems` 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 apsystems` 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)


apsystems documentation apsystems source (message by IssueLinks)

mawoka-myblock commented 1 month ago

That's strange as I can't replicate it in my setup

alfwro13 commented 1 month ago

My logs are flooded with that error after sunset and they stop at sunrise (so basically when the the inverter goes offline at night)

casa-feuer commented 1 month ago

Hello, i have also problems with the max_output value: Since changing from HACS to main HA Plugin, i can not see or set the max_output anymore. The value and input field are missing. But i also have that errors in my logfile.

Regards Johannes

Logger: homeassistant.helpers.entity Quelle: helpers/entity.py:944 Erstmals aufgetreten: 9. Juli 2024 um 21:26:03 (8860 Vorkommnisse) Zuletzt protokolliert: 18:38:16

Update for number.ez1fassaderechts_maximale_leistung fails Update for number.ez1garagelinks_maximale_leistung fails Update for number.ez1mbalkonrechts_maximale_leistung fails Update for number.ez1mbalkonlinks_maximale_leistung fails Update for number.ez1fassadelinks_maximale_leistung fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1296, in async_device_update await self.async_update() File "/usr/src/homeassistant/homeassistant/components/apsystems/number.py", line 48, in async_update self._attr_native_value = await self._api.get_max_power() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/init.py", line 239, in get_max_power response = await self._request("getMaxPower") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/init.py", line 86, in _request async with ses.get(url, timeout=self.timeout) as resp: File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1197, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 608, in _request await resp.start(conn) File "/usr/local/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 971, in start with self._timer: File "/usr/local/lib/python3.12/site-packages/aiohttp/helpers.py", line 735, in exit raise asyncio.TimeoutError from None TimeoutError

casa-feuer commented 1 month ago

After installing the latest HA Update (7.2) the Input field ist available again. But still timeout Errors: Logger: homeassistant.helpers.entity Quelle: helpers/entity.py:944 Erstmals aufgetreten: 20:37:37 (1812 Vorkommnisse) Zuletzt protokolliert: 22:51:11

Update for number.ez1fassadelinks_maximale_leistung fails Update for number.ez1garagelinks_maximale_leistung fails Update for number.ez1fassaderechts_maximale_leistung fails Update for number.ez1mbalkonlinks_maximale_leistung fails Update for number.ez1mbalkonrechts_maximale_leistung fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1296, in async_device_update await self.async_update() File "/usr/src/homeassistant/homeassistant/components/apsystems/number.py", line 48, in async_update self._attr_native_value = await self._api.get_max_power() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/init.py", line 239, in get_max_power response = await self._request("getMaxPower") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/init.py", line 86, in _request async with ses.get(url, timeout=self.timeout) as resp: File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1197, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 507, in _request with timer: File "/usr/local/lib/python3.12/site-packages/aiohttp/helpers.py", line 735, in exit raise asyncio.TimeoutError from None TimeoutError

mawoka-myblock commented 1 month ago

The error is unhandled intentionally as it shouldn't occur, but it's produced by the inverter, not the integration. And as I've already mentioned, I can't replicate the issue and for me, the issue is closed. Sorry for that. I've just checked personally and the TimeoutError pops up ~5 times a day and that's nothing to worry about.

mawoka-myblock commented 1 month ago

@home-assistant close

mawoka-myblock commented 1 month ago

@home-assistant rename APSysttem integration - solar_max_output update fails with TimeoutError

mawoka-myblock commented 1 month ago

@home-assistant reopen

mawoka-myblock commented 1 month ago

I've got the logs as well now, so I'll have to do some testing as this now isn't a problem only with your setup, but a problem in general.

flo269 commented 1 month ago

Hi, I am seeing it also and have roughly 55k lines of logs per day - mainly containing this:


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 944, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1296, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/apsystems/number.py", line 48, in async_update
    self._attr_native_value = await self._api.get_max_power()
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/__init__.py", line 239, in get_max_power
    response = await self._request("getMaxPower")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/__init__.py", line 86, in _request
    async with ses.get(url, timeout=self.timeout) as resp:
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 1197, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 581, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 544, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 944, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1257, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1226, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1033, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 10.10.10.9:8050 ssl:default [Connect call failed ('10.10.10.9', 8050)]
2024-07-25 22:56:30.242 INFO (MainThread) [homeassistant.components.generic_hygrostat.humidifier] Turning off humidifier switch.tasmota
2024-07-25 22:56:45.401 ERROR (MainThread) [homeassistant.helpers.entity] Update for number.solar_max_output fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1025, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1122, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1104, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1007, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 641, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 681, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('10.10.10.9', 8050)

Core 2024.7.3 Supervisor 2024.06.2 Operating System 12.4 Frontend 20240710.0 Raspberry Pi 4

Let me know if I can help in any way.

Thanks!

mawoka-myblock commented 1 month ago

Thanks for providing additional logs! This issue seems a bit over my head, as the integration trusts Home Assistant with handling failures and retries, so I'll have to investigate an will probably need support in this regard.

As far as I know the following is the problem:

A connection problem should make HA retry the update and if that fails again, the sensor should get unavailable or gets pulled an hour later or so. (That's my understanding)

But somehow, HA seems to just keep updating the sensor.

denwald commented 1 month ago

I get the same error in the log (Update for number.apsystems_ez1_m_max_output_power fails) many thousand times overnight, but strangely not consistently every night.

The Shelly integration recently also started to throw connection errors after powering one of my Shelly Plus Plugs devices down. The logs look a little bit different though, so I'm not certain that the root cause is the same as with the APsystems integration.

I'm using the built-in integration for APsystems inverters on HA 2024.7.4 (docker core).

This is the log for the Shelly Plug connection. Just leaving this here in case it might shed some light on the issue that is discussed here.

Logger: homeassistant.components.shelly
Source: components/shelly/coordinator.py:171
integration: Shelly (documentation, issues)
First occurred: July 30, 2024 at 17:02:28 (3761 occurrences)
Last logged: 10:50:26

Error connecting to Shelly device Shelly Plug 2, error: DeviceConnectionError(DeviceConnectionError(ClientConnectorError(ConnectionKey(host='192.168.100.100', port=80, is_ssl=False, ssl=True, proxy=None, proxy_auth=None, proxy_headers_hash=-2202016839093191944), OSError(113, "Connect call failed ('192.168.100.100', 80)"))))
alfwro13 commented 3 weeks ago

For the time being until this is fixed and avoid tens of thousands of errors in my log file every day I use homeassistant.disable_entity in the evening and homeassistant.enable_entity in the morning to disable/enable the max_output entities on my inverters. Please not that those services are available after installing HACS "Spook your homie" integration.