Files
localthings/tests/test_capability.py
T
Marc Billow 022a192bca feat: CoAP inter-request pacing to prevent RT-OCF rate limit drops
Samsung appliances silently drop CoAP requests when hit faster than their
firmware ceiling (~8–14 req/s measured; dishwasher unknown). Multi-block
Block2 fetches on LAN hit ~100 req/s instantaneously, causing the observed
burst timeouts on block 4 and block 10 of /device/0.

Adds rate_limit_rps (default 5 req/s / 200 ms) to DtlsCoapSession with a
pace() method that enforces the inter-block delay via _stop.wait() so session
teardown interrupts the sleep cleanly. Coordinator calls pace() between hrefs
in _poll_hrefs_blocking. Also adds device IP to all GET log lines for easier
per-device filtering.
2026-06-30 22:40:14 -05:00

20 lines
655 B
Python

from custom_components.localthings.ocf.registry.capability import Capability
from custom_components.localthings.ocf.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 c.active_when is None
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")