Skip to content

Warn on unanswered optional cluster reads - #12

Merged
MarkParker5 merged 1 commit into
developfrom
fix/pairing-log-noise
Oct 30, 2026
Merged

MarkParker5 merged 1 commit into
developfrom
fix/pairing-log-noise

Conversation

@MarkParker5

Copy link
Copy Markdown
Member

Log line (pairing a Tuya TS0001 relay):
ERROR majordom_zigbee.controller:controller.py:976 [PAIR] read_attributes error device=…(TS0001) endpoint=1(ON_OFF_LIGHT) cluster=1794(Metering) error=TimeoutError attrs=
plus, once on the CM4 run: ERROR asyncio:base_events.py:1871 Task exception was never retrieved.

Cause

  • _read_cluster_attributes logged every exception at ERROR and kept reading the next chunks, so a listed-but-unanswered cluster (Metering on the TS0001) logged an ERROR per chunk and waited the 2 s timeout for each.
  • _create_task (and the reconnect task) only discarded finished tasks; nobody retrieved their exceptions.

Fix

  • A TimeoutError now logs once per cluster read and stops the remaining chunks: WARNING for optional clusters, ERROR still for main-parameter clusters (OnOff, LevelControl, …). Other exceptions stay ERROR. Timeouts unchanged.
  • A _log_task_exception done-callback on every _create_task task and on the reconnect task logs the exception (ERROR with traceback) and so retrieves it.

Tested

  • New tests (failed before the fix): test_an_unanswered_optional_cluster_read_is_a_warning_not_an_error (TS0001 with Metering timing out: only WARNINGs, one request per read), test_a_failed_background_task_is_logged_not_left_unretrieved.
  • Full suite: 93 passed, 1 skipped. ruff check/format and ty clean.

Also log exceptions of fire-and-forget tasks instead of leaving them
unretrieved.
@MarkParker5
MarkParker5 merged commit 5cb11e7 into develop Oct 30, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant