Skip to content

Intermittent failure to fetch telemetry, with "zlib.error: Error -5 while decompressing data: incomplete or truncated stream" #152

Description

@lurgh

I am intermittently (but regularly) getting a failure in haomnilogic-local's update attempt due to pyomnilogic_local async_get_telemetry failing with "zlib.error: Error -5 while decompressing data: incomplete or truncated stream"`. It has been happening for at least a couple weeks - I believe dating back before I installed the 2.0.0 integration but I am not certain. There is a regular intermittent pattern to the failures. It seems plausible that it is related to the telemetry size changing and sometimes crossing a critical threshold.

Here is a stack trace:

2026-06-19 21:56:32.668 ERROR (MainThread) [custom_components.omnilogic_local.coordinator] Error fetching OmniLogic data: Failed to update data from OmniLogic
2026-06-19 21:56:32.668 DEBUG (MainThread) [custom_components.omnilogic_local.coordinator] Full error:
Traceback (most recent call last):
  File "/config/custom_components/omnilogic_local/coordinator.py", line 47, in _async_update_data
    await self.omni.refresh(force_telemetry=True)
  File "/usr/local/lib/python3.14/site-packages/pyomnilogic_local/omnilogic.py", line 148, in refresh
    self.telemetry = await self._api.async_get_telemetry()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/pyomnilogic_local/api/api.py", line 247, in async_get_telemetry
    resp = await self.async_send_and_receive(MessageType.GET_TELEMETRY, req_body)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/pyomnilogic_local/api/api.py", line 146, in async_send_and_receive
    resp = await protocol.async_send_and_receive(message_type, message)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/pyomnilogic_local/api/protocol.py", line 336, in async_send_and_receive
    return self._decode_payload(raw_data, compressed)
           ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.14/site-packages/pyomnilogic_local/api/protocol.py", line 287, in _decode_payload
    data = zlib.decompress(data.rstrip(b"\x00"))
zlib.error: Error -5 while decompressing data: incomplete or truncated stream

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 434, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/omnilogic_local/coordinator.py", line 51, in _async_update_data
    raise UpdateFailed("Failed to update data from OmniLogic") from err
homeassistant.helpers.update_coordinator.UpdateFailed: Failed to update data from OmniLogic
2026-06-19 21:56:32.680 DEBUG (MainThread) [custom_components.omnilogic_local.coordinator] Finished fetching OmniLogic data in 0.026 seconds (success: False)

Another user reported this issue in the HA forums and posted an AI analysis with proposed patch here: https://community.home-assistant.io/t/hayward-pools-local-integration-announcement/584634/16. I can confirm that this patch makes the problem go away, although I struggle to see why it would make a difference:

--- api/protocol.py_orig
+++ api/protocol.py
@@ -284,7 +284,9 @@
             Decoded UTF-8 string with leading/trailing null bytes stripped.
         """
         if compressed:
-            data = zlib.decompress(data.rstrip(b"\x00"))
+            # data = zlib.decompress(data.rstrip(b"\x00"))
+            _d = zlib.decompressobj()
+            data = _d.decompress(data.rstrip(b"\x00")) + _d.flush()
         return data.decode("utf-8").strip("\x00")

I would (and can) provide a PR but I am not super comfortable in not understanding why this is intermittently failing or why this fix works. Happy to help with debug if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions