From ff6e1ecff4d8ef7cbbf4a1845a6a31f7dea59a9f Mon Sep 17 00:00:00 2001 From: Marc Billow Date: Mon, 27 Jul 2026 03:56:26 +0000 Subject: [PATCH] Rename gas cooktop registry's display name to avoid induction_cooktop confusion Renames DeviceRegistry.name from 'cooktop' to 'gas_cooktop' for the NA9300K-class gas-cooktop registry (PR #23), so diagnostics/device-info labels no longer collide with the unrelated induction_cooktop family (issue #86) -- two different OCF surfaces that happen to share the English word "cooktop". Safe rename: _REGISTRY_BY_KEY's 'cooktop' lookup key is unchanged, so all three existing detection paths (oneUiVersion "Cooktop" exact match, the legacy ARTIK051 modelNum rule, and the resource-signature fallback) keep routing real devices exactly as before. Entity unique_ids are built from device serial + entity key, not registry name, so existing entities are unaffected. Only the DeviceInfo.name and diagnostics device_type strings change, both cosmetic. --- README.md | 2 +- .../localthings/registry/by_type/cooktop.py | 14 ++++++++++++-- tests/localthings/test_coordinator.py | 2 +- tests/test_by_type.py | 9 ++++++--- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ae2dbe7..731cfcd 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Your state stays on your LAN: HA talks to the appliance over a direct DTLS sessi | Air purifier | `by_type/air_purifier.py` | | Dryer | `by_type/dryer.py` | | Oven | `by_type/oven.py` | -| Cooktop (read-only burner status) | `by_type/cooktop.py` | +| Gas cooktop (read-only burner status) | `by_type/cooktop.py` | | Range hood | `by_type/range_hood.py` | | Range | `by_type/range.py` | | Dishwasher | `by_type/dishwasher.py` | diff --git a/custom_components/localthings/registry/by_type/cooktop.py b/custom_components/localthings/registry/by_type/cooktop.py index 08084d9..91fc189 100644 --- a/custom_components/localthings/registry/by_type/cooktop.py +++ b/custom_components/localthings/registry/by_type/cooktop.py @@ -1,11 +1,21 @@ -"""Cooktop device registry.""" +"""Gas cooktop device registry (NA9300K-class, PR #23). + +Named 'gas_cooktop' (not 'cooktop') so its diagnostics/device-info label +doesn't collide with the unrelated induction_cooktop family (issue #86, +by_type/induction_cooktop.py) -- two different OCF surfaces that happen to +share the English word "cooktop". The `_REGISTRY_BY_KEY['cooktop']` lookup +key is unchanged: it's relied on by real devices reporting +oneUiVersion "Cooktop" (for_device), the legacy ARTIK051 modelNum rule +(for_device_by_model), and the resource-signature fallback +(for_device_by_resources) alike. +""" from ..capabilities import common, cooktop, ignored from ._base import DeviceRegistry, _build REGISTRY = DeviceRegistry( - name='cooktop', + name='gas_cooktop', capabilities=_build([ *ignored.IGNORED, cooktop.COOKTOP_POWER, diff --git a/tests/localthings/test_coordinator.py b/tests/localthings/test_coordinator.py index a6abccd..cac35f6 100644 --- a/tests/localthings/test_coordinator.py +++ b/tests/localthings/test_coordinator.py @@ -169,7 +169,7 @@ def test_run_discovery_detects_cooktop_via_resource_signature( coordinator = LocalThingsCoordinator(hass, mock_entry) coordinator._run_discovery(_load_device('cooktop')) - assert coordinator.device_type_name == 'cooktop' + assert coordinator.device_type_name == 'gas_cooktop' assert coordinator._unbound_hrefs == [] diff --git a/tests/test_by_type.py b/tests/test_by_type.py index b8216ca..b64ee71 100644 --- a/tests/test_by_type.py +++ b/tests/test_by_type.py @@ -42,9 +42,12 @@ class TestForDevice: assert registry.name == 'refrigerator' def test_for_device_returns_cooktop_registry(self): + """The registry's own .name is 'gas_cooktop' (disambiguated from + induction_cooktop), but the lookup key devices route through stays + 'cooktop' -- oneUiVersion "Cooktop" still resolves here.""" registry = for_device('7.0 Cooktop') assert registry is not None - assert registry.name == 'cooktop' + assert registry.name == 'gas_cooktop' def test_for_device_returns_range_hood_registry(self): registry = for_device('7.0 Range Hood') @@ -258,7 +261,7 @@ class TestForDeviceByModel: 'ARTIK051_GLOBAL_COOKTOP', ) assert reg is not None - assert reg.name == 'cooktop' + assert reg.name == 'gas_cooktop' def test_range_hood_via_ahd_model(self): from custom_components.localthings.registry.by_type import for_device_by_model @@ -319,7 +322,7 @@ class TestForDeviceByResources: reg = for_device_by_resources(_load_device('cooktop')) assert reg is not None - assert reg.name == 'cooktop' + assert reg.name == 'gas_cooktop' def test_unrelated_mode_options_are_not_cooktop(self): from custom_components.localthings.registry.by_type import for_device_by_resources