Connection is not restored after "Unexpected error fetching Nibe Heat Pump data"
The problem
Once in a while the Nibe integration comes across a connection error in fetching data from the heatpump S1155. After this error the connection to the heatpump is not automatically restored, but the error persists until the intergration is reloaded (or HA restarted). In the attached logfile the error occurs first time around 18:00, the integration was restarted around 08:30.
What version of Home Assistant Core has the issue?
core-2024.7.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
nibe_heatpump
Link to integration documentation on our website
https://www.home-assistant.io/integrations/nibe_heatpump
Diagnostics information
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
Hey there @elupus, mind taking a look at this issue as it has been labeled with an integration (nibe_heatpump) you are listed as a code owner for? Thanks!
Code owner commands
Code owners of nibe_heatpump can trigger bot actions by commenting:
@home-assistant closeCloses the issue.@home-assistant rename Awesome new titleRenames the issue.@home-assistant reopenReopen the issue.@home-assistant unassign nibe_heatpumpRemoves the current integration label and assignees on the issue, add the integration domain after the command.@home-assistant add-label needs-more-informationAdd a label (needs-more-information, problem in dependency, problem in custom component) to the issue.@home-assistant remove-label needs-more-informationRemove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.
(message by CodeOwnersMention)
nibe_heatpump documentation nibe_heatpump source (message by IssueLinks)
Looks like the modbus connection get's into some weird state:
2024-08-20 18:11:47.820 ERROR (MainThread) [homeassistant.components.nibe_heatpump] Unexpected error fetching Nibe Heat Pump data
Traceback (most recent call last):
File "/var/homeassistant/lib/python3.12/site-packages/homeassistant/helpers/update_coordinator.py", line 312, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/homeassistant/components/nibe_heatpump/coordinator.py", line 150, in _async_update_data
return await self._async_update_data_internal()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/homeassistant/components/nibe_heatpump/coordinator.py", line 172, in _async_update_data_internal
async for data in self.connection.read_coils(_get_coils()):
File "/var/homeassistant/lib/python3.12/site-packages/nibe/connection/__init__.py", line 43, in read_coils
yield await self.read_coil(coil, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
return await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/tenacity/_asyncio.py", line 47, in __call__
do = self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/tenacity/__init__.py", line 314, in iter
return fut.result()
^^^^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/var/homeassistant/lib/python3.12/site-packages/tenacity/_asyncio.py", line 50, in __call__
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/nibe/connection/modbus.py", line 85, in read_coil
result = await self._client.read_input_registers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/async_modbus/core.py", line 194, in read_input_registers
return await self._send_message(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/async_modbus/core.py", line 142, in _send_message
return await self.protocol._async_send_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/async_modbus/core.py", line 52, in send_message_tcp
return tcp.parse_response_adu(response_error_adu + response_remainder, adu)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/umodbus/client/tcp.py", line 235, in parse_response_adu
function = create_function_from_response_pdu(resp_pdu, req_adu)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/umodbus/functions.py", line 140, in create_function_from_response_pdu
return function.create_from_response_pdu(resp_pdu)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/homeassistant/lib/python3.12/site-packages/umodbus/functions.py", line 1070, in create_from_response_pdu
address, value = struct.unpack('>HH', resp_pdu[1:5])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 4 bytes
Not sure how to handle that. Have to think about that one.
I have the same issue with a Nibe S735:
2024-09-30 10:40:43.915 ERROR (MainThread) [homeassistant.components.nibe_heatpump] Unexpected error fetching Nibe Heat Pump 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/nibe_heatpump/coordinator.py", line 150, in _async_update_data
return await self._async_update_data_internal()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/nibe_heatpump/coordinator.py", line 172, in _async_update_data_internal
async for data in self.connection.read_coils(_get_coils()):
File "/usr/local/lib/python3.12/site-packages/nibe/connection/__init__.py", line 44, in read_coils
yield await self.read_coil(coil, timeout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 189, in async_wrapped
return await copy(fn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 111, in __call__
do = await self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 153, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 99, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/tenacity/__init__.py", line 398, in <lambda>
self._add_action_func(lambda rs: rs.outcome.result())
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result
return self.__get_result()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
raise self._exception
File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/__init__.py", line 114, in __call__
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/nibe/connection/modbus.py", line 86, in read_coil
result = await self._client.read_input_registers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/async_modbus/core.py", line 194, in read_input_registers
return await self._send_message(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/async_modbus/core.py", line 142, in _send_message
return await self.protocol._async_send_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/async_modbus/core.py", line 42, in send_message_tcp
response_error_adu = await reader.readexactly(exception_adu_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/sockio/aio.py", line 36, in wrapper
return await coro
^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/sockio/aio.py", line 383, in readexactly
return await self._readexactly(n)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/sockio/aio.py", line 52, in wrapper
await self.close()
File "/usr/local/lib/python3.12/site-packages/sockio/aio.py", line 309, in close
await self.writer.wait_closed()
File "/usr/local/lib/python3.12/asyncio/streams.py", line 364, in wait_closed
await self._protocol._get_close_waiter(self)
File "/usr/local/lib/python3.12/asyncio/selector_events.py", line 1003, in _read_ready__data_received
data = self._sock.recv(self.max_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer
Not sure if it has to do with some recent update of the heat-pump...?
Have anybody solved this? Any hotfixes? I have S1255 and similar issues occurred couple months. After heatpump losts connection to the local network, and to homeassistant, it won't wake up.
I found the reason in my setup. It was actually due to a miss in a new environment where I forgot to specify a mac-binding for the heat-pump IP, so it changed IP address via dhcp. After fixing that it got a stable connection again. Now it seems to work fine.
Indeed, I changed my heatpump from a WiFi connection to ethernet, which reduced the amount of connection losses and following issues with this integration. Besides it seems reducing the amount of entities, especially ones which are actually not in use by the heatpump, also stabilizes this issue.
Would still be neat though if the integration would be able to recover by itself.
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.