Map remaining coverage-gap hrefs, fix discover() false-gap bug, improve device naming

Maps the fridge/dishwasher hrefs flagged by last session's coverage-gap
Repairs issue: defrost delay (switch) + block status (diagnostic binary
sensor), master ice-maker enable, self-check trigger/status, dishwasher
diagnosis trigger/status, and last-operation-source. Adds fallback
capabilities for /doors, /temperatures, and /icemaker/status that only
bind when the richer per-instance hrefs they duplicate are absent, so
simpler devices without those hrefs still get the data. Everything else
in the original gap list moves to capabilities.ignored (Bixby audio
feedback, inert DR/energy-planner resources, redundant metadata).

Fixes discover() reporting a known href as an unregistered gap whenever
its match_fn declined to bind for that device (e.g. a filter capability
on hardware without that filter) — it's now only a gap when no capability
is registered for the href at all.

Device naming now uses x.com.samsung.da.modelNum (not the OCF /oic/p,d
metadata, which produced inconsistent names like "[dishwasher] Samsung")
to build "Samsung <Type> (<model>)".
This commit is contained in:
Marc Billow committed 2026-07-08 15:24:34 -05:00
1 parent d2699f0f5b
commit 5d1a32aa9a
13 files changed
+279 -23

No files matched your search

+7
View File
@@ -6,16 +6,19 @@
"cycle",
"cycle_active",
"delay_start_time",
"diagnosis_status",
"energy_kwh",
"finish_time",
"firmware_update",
"heated_dry",
"job_beginning_status",
"led_brightness",
"led_night_brightness",
"led_night_end",
"led_night_light",
"led_night_start",
"machine_state",
"operation_origin",
"power_switch",
"power_watts",
"progress",
@@ -34,16 +37,20 @@
"samsung_dishwasher_cycle",
"samsung_dishwasher_cycle_active",
"samsung_dishwasher_delay_start_time",
"samsung_dishwasher_diagnosis_start",
"samsung_dishwasher_diagnosis_status",
"samsung_dishwasher_energy_kwh",
"samsung_dishwasher_finish_time",
"samsung_dishwasher_firmware_update",
"samsung_dishwasher_heated_dry",
"samsung_dishwasher_job_beginning_status",
"samsung_dishwasher_led_brightness",
"samsung_dishwasher_led_night_brightness",
"samsung_dishwasher_led_night_end",
"samsung_dishwasher_led_night_light",
"samsung_dishwasher_led_night_start",
"samsung_dishwasher_machine_state",
"samsung_dishwasher_operation_origin",
"samsung_dishwasher_pause",
"samsung_dishwasher_power_switch",
"samsung_dishwasher_power_watts",
+9
View File
@@ -10,6 +10,8 @@
"cooler_setpoint",
"cooler_temperature",
"day_brightness",
"defrost_blocked",
"defrost_delay",
"door_alert",
"door_cooler_open",
"door_freezer_open",
@@ -33,6 +35,8 @@
"rapid_freezing",
"rapid_fridge",
"sabbath_mode",
"selfcheck_result",
"selfcheck_status",
"welcome_lighting"
],
"discovery_unique_ids": [
@@ -46,6 +50,8 @@
"samsung_refrigerator_cooler_setpoint",
"samsung_refrigerator_cooler_temperature",
"samsung_refrigerator_day_brightness",
"samsung_refrigerator_defrost_blocked",
"samsung_refrigerator_defrost_delay",
"samsung_refrigerator_door_alert",
"samsung_refrigerator_door_cooler_open",
"samsung_refrigerator_door_freezer_open",
@@ -69,6 +75,9 @@
"samsung_refrigerator_rapid_freezing",
"samsung_refrigerator_rapid_fridge",
"samsung_refrigerator_sabbath_mode",
"samsung_refrigerator_selfcheck_result",
"samsung_refrigerator_selfcheck_start",
"samsung_refrigerator_selfcheck_status",
"samsung_refrigerator_welcome_lighting"
]
}
+12 -8
View File
@@ -79,30 +79,34 @@ async def test_update_failed_on_persistent_poll_error(
# Coverage-gap detection and the Repairs issue it raises
# ---------------------------------------------------------------------------
async def test_discovery_populates_device_type_and_unbound_hrefs(
async def test_discovery_populates_device_type_with_no_unbound_hrefs(
hass: HomeAssistant, mock_entry, mock_coordinator_session
) -> None:
"""The real refrigerator fixture is a recognized type with some gaps left."""
"""The real refrigerator fixture is a recognized type, fully covered.
Every href in this fixture is either mapped to a capability or listed
in capabilities.ignored — see tests/test_registry_ignored.py for the
noise-suppression checks. If this starts failing because a genuinely
new gap appeared, map it or ignore it rather than deleting the assertion.
"""
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
coordinator: LocalThingsCoordinator = hass.data[DOMAIN][mock_entry.entry_id]
assert coordinator.device_type_name == 'refrigerator'
assert coordinator.one_ui_version == '7.0 Refrigerator'
# Real, currently-unmodeled hrefs on this fixture (not noise — see
# tests/test_registry_ignored.py for the noise-suppression checks).
assert '/bespoke/vs/0' in coordinator._unbound_hrefs
assert coordinator._unbound_hrefs == []
async def test_coverage_gap_issue_created_for_real_fixture_gaps(
async def test_coverage_gap_issue_absent_for_fully_covered_real_fixture(
hass: HomeAssistant, mock_entry, mock_coordinator_session
) -> None:
"""A recognized device with leftover unbound hrefs still raises the issue."""
"""A recognized device with no unbound hrefs does not raise the issue."""
await hass.config_entries.async_setup(mock_entry.entry_id)
await hass.async_block_till_done()
issue_id = f"device_gap_{mock_entry.entry_id}"
assert ir.async_get(hass).async_get_issue(DOMAIN, issue_id) is not None
assert ir.async_get(hass).async_get_issue(DOMAIN, issue_id) is None
def test_update_coverage_gap_issue_creates_issue_for_unknown_type(
+1 -1
View File
@@ -18,7 +18,7 @@ async def test_diagnostics_shape_and_redaction(
assert diagnostics["device_type"] == 'refrigerator'
assert diagnostics["one_ui_version"] == '7.0 Refrigerator'
assert '/bespoke/vs/0' in diagnostics["unbound_hrefs"]
assert diagnostics["unbound_hrefs"] == []
assert diagnostics["integration_version"] == '0.1.0'
assert diagnostics["smartthings_local_version"]
+20
View File
@@ -138,6 +138,26 @@ def test_discover_match_fn_filters_wrong_device():
assert bound == []
def test_discover_match_fn_decline_is_not_logged_as_gap():
"""A registered href whose match_fn declines is known, not a gap.
Distinguishes "no capability registered for this href" (a real
coverage gap) from "a capability is registered but chose not to bind
for this device" (e.g. a filter capability on hardware that doesn't
have that filter) — only the former should be reported via `log`.
"""
seen = []
cap = Capability(
href='/filter/vs/0',
match_fn=lambda rep, resources: False,
entities=(BinarySensorDesc(key='filter', field='x.com.samsung.da.filterStatus'),),
)
resources = {'/filter/vs/0': {'x.com.samsung.da.filterStatus': 'notused'}}
bound = discover(resources, {'/filter/vs/0': [cap]}, log=seen.append)
assert bound == []
assert seen == []
def test_discover_rt_filter_gates_binding():
"""Cap with rt_filter must not bind a rep whose rt list does not match."""
oven_mode_cap = Capability(
+7 -6
View File
@@ -45,14 +45,15 @@ def test_ignored_hrefs_absent_from_refrigerator_gaps():
assert not present_ignored, f"ignored hrefs leaked into gap report: {present_ignored}"
def test_dishwasher_fixture_still_has_genuine_gaps():
def test_dishwasher_fixture_has_no_remaining_gaps():
"""Sanity check that the gap mechanism isn't silencing everything.
If this starts failing because the fixture is now fully covered, that's
good news — just trim the expected set down (or to empty) rather than
deleting the test.
Every href in the dishwasher fixture is now either mapped to a
capability or listed in capabilities.ignored — if this starts failing
because a genuinely new gap appeared, that's the interesting case to
look at (add the href to ignored.py or map it, don't just delete this
assertion).
"""
resources = _load('dishwasher_device.json')
unbound = set(_unbound_hrefs(resources, dishwasher.REGISTRY))
assert '/wm/jobbeginingstatus/vs/0' in unbound
assert '/diagnosis/vs/0' in unbound
assert unbound == set()