♻️ Extract _find_switch_capacity to collapse switch-capacity scan #48

Merged
mat merged 1 commit from refactor/find-switch-capacity into main 2026-07-13 12:49:39 +00:00
Owner

Pure, behavior-preserving refactor of coordinator.py.

Collapses the duplicated features→capacities→nature scan (previously in both _has_switch_capacity and _fetch_switch_state) into a single static _find_switch_capacity helper, and removes _has_switch_capacity.

⚠️ Stacked on #47 — this PR targets refactor/try-fetch-helper, not main. Merge #47 first; this PR will then retarget to main.

Note: this aligns _fetch_switch_state with the first-match semantics that _has_switch_capacity already used. The old inner-loop break returned the last feature's match for a multi-feature device — a latent inconsistency, not exercised by any test.

  • 32/32 tests pass, ruff clean.
Pure, behavior-preserving refactor of `coordinator.py`. Collapses the duplicated features→capacities→nature scan (previously in **both** `_has_switch_capacity` and `_fetch_switch_state`) into a single static `_find_switch_capacity` helper, and removes `_has_switch_capacity`. ⚠️ **Stacked on #47** — this PR targets `refactor/try-fetch-helper`, not `main`. Merge #47 first; this PR will then retarget to `main`. Note: this aligns `_fetch_switch_state` with the first-match semantics that `_has_switch_capacity` already used. The old inner-loop `break` returned the *last* feature's match for a multi-feature device — a latent inconsistency, not exercised by any test. - 32/32 tests pass, ruff clean.
♻️ Extract _find_switch_capacity to collapse switch-capacity scan
All checks were successful
Validate / lint-ruff (push) Successful in 7s
Validate / test-pytest (push) Successful in 2m59s
Validate / type-check-mypy (push) Successful in 3m8s
Validate / lint-ruff (pull_request) Successful in 7s
Validate / test-pytest (pull_request) Successful in 2m59s
Validate / type-check-mypy (pull_request) Successful in 3m7s
ddcb75284f
mat changed target branch from refactor/try-fetch-helper to main 2026-07-10 18:01:20 +00:00
mat force-pushed refactor/find-switch-capacity from ddcb75284f
All checks were successful
Validate / lint-ruff (push) Successful in 7s
Validate / test-pytest (push) Successful in 2m59s
Validate / type-check-mypy (push) Successful in 3m8s
Validate / lint-ruff (pull_request) Successful in 7s
Validate / test-pytest (pull_request) Successful in 2m59s
Validate / type-check-mypy (pull_request) Successful in 3m7s
to 577546f09a
All checks were successful
Validate / lint-ruff (push) Successful in 7s
Validate / test-pytest (push) Successful in 2m59s
Validate / type-check-mypy (push) Successful in 3m7s
Validate / lint-ruff (pull_request) Successful in 7s
Validate / test-pytest (pull_request) Successful in 2m59s
Validate / type-check-mypy (pull_request) Successful in 3m8s
2026-07-10 18:26:05 +00:00
Compare
mat merged commit 5b98c7756c into main 2026-07-13 12:49:39 +00:00
mat deleted branch refactor/find-switch-capacity 2026-07-13 12:49:39 +00:00
mat referenced this pull request from a commit 2026-07-13 13:03:58 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mat/homeassistant-comwatt!48
No description provided.