Fix hot/warm href tiers dropped for no-entity coverage capabilities
discover() only emitted a BoundEntity per capability *entity*, so a coverage-only Capability (entities=(), used to mark a href as handled elsewhere -- e.g. the AC climate card's wind/strength, wind/direction, temperature/control hrefs) produced zero rows. The coordinator computed its hot/warm href lists by walking `bound`, so every such href's poll_tier was silently discarded and it fell back to the ~30s summary poll only -- no sub-poll cadence and never attempted for OCF OBSERVE. This is the root cause of issue #166's "up to a minute" lag for remote-driven fan-speed changes: /wind/strength/vs/0 carries poll_tier 'warm' via airconditioner.COVERAGE but never reached _hot_hrefs/_warm_hrefs, so it wasn't in the OBSERVE-attempt href list and only refreshed on the summary poll. discover() now takes an optional tier_log(href, poll_tier) callback fired for every href a capability matches, entities or not. The coordinator uses it directly instead of deriving tiers from `bound`.
This commit is contained in:
3 files changed
+38
-9
No files matched your search
@@ -73,7 +73,15 @@ def discover(
|
||||
registry: dict[str, list[Capability]],
|
||||
pattern_caps: Iterable[Capability] = (),
|
||||
log: Optional[Callable[[str], None]] = None,
|
||||
tier_log: Optional[Callable[[str, str], None]] = None,
|
||||
) -> list[BoundEntity]:
|
||||
"""`tier_log(href, poll_tier)` fires for every href a capability actually
|
||||
matches, even a no-entity "coverage-only" capability (see COVERAGE lists
|
||||
in capabilities/*.py) that `_bind()` turns into zero `BoundEntity` rows.
|
||||
Callers that need a href's poll cadence (the coordinator's hot/warm
|
||||
sub-poll and OBSERVE-attempt lists) must use this, not `bound` -- a
|
||||
coverage-only capability's `poll_tier` would otherwise be silently
|
||||
dropped since it never appears in `bound`."""
|
||||
out: list[BoundEntity] = []
|
||||
|
||||
for href, rep in resources.items():
|
||||
@@ -91,6 +99,8 @@ def discover(
|
||||
inst = instance_suffix(href)
|
||||
out.extend(_bind(cap, href, inst, _instance_name(cap, rep)))
|
||||
matched = True
|
||||
if tier_log is not None:
|
||||
tier_log(href, cap.poll_tier)
|
||||
|
||||
if matched:
|
||||
continue
|
||||
@@ -109,6 +119,8 @@ def discover(
|
||||
segs = [s for s in src.strip('/').split('/') if s and not s.isdigit() and s != 'vs']
|
||||
out.extend(_bind(cap, href, inst, _instance_name(cap, rep), '_'.join(segs)))
|
||||
matched = True
|
||||
if tier_log is not None:
|
||||
tier_log(href, cap.poll_tier)
|
||||
break
|
||||
|
||||
if not matched and not caps and log is not None:
|
||||
|
||||
Reference in new issue
Block a user