TP1X_DA-KS-COOKTOP-01011 (NV8500T-/KO4) is the same board family and /cooktop/status/vs/0 resource shape as issue #44's range combo, minus the oven -- but its modelNum uses the hyphenated '-COOKTOP-' token, which for_device_by_model's existing '_COOKTOP' check (underscore- delimited, matching the unrelated NA9300K gas-cooktop family in cooktop.py) doesn't match. The device fell back to 'unknown' with only energy/alarms from the global fallback. Add the hyphenated token check, routing to a new 'induction_cooktop' registry (by_type/induction_cooktop.py) that reuses range.py's COOKTOP_STATUS/COOKTOP_SPEC/COOKTOP_SAFETY/PROBE_STATUS and cooktop.PAIRED_HOOD_STATUS wholesale rather than pulling in range.py's oven capabilities, which this device has no hrefs for at all. Along the way, three fields the reporter asked for turned out to be gaps in the shared range.py capability itself, not just missing routing -- also present (and previously unmodeled) on issue #44's original combo-range dump: - /cooktop/status/vs/0's own `power` and `childLock` fields (distinct from common.POWER's /power/0 or /power/vs/0, which a combo range additionally carries for the whole appliance) -- childLock gets a write_fn (a safe lock toggle, direct single-field PUT), power stays read-only (no live device to confirm a remote write wouldn't leave a burner active unattended). - Each burner's `panDetection` field. New: a Bluetooth meat-probe capability for /bluetooth/probe/status/vs/0 (read-only -- connection, battery, current/target temperature), and /cooktop/recipe/status/vs/0 is ignored (every field empty on this idle dump, same treatment as the microwave family's /recipe/cook/vs/0). Regenerates the range golden fixture (gains cooktop_power/ cooktop_child_lock/burner_N_pan_detected) and adds a dedicated fixture for the standalone cooktop.
66 lines
2.3 KiB
Python
66 lines
2.3 KiB
Python
"""Tests for the standalone induction-cooktop registry (issue #86)."""
|
|
from custom_components.localthings.registry.adapter import flatten
|
|
from custom_components.localthings.registry.by_type import for_device_by_model, induction_cooktop
|
|
from custom_components.localthings.registry.discovery import discover
|
|
|
|
from tests.conftest import _load_device
|
|
|
|
|
|
def _cooktop():
|
|
resources = _load_device('induction_cooktop')
|
|
info = resources['/information/vs/0']
|
|
reg = for_device_by_model(
|
|
info['x.com.samsung.da.modelNum'], info['x.com.samsung.da.description'],
|
|
)
|
|
return reg, resources
|
|
|
|
|
|
def _state():
|
|
reg, resources = _cooktop()
|
|
bound = discover(resources, reg.capabilities, reg.pattern_capabilities)
|
|
return flatten(bound, resources)
|
|
|
|
|
|
def test_model_resolves_to_induction_cooktop_registry():
|
|
reg, _ = _cooktop()
|
|
assert reg is not None and reg.name == 'induction_cooktop'
|
|
assert reg is induction_cooktop.REGISTRY
|
|
|
|
|
|
def test_no_unbound_hrefs():
|
|
"""Every resource in the issue #86 dump binds or is ignored -- clears
|
|
the coverage-gap repair."""
|
|
reg, resources = _cooktop()
|
|
unbound = []
|
|
discover(resources, reg.capabilities, reg.pattern_capabilities, log=unbound.append)
|
|
assert unbound == []
|
|
|
|
|
|
def test_expected_entities_present():
|
|
state = _state()
|
|
for key in (
|
|
'cooktop_state', 'cooktop_power', 'cooktop_child_lock',
|
|
'burner_0_power_level', 'burner_0_state', 'burner_0_hot_surface',
|
|
'burner_0_pan_detected', 'burner_2_pan_detected',
|
|
'paired_hood_connected', 'probe_connected', 'probe_temperature',
|
|
'energy_kwh', 'alarm_code',
|
|
):
|
|
assert key in state, key
|
|
|
|
|
|
def test_unreported_burners_gated_out():
|
|
"""Dump reports numberOfBurners=3 (indices 0-2) -- burner slot 3+ of
|
|
range.MAX_BURNERS must not appear as entities."""
|
|
state = _state()
|
|
assert 'burner_3_power_level' not in state
|
|
|
|
|
|
def test_recipe_status_href_is_ignored_not_unbound():
|
|
"""/cooktop/recipe/status/vs/0 is idle/empty on this dump -- covered by
|
|
ignored.py, not modeled as an entity (same treatment as the microwave
|
|
family's /recipe/cook/vs/0)."""
|
|
reg, _ = _cooktop()
|
|
ignored_hrefs = {cap.href for caps in reg.capabilities.values() for cap in caps
|
|
if cap.entities == ()}
|
|
assert '/cooktop/recipe/status/vs/0' in ignored_hrefs
|