Skip to content

Fix: Scope quick and debounced refresh to Keymaster lock entries #684

Description

@tykeal

Part of #670

Summary

Replace global quick/debounce refresh state with entry-specific tracking that feeds
the manager refresh pipeline. Rapid edits should coalesce per lock, while edits on different locks
refresh independently. This completes the releasable unit started by task-9.

Scope / changes

  • Replace global _quick_refresh and _cancel_quick_refresh at coordinator.py:118-119, plus
    shutdown cleanup at coordinator.py:139-145, with per-entry sets/maps.
  • Convert _trigger_quick_refresh() and debounce methods at coordinator.py:1834-1857 to accept
    entry IDs and call the manager pipeline/per-lock coordinator refresh.
  • Convert all _quick_refresh = True sites to record entry IDs: coordinator.py:1596,
    coordinator.py:1678, coordinator.py:2310, and parent-child retry at
    coordinator.py:2493.
  • Convert _schedule_quick_refresh_if_needed() at coordinator.py:2511-2522 to schedule only
    pending entry IDs.
  • Keep entity setters calling await self.coordinator.async_request_debounced_refresh() through
    per-lock coordinator proxies; current setter examples include switch.py:324 and
    switch.py:352.
  • Extend tests/test_debounce.py, which currently mocks _quick_refresh at
    tests/test_debounce.py:53-63, for per-entry quick/debounce behavior.

Plan reference

§5.7, §7.2, §7.5, §8 PR 5; decisions 3 and 9;
2026-07-07 task-9/task-10 shippability finding.

Dependencies

Depends on: #683

Acceptance criteria

  • Multiple rapid edits for one lock coalesce into one per-lock refresh.
  • Edits on two locks schedule two independent per-lock refreshes, not one global fan-out.
  • set_pin_on_lock() and clear_pin_from_lock() add only target/transaction-affected entry IDs
    to quick-refresh tracking.
  • Unload/shutdown cancels and removes per-entry quick/debounce handles.
  • Re-run the plan §7.2 guard regression for quick/debounce paths and prove fan-out remains
    deferred and scoped to the dirty entry set.
  • Targeted validation: pytest tests/test_debounce.py tests/test_coordinator_sync.py.
  • Broader validation: ruff check custom_components/ tests/, ruff format --check custom_components/ tests/, mypy custom_components/keymaster/.

Risk / notes

Avoid reintroducing independent simultaneous polling. All scheduled quick
refreshes should pass through the manager's single sequential refresh loop from task-8.

Size

M

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