Squash-merge PR #251: fix appliance course labels and AC setup timeouts

- Add confirmed Samsung Table_02 washer course mappings (69-79, 88)
- Add confirmed dishwasher course mappings (82, 8a, a7, a8, 8c, 88)
- Localize new washer/dishwasher course labels in en, cs, nl
- Decode device-provided personal washer course names from TLV payloads
- Show unrecognized washer enum bytes as 'Unknown (0xNN)'
- Normalize select current-state and options through one display path
- Bound first-setup subdevice enumeration with a shared time budget

Co-authored-by: galaxysj <224385302+galaxysj@users.noreply.github.com>
This commit is contained in:
Marc Billowandgalaxysj committed 2026-08-08 21:17:43 +00:00
1 parent 55765fdf9a
commit 00db7890f5
19 files changed
+771 -49

No files matched your search

+111
View File
@@ -10,6 +10,7 @@ from typing import cast
import cbor2
from custom_components.localthings.registry import subdevices as subdevices_module
from custom_components.localthings.registry.by_type import DeviceRegistry
from custom_components.localthings.registry.capability import Capability
from custom_components.localthings.registry.entities import BinarySensorDesc, SensorDesc
@@ -350,6 +351,116 @@ def test_enumerate_prefixed_flat_fallback_probe_log_reports_every_href_tried():
assert probes[f"/{_UUID}/mode/vs/0"] is True
def test_enumeration_budget_bounds_silent_prefixed_fallback_and_uses_priority(
monkeypatch,
):
"""A firmware that drops unknown prefixed paths cannot stall setup.
The Collection probe gets the larger blockwise allowance. The preferred
live-state href is then attempted first, and the last Property probe is
clamped to exactly the time left in the shared enumeration budget.
"""
class Clock:
now = 0.0
def monotonic(self):
return self.now
class SilentSession:
def __init__(self, clock):
self.clock = clock
self.calls = []
def get(self, path, timeout=10.0):
self.calls.append((tuple(path), timeout))
self.clock.now += timeout
raise TimeoutError
def pace(self):
pass
clock = Clock()
session = SilentSession(clock)
monkeypatch.setattr(subdevices_module.time, 'monotonic', clock.monotonic)
resources = {
'/subdevices/vs/0': {
'x.com.samsung.da.subdeviceIdList': [_UUID],
},
'/power/vs/0': {'power': 'On'},
'/mode/vs/0': {'mode': 'Cool'},
}
found, extra = enumerate_subdevices(
session,
resources,
oic_res_links=[],
preferred_hrefs=('/mode/vs/0',),
time_budget=7.0,
collection_timeout=4.0,
property_timeout=2.0,
)
assert found == []
assert extra == {}
assert clock.now == 7.0
assert session.calls == [
((_UUID, 'device', '0'), 4.0),
((_UUID, 'mode', 'vs', '0'), 2.0),
((_UUID, 'power', 'vs', '0'), 1.0),
]
def test_enumeration_keeps_preferred_response_found_before_budget_expires(
monkeypatch,
):
"""A useful early response survives later silent probes hitting the cap."""
class Clock:
now = 0.0
def monotonic(self):
return self.now
class PartlyResponsiveSession:
def __init__(self, clock):
self.clock = clock
def get(self, path, timeout=10.0):
if tuple(path) == (_UUID, 'mode', 'vs', '0'):
return 0x45, cbor2.dumps({'mode': 'Cool'})
self.clock.now += timeout
raise TimeoutError
def pace(self):
pass
clock = Clock()
monkeypatch.setattr(subdevices_module.time, 'monotonic', clock.monotonic)
resources = {
'/subdevices/vs/0': {
'x.com.samsung.da.subdeviceIdList': [_UUID],
},
'/power/vs/0': {'power': 'On'},
'/mode/vs/0': {'mode': 'Cool'},
}
found, extra = enumerate_subdevices(
PartlyResponsiveSession(clock),
resources,
oic_res_links=[],
preferred_hrefs=('/mode/vs/0',),
time_budget=7.0,
collection_timeout=4.0,
property_timeout=2.0,
)
assert [(subdevice.kind, subdevice.key) for subdevice in found] == [
('prefixed', _UUID),
]
assert found[0].flat_hrefs == ('/mode/vs/0',)
assert extra == {f'/{_UUID}/mode/vs/0': {'mode': 'Cool'}}
assert clock.now == 7.0
def test_enumerate_prefixed_flat_fallback_with_no_master_hrefs_to_probe_is_a_no_op():
"""The master itself having nothing but /subdevices/vs/0 in its own
resources this cycle (e.g. a very first, mostly-empty poll) must not