feat(washer): add washer device registry
This commit is contained in:
1 parent
1e70380ae3
commit
779c2f9881
3 files changed
+57
-1
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from ._base import DeviceRegistry
|
from ._base import DeviceRegistry
|
||||||
from . import dishwasher, dryer, oven, refrigerator
|
from . import dishwasher, dryer, oven, refrigerator, washer
|
||||||
|
|
||||||
__all__ = ['DeviceRegistry', '_type_key', 'for_device']
|
__all__ = ['DeviceRegistry', '_type_key', 'for_device']
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ _REGISTRY_BY_KEY: dict[str, DeviceRegistry] = {
|
|||||||
'dryer': dryer.REGISTRY,
|
'dryer': dryer.REGISTRY,
|
||||||
'oven': oven.REGISTRY,
|
'oven': oven.REGISTRY,
|
||||||
'refrigerator': refrigerator.REGISTRY,
|
'refrigerator': refrigerator.REGISTRY,
|
||||||
|
'washer': washer.REGISTRY,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
]),
|
||||||
|
)
|
||||||
@@ -70,3 +70,32 @@ class TestDeviceRegistries:
|
|||||||
for cap in caps:
|
for cap in caps:
|
||||||
assert cap.rt_filter is not None or cap.match_fn is not None, \
|
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"
|
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"
|
||||||
Reference in new issue
Block a user