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
71.98k stars 30.17k forks source link

APSysttem integration: Keep production data even on timeout #124640

Closed scharrrfi closed 1 month ago

scharrrfi commented 1 month ago

The problem

Hi there,

since a few days I have a APSystems EZ1-M in my setup. The wifi in my garden is not ideal. That causes, that sometimes the inverter disconnects from my wifi. Is this on a full hour, my energy dashboard cannot update / write with the current production data, because the entities switch to "not available".

I think it can also a better log handling, because on every timeout it does produce an error.

Is it possible to keep the production data (all time and today) even if I have a timeout to the inverter?

Thank you!

What version of Home Assistant Core has the issue?

core-2024.8.3

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

apsystems

Link to integration documentation on our website

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

Diagnostics information

Logger: homeassistant.components.apsystems Quelle: helpers/update_coordinator.py:354 Integration: APsystems (Dokumentation, Probleme) Erstmals aufgetreten: 15:01:10 (1 Vorkommnisse) Zuletzt protokolliert: 15:01:10

Unexpected error fetching APSystems Data 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/components/apsystems/coordinator.py", line 29, in _async_update_data return await self.api.get_output_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/APsystemsEZ1/init.py", line 192, in get_output_data return ReturnOutputData(**response["data"]) if response else None ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: ReturnOutputData.init() got an unexpected keyword argument 'rtime'

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Logger: homeassistant.helpers.entity Quelle: helpers/entity.py:942 Erstmals aufgetreten: 14:54:49 (8 Vorkommnisse) Zuletzt protokolliert: 14:59:51

Update for number.balkonkraftwerk_maximale_leistung fails Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1073, in _wrap_create_connection sock = await aiohappyeyeballs.start_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 104, in start_connection raise first_exception File "/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 81, in start_connection sock = await _connect_sock( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohappyeyeballs/impl.py", line 166, in _connect_sock await loop.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.101.141', 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 942, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, 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 1353, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/client.py", line 657, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 564, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 975, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1350, in _create_direct_connection raise last_exc File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1319, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/aiohttp/connector.py", line 1088, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.101.141:8050 ssl:default [Connect call failed ('192.168.101.141', 8050)]

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

Thanks for opening the issue! This is not really a bug, unfortunately, that's a feature. That's just the Home Assistant way of handling the stuff: if the data source (the inverter) gets unavailable, all associated sensors get unavailable as well. I'd fix that by creating a template sensor somehow that keeps the values. Check the forums for that please. Regarding the errors, I'm not sure if another handling is wanted. Please also don't call it timeout, as it isn't and would make a difference. The thing is: do you ever want to fail silently? I don't think so, so this error is appropriate IMO

mawoka-myblock commented 1 month ago

@home-assistant close

scharrrfi commented 1 month ago

But the whole night, when no sun shines and the inverter is off, it will post every few minutes this time out message in the logs. This cannot be a "feature". Other inverter integrations can also keep some values when the inverter is offline over night do not change them to not available. So that is possible.

mawoka-myblock commented 1 month ago

Then it's a duplicate: https://github.com/home-assistant/core/issues/121419