Replace the breadth/silence downgrade heuristic with a simpler rule: a still-live OBSERVE session is never torn down on a sweep/cache mismatch (the 30s sweep already corrects the cache regardless of mode) -- only a proven reconnect invalidates subscriptions. A mismatch instead triggers extra hot/warm subpolls this cycle as a bounded fallback. Also stop treating a summary-poll block-level ACK timeout as session death: distinguish TimeoutError (transfer was progressing, session likely alive) from ConnectionError (session actually closed), backed by a consecutive-timeout counter so a genuinely dead channel still recovers. This was causing a flaky/slow device (e.g. a dishwasher) to flap observe<->poll every ~45s on nothing but a slow blockwise GET. Also remove the dead is_active/active_when scaffolding (never wired into the coordinator) and add DEBUG logging for each OBSERVE notify received, including its href.
19 lines
614 B
Python
19 lines
614 B
Python
from custom_components.localthings.registry.capability import Capability
|
|
from custom_components.localthings.registry.entities import BinarySensorDesc
|
|
|
|
|
|
def test_capability_defaults():
|
|
c = Capability(href='/kidslock/vs/0',
|
|
entities=(BinarySensorDesc(key='child_lock', field='x.com.samsung.da.kidsLock'),))
|
|
assert c.poll_tier == 'cold'
|
|
assert len(c.entities) == 1
|
|
|
|
|
|
def test_capability_is_frozen():
|
|
c = Capability(href='/kidslock/vs/0', entities=())
|
|
try:
|
|
c.href = '/other/vs/0'
|
|
except Exception:
|
|
return
|
|
raise AssertionError("expected frozen dataclass")
|