From 779c2f9881a231d248b9219c4b25cac7d62f617d Mon Sep 17 00:00:00 2001 From: Marc Billow Date: Sat, 11 Jul 2026 12:45:05 -0500 Subject: [PATCH] feat(washer): add washer device registry --- .../localthings/registry/by_type/__init__.py | 3 +- .../localthings/registry/by_type/washer.py | 26 +++++++++++++++++ tests/test_by_type.py | 29 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 custom_components/localthings/registry/by_type/washer.py diff --git a/custom_components/localthings/registry/by_type/__init__.py b/custom_components/localthings/registry/by_type/__init__.py index 97a4e38..c6049f1 100644 --- a/custom_components/localthings/registry/by_type/__init__.py +++ b/custom_components/localthings/registry/by_type/__init__.py @@ -2,7 +2,7 @@ from typing import Optional from ._base import DeviceRegistry -from . import dishwasher, dryer, oven, refrigerator +from . import dishwasher, dryer, oven, refrigerator, washer __all__ = ['DeviceRegistry', '_type_key', 'for_device'] @@ -12,6 +12,7 @@ _REGISTRY_BY_KEY: dict[str, DeviceRegistry] = { 'dryer': dryer.REGISTRY, 'oven': oven.REGISTRY, 'refrigerator': refrigerator.REGISTRY, + 'washer': washer.REGISTRY, } diff --git a/custom_components/localthings/registry/by_type/washer.py b/custom_components/localthings/registry/by_type/washer.py new file mode 100644 index 0000000..22f2f9a --- /dev/null +++ b/custom_components/localthings/registry/by_type/washer.py @@ -0,0 +1,26 @@ +"""Washer device registry.""" +from ..capabilities import common, dishwasher, fridge, ignored, operational, washer +from ._base import DeviceRegistry, _build + +REGISTRY = DeviceRegistry( + name='washer', + capabilities=_build([ + *ignored.IGNORED, + washer.POWER_GENERIC, + washer.POWER_VS_FALLBACK, + washer.KIDS_LOCK_GENERIC, + washer.KIDS_LOCK_VS_FALLBACK, + washer.REMOTE_CONTROL_GENERIC, + washer.REMOTE_CONTROL_VS_FALLBACK, + washer.WASHER_SETTINGS, + washer.WASHER_COURSE, + washer.BUZZER_SOUND, + washer.WASHER_JOB_BEGINNING_STATUS, + common.ALARMS, + common.ENERGY_METER, + common.WATER_METER, + operational.OPERATIONAL_STATE, + dishwasher.DIAGNOSIS, + fridge.FIRMWARE_UPDATE, + ]), +) diff --git a/tests/test_by_type.py b/tests/test_by_type.py index 3124beb..6dfebf0 100644 --- a/tests/test_by_type.py +++ b/tests/test_by_type.py @@ -70,3 +70,32 @@ class TestDeviceRegistries: for cap in caps: assert cap.rt_filter is not None or cap.match_fn is not None, \ f"href {href!r} has multiple caps but {cap!r} lacks rt_filter and match_fn" + + +class TestWasherRegistry: + def test_washer_registry_registered(self): + from custom_components.localthings.registry.by_type import _REGISTRY_BY_KEY + assert 'washer' in _REGISTRY_BY_KEY + assert _REGISTRY_BY_KEY['washer'].name == 'washer' + + def test_washer_registry_has_no_dup_hrefs(self): + from custom_components.localthings.registry.by_type import _REGISTRY_BY_KEY + registry = _REGISTRY_BY_KEY['washer'] + for href, caps in registry.capabilities.items(): + if len(caps) > 1: + for cap in caps: + assert cap.rt_filter is not None or cap.match_fn is not None, \ + f"href {href!r} has multiple caps but {cap!r} lacks rt_filter and match_fn" + + def test_washer_registry_covers_known_hrefs(self): + from custom_components.localthings.registry.by_type import _REGISTRY_BY_KEY + registry = _REGISTRY_BY_KEY['washer'] + for href in ( + '/power/0', '/power/vs/0', '/kidslock/0', '/kidslock/vs/0', + '/remotectrl/0', '/remotectrl/vs/0', '/alarms/vs/0', + '/energy/consumption/vs/0', '/water/consumption/vs/0', + '/operational/state/vs/0', '/washer/vs/0', '/course/vs/0', + '/buzzersound/vs/0', '/wm/jobbeginingstatus/vs/0', + '/diagnosis/vs/0', '/otninformation/vs/0', + ): + assert href in registry.capabilities, f"{href} missing from washer registry"