Skip to content

Integration crashes with AttributeError during panel boot recovery due to inadequate type checking on coordinator data #71

@hildebrau

Description

@hildebrau

In custom_components/omnilogic_local/light.py line 102:

"omnilogic_state": self.data.telemetry.state.pretty()

^^^^^^^^

This crashes when self.data.telemetry.state is an integer instead of an object

Root Cause:
Timing Issue: Integration starts polling immediately after network recovery
Panel State: Panel is still booting and returns incomplete/unexpected data types
Type Assumption: Integration assumes data will always be a proper object with .pretty() method
No Validation: No type checking before calling object methods

I'm running 0.7.12 apparently.. so I'll try to upgrade to the next point release; but the release note on that one didn't seem relevant to me.

I get messages like these when my Omnilogic panel is booting up.. granted, some automations are trying to poll things against it, most likely.. but I feel like there could be better error handling in here somewhere.

2025-08-19 15:13:22.581 DEBUG (MainThread) [custom_components.omnilogic.common] Finished fetching Omnilogic data in 0.092 seconds (success: True)
2025-08-19 15:13:36.172 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run
    self._context.run(self._callback, *self._args)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1237, in _read_ready
    self._protocol.error_received(exc)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyomnilogic_local/protocol.py", line 112, in error_received
    raise exc
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1233, in _read_ready
    data, addr = self._sock.recvfrom(self.max_size)
                 ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
ConnectionRefusedError: [Errno 111] Connection refused
2025-08-19 15:13:36.279 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run
    self._context.run(self._callback, *self._args)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1237, in _read_ready
    self._protocol.error_received(exc)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyomnilogic_local/protocol.py", line 112, in error_received
    raise exc
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1233, in _read_ready
    data, addr = self._sock.recvfrom(self.max_size)
                 ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
ConnectionRefusedError: [Errno 111] Connection refused
2025-08-19 15:13:36.779 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run
    self._context.run(self._callback, *self._args)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1237, in _read_ready
    self._protocol.error_received(exc)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyomnilogic_local/protocol.py", line 112, in error_received
    raise exc
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1233, in _read_ready
    data, addr = self._sock.recvfrom(self.max_size)
                 ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
ConnectionRefusedError: [Errno 111] Connection refused
2025-08-19 15:13:37.280 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run
    self._context.run(self._callback, *self._args)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1237, in _read_ready
    self._protocol.error_received(exc)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyomnilogic_local/protocol.py", line 112, in error_received
    raise exc
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1233, in _read_ready
    data, addr = self._sock.recvfrom(self.max_size)
                 ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
ConnectionRefusedError: [Errno 111] Connection refused
2025-08-19 15:13:37.780 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback _SelectorDatagramTransport._read_ready() (None)
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run
    self._context.run(self._callback, *self._args)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1237, in _read_ready
    self._protocol.error_received(exc)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/site-packages/pyomnilogic_local/protocol.py", line 112, in error_received
    raise exc
  File "/usr/local/lib/python3.13/asyncio/selector_events.py", line 1233, in _read_ready
    data, addr = self._sock.recvfrom(self.max_size)
                 ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
ConnectionRefusedError: [Errno 111] Connection refused
2025-08-19 15:13:52.580 DEBUG (MainThread) [custom_components.omnilogic.common] Finished fetching Omnilogic data in 0.090 seconds (success: True)

2025-08-19 15:14:07.916 INFO (MainThread) [custom_components.omnilogic_local.coordinator] Fetching OmniLogic data recovered
2025-08-19 15:14:07.916 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved (None)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 280, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 491, in _async_refresh
    self.async_update_listeners()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 190, in async_update_listeners
    update_callback()
    ~~~~~~~~~~~~~~~^^
  File "/config/custom_components/omnilogic_local/entity.py", line 47, in _handle_coordinator_update
    self.async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1026, in async_write_ha_state
    self._async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1151, in _async_write_ha_state
    self.__async_calculate_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1092, in __async_calculate_state
    if extra_state_attributes := self.extra_state_attributes:
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/omnilogic_local/light.py", line 102, in extra_state_attributes
    "omnilogic_state": self.data.telemetry.state.pretty(),
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'pretty'


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