Skip to content

Skip volume/source poll for off zones; lower poll frequency#2

Merged
cdheiser merged 2 commits intomainfrom
poll-optimize
Apr 18, 2026
Merged

Skip volume/source poll for off zones; lower poll frequency#2
cdheiser merged 2 commits intomainfrom
poll-optimize

Conversation

@cdheiser
Copy link
Copy Markdown
Owner

Summary

  • Crestron only responds to VOLUME/SOURCE queries when a zone is powered on. Previously we queried all three every poll, so each off zone burned the full command timeout waiting for a silent reply. With 3 off zones, one poll cycle was ~15 s.
  • Now: query POWER first, and only follow up with VOLUME/SOURCE when the zone is on. Off zones report just power.
  • POLL_INTERVAL_SECONDS 15 → 30 (polling half as often).
  • COMMAND_TIMEOUT_SECONDS 5 → 2 so any unexpected silence stalls less.

Initial refresh on startup still does the full check — if a zone is on at boot it'll pick up volume/source immediately. On transition OFF → ON, the next poll or a command-triggered async_request_refresh will pull volume/source.

Test plan

  • pytest — updated test_poll_collects_state_for_all_zones to assert DECK (off) emits only POWER and skips VOLUME/SOURCE writes.
  • Ruff + Mypy pass.
  • Install on HA and verify debug logs: off zones should show a single ZONE POWER round-trip per poll, not three.

🤖 Generated with Claude Code

Crestron only responds to VOLUME/SOURCE queries when a zone is
powered on. Previously we queried all three for every zone every
poll, so each off zone burned COMMAND_TIMEOUT_SECONDS waiting for
a response that never comes — three off zones = ~15s per poll.

Now we query POWER first and only follow up with VOLUME/SOURCE
when the zone is on. Also bumps POLL_INTERVAL_SECONDS 15 → 30 and
tightens COMMAND_TIMEOUT_SECONDS 5 → 2 so any unexpected silence
stalls less.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Comment thread custom_components/crestron/hub.py Outdated
source_line = await self.request(f"{zone} SOURCE")
if source_line:
zone_state["source"] = source_line.split()[-1]
# Crestron only responds to VOLUME/SOURCE when the zone is on,
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is incorrect. I believe setting the source will turn the zone on. I think the logic is correct but this comment is misleading.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — dropped the misleading comment in 42249ff.

Per review: the statement that Crestron only responds to
VOLUME/SOURCE when on is wrong in general — setting SOURCE as
a command turns the zone on. Only the *query* behavior is
what this branch exploits, and the code is self-explanatory.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cdheiser cdheiser merged commit 67333e1 into main Apr 18, 2026
3 checks passed
@cdheiser cdheiser deleted the poll-optimize branch April 18, 2026 23:49
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