diff --git a/.gitignore b/.gitignore index 2b30892..ee1c255 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ certs/ *.key # Exception: bundled Samsung OCF Root CA (public cert, no key material) -!samsung_appliance/ocf_root_ca.pem +!custom_components/localthings/ocf/ocf_root_ca.pem token.txt # Python artifacts diff --git a/custom_components/localthings/binary_sensor.py b/custom_components/localthings/binary_sensor.py index 88c38f8..e390a59 100644 --- a/custom_components/localthings/binary_sensor.py +++ b/custom_components/localthings/binary_sensor.py @@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from samsung_appliance.registry.entities import BinarySensorDesc +from .ocf.registry.entities import BinarySensorDesc from .const import DOMAIN from .coordinator import LocalThingsCoordinator diff --git a/custom_components/localthings/config_flow.py b/custom_components/localthings/config_flow.py index 804470e..d892bf4 100644 --- a/custom_components/localthings/config_flow.py +++ b/custom_components/localthings/config_flow.py @@ -26,8 +26,8 @@ def _probe_and_validate(host: str, cert_pem: str, key_pem: str) -> dict: to a temp-file pair and cleaned up in the finally block. """ import cbor2 - from samsung_appliance.coap_dtls import DtlsCoapSession - from samsung_appliance.batch import parse_device0_batch + from .ocf.coap_dtls import DtlsCoapSession + from .ocf.batch import parse_device0_batch # Write PEM strings to temporary files — DtlsCoapSession requires # cert_path / key_path rather than in-memory PEM strings. diff --git a/custom_components/localthings/coordinator.py b/custom_components/localthings/coordinator.py index ad65b64..64312f6 100644 --- a/custom_components/localthings/coordinator.py +++ b/custom_components/localthings/coordinator.py @@ -14,13 +14,13 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed from homeassistant.helpers.device_registry import DeviceInfo -from samsung_appliance.batch import parse_device0_batch -from samsung_appliance.coap_dtls import DtlsCoapSession -from samsung_appliance.registry.by_type import for_device -from samsung_appliance.registry.discovery import discover, BoundEntity -from samsung_appliance.registry import CAPABILITIES -from samsung_appliance.registry.adapter import flatten, is_active -from samsung_appliance.registry.identity import read_identity, DeviceIdentity +from .ocf.batch import parse_device0_batch +from .ocf.coap_dtls import DtlsCoapSession +from .ocf.registry.by_type import for_device +from .ocf.registry.discovery import discover, BoundEntity +from .ocf.registry import CAPABILITIES +from .ocf.registry.adapter import flatten, is_active +from .ocf.registry.identity import read_identity, DeviceIdentity from .const import ( DOMAIN, CONF_HOST, CONF_PORT, CONF_CERT_PEM, CONF_KEY_PEM, diff --git a/custom_components/localthings/entity.py b/custom_components/localthings/entity.py index 326ff51..84fd250 100644 --- a/custom_components/localthings/entity.py +++ b/custom_components/localthings/entity.py @@ -4,8 +4,8 @@ from __future__ import annotations from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.device_registry import DeviceInfo -from samsung_appliance.registry.adapter import _key -from samsung_appliance.registry.discovery import BoundEntity +from .ocf.registry.adapter import _key +from .ocf.registry.discovery import BoundEntity from .const import DOMAIN from .coordinator import LocalThingsCoordinator diff --git a/custom_components/localthings/number.py b/custom_components/localthings/number.py index 73bda23..90e0b56 100644 --- a/custom_components/localthings/number.py +++ b/custom_components/localthings/number.py @@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from samsung_appliance.registry.entities import NumberDesc +from .ocf.registry.entities import NumberDesc from .const import DOMAIN from .coordinator import LocalThingsCoordinator diff --git a/samsung_appliance/__init__.py b/custom_components/localthings/ocf/__init__.py similarity index 68% rename from samsung_appliance/__init__.py rename to custom_components/localthings/ocf/__init__.py index debc576..c134506 100644 --- a/samsung_appliance/__init__.py +++ b/custom_components/localthings/ocf/__init__.py @@ -1,4 +1,4 @@ -"""Samsung appliance local-API library. +"""Samsung appliance local-API library (custom_components/localthings/ocf). CoAP/DTLS session management, OCF batch resource parsing, and a capability registry for discovering and reading Samsung appliance state.""" diff --git a/samsung_appliance/batch.py b/custom_components/localthings/ocf/batch.py similarity index 100% rename from samsung_appliance/batch.py rename to custom_components/localthings/ocf/batch.py diff --git a/samsung_appliance/coap_dtls.py b/custom_components/localthings/ocf/coap_dtls.py similarity index 100% rename from samsung_appliance/coap_dtls.py rename to custom_components/localthings/ocf/coap_dtls.py diff --git a/samsung_appliance/observe_refresh.py b/custom_components/localthings/ocf/observe_refresh.py similarity index 100% rename from samsung_appliance/observe_refresh.py rename to custom_components/localthings/ocf/observe_refresh.py diff --git a/samsung_appliance/ocf_root_ca.pem b/custom_components/localthings/ocf/ocf_root_ca.pem similarity index 100% rename from samsung_appliance/ocf_root_ca.pem rename to custom_components/localthings/ocf/ocf_root_ca.pem diff --git a/samsung_appliance/registry/__init__.py b/custom_components/localthings/ocf/registry/__init__.py similarity index 100% rename from samsung_appliance/registry/__init__.py rename to custom_components/localthings/ocf/registry/__init__.py diff --git a/samsung_appliance/registry/adapter.py b/custom_components/localthings/ocf/registry/adapter.py similarity index 100% rename from samsung_appliance/registry/adapter.py rename to custom_components/localthings/ocf/registry/adapter.py diff --git a/samsung_appliance/registry/by_type/__init__.py b/custom_components/localthings/ocf/registry/by_type/__init__.py similarity index 100% rename from samsung_appliance/registry/by_type/__init__.py rename to custom_components/localthings/ocf/registry/by_type/__init__.py diff --git a/samsung_appliance/registry/by_type/_base.py b/custom_components/localthings/ocf/registry/by_type/_base.py similarity index 100% rename from samsung_appliance/registry/by_type/_base.py rename to custom_components/localthings/ocf/registry/by_type/_base.py diff --git a/samsung_appliance/registry/by_type/dishwasher.py b/custom_components/localthings/ocf/registry/by_type/dishwasher.py similarity index 100% rename from samsung_appliance/registry/by_type/dishwasher.py rename to custom_components/localthings/ocf/registry/by_type/dishwasher.py diff --git a/samsung_appliance/registry/by_type/dryer.py b/custom_components/localthings/ocf/registry/by_type/dryer.py similarity index 100% rename from samsung_appliance/registry/by_type/dryer.py rename to custom_components/localthings/ocf/registry/by_type/dryer.py diff --git a/samsung_appliance/registry/by_type/oven.py b/custom_components/localthings/ocf/registry/by_type/oven.py similarity index 100% rename from samsung_appliance/registry/by_type/oven.py rename to custom_components/localthings/ocf/registry/by_type/oven.py diff --git a/samsung_appliance/registry/by_type/refrigerator.py b/custom_components/localthings/ocf/registry/by_type/refrigerator.py similarity index 100% rename from samsung_appliance/registry/by_type/refrigerator.py rename to custom_components/localthings/ocf/registry/by_type/refrigerator.py diff --git a/samsung_appliance/registry/capabilities/__init__.py b/custom_components/localthings/ocf/registry/capabilities/__init__.py similarity index 100% rename from samsung_appliance/registry/capabilities/__init__.py rename to custom_components/localthings/ocf/registry/capabilities/__init__.py diff --git a/samsung_appliance/registry/capabilities/common.py b/custom_components/localthings/ocf/registry/capabilities/common.py similarity index 100% rename from samsung_appliance/registry/capabilities/common.py rename to custom_components/localthings/ocf/registry/capabilities/common.py diff --git a/samsung_appliance/registry/capabilities/dryer.py b/custom_components/localthings/ocf/registry/capabilities/dryer.py similarity index 100% rename from samsung_appliance/registry/capabilities/dryer.py rename to custom_components/localthings/ocf/registry/capabilities/dryer.py diff --git a/samsung_appliance/registry/capabilities/fridge.py b/custom_components/localthings/ocf/registry/capabilities/fridge.py similarity index 100% rename from samsung_appliance/registry/capabilities/fridge.py rename to custom_components/localthings/ocf/registry/capabilities/fridge.py diff --git a/samsung_appliance/registry/capabilities/laundry.py b/custom_components/localthings/ocf/registry/capabilities/laundry.py similarity index 100% rename from samsung_appliance/registry/capabilities/laundry.py rename to custom_components/localthings/ocf/registry/capabilities/laundry.py diff --git a/samsung_appliance/registry/capabilities/operational.py b/custom_components/localthings/ocf/registry/capabilities/operational.py similarity index 100% rename from samsung_appliance/registry/capabilities/operational.py rename to custom_components/localthings/ocf/registry/capabilities/operational.py diff --git a/samsung_appliance/registry/capabilities/oven.py b/custom_components/localthings/ocf/registry/capabilities/oven.py similarity index 100% rename from samsung_appliance/registry/capabilities/oven.py rename to custom_components/localthings/ocf/registry/capabilities/oven.py diff --git a/samsung_appliance/registry/capability.py b/custom_components/localthings/ocf/registry/capability.py similarity index 100% rename from samsung_appliance/registry/capability.py rename to custom_components/localthings/ocf/registry/capability.py diff --git a/samsung_appliance/registry/discovery.py b/custom_components/localthings/ocf/registry/discovery.py similarity index 100% rename from samsung_appliance/registry/discovery.py rename to custom_components/localthings/ocf/registry/discovery.py diff --git a/samsung_appliance/registry/entities.py b/custom_components/localthings/ocf/registry/entities.py similarity index 100% rename from samsung_appliance/registry/entities.py rename to custom_components/localthings/ocf/registry/entities.py diff --git a/samsung_appliance/registry/identity.py b/custom_components/localthings/ocf/registry/identity.py similarity index 100% rename from samsung_appliance/registry/identity.py rename to custom_components/localthings/ocf/registry/identity.py diff --git a/samsung_appliance/registry/registry.py b/custom_components/localthings/ocf/registry/registry.py similarity index 100% rename from samsung_appliance/registry/registry.py rename to custom_components/localthings/ocf/registry/registry.py diff --git a/custom_components/localthings/select.py b/custom_components/localthings/select.py index e7e31b8..8444c48 100644 --- a/custom_components/localthings/select.py +++ b/custom_components/localthings/select.py @@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from samsung_appliance.registry.entities import SelectDesc +from .ocf.registry.entities import SelectDesc from .const import DOMAIN from .coordinator import LocalThingsCoordinator diff --git a/custom_components/localthings/sensor.py b/custom_components/localthings/sensor.py index fed4f74..b9c6dde 100644 --- a/custom_components/localthings/sensor.py +++ b/custom_components/localthings/sensor.py @@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from samsung_appliance.registry.entities import SensorDesc +from .ocf.registry.entities import SensorDesc from .const import DOMAIN from .coordinator import LocalThingsCoordinator diff --git a/custom_components/localthings/switch.py b/custom_components/localthings/switch.py index 927dcf8..173d546 100644 --- a/custom_components/localthings/switch.py +++ b/custom_components/localthings/switch.py @@ -6,7 +6,7 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback -from samsung_appliance.registry.entities import SwitchDesc +from .ocf.registry.entities import SwitchDesc from .const import DOMAIN from .coordinator import LocalThingsCoordinator diff --git a/tests/conftest.py b/tests/conftest.py index f14036f..a002b56 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -7,7 +7,7 @@ FIXTURES = Path(__file__).resolve().parent / 'fixtures' def _resources_from_dump(dump: dict) -> dict[str, dict]: - from samsung_appliance.batch import parse_device0_batch + from custom_components.localthings.ocf.batch import parse_device0_batch return parse_device0_batch(dump['device0']) diff --git a/tests/localthings/conftest.py b/tests/localthings/conftest.py index d98a3e6..d979e14 100644 --- a/tests/localthings/conftest.py +++ b/tests/localthings/conftest.py @@ -52,7 +52,7 @@ ENTRY_DATA = { def _load_fridge_resources() -> dict: - from samsung_appliance.batch import parse_device0_batch + from custom_components.localthings.ocf.batch import parse_device0_batch data = json.loads((FIXTURES / 'refrigerator_device.json').read_text()) return parse_device0_batch(data['device0']) diff --git a/tests/test_by_type.py b/tests/test_by_type.py index c50671d..c41e558 100644 --- a/tests/test_by_type.py +++ b/tests/test_by_type.py @@ -1,6 +1,6 @@ """Tests for samsung_appliance/registry/by_type.""" import pytest -from samsung_appliance.registry.by_type import _type_key, for_device, DeviceRegistry +from custom_components.localthings.ocf.registry.by_type import _type_key, for_device, DeviceRegistry class TestTypeKey: diff --git a/tests/test_by_type_capabilities.py b/tests/test_by_type_capabilities.py index 1d9ad29..f8f399b 100644 --- a/tests/test_by_type_capabilities.py +++ b/tests/test_by_type_capabilities.py @@ -4,10 +4,10 @@ from pathlib import Path import pytest -from samsung_appliance.registry.adapter import _key -from samsung_appliance.registry.by_type import dishwasher, refrigerator -from samsung_appliance.registry.capabilities import fridge -from samsung_appliance.registry.discovery import discover +from custom_components.localthings.ocf.registry.adapter import _key +from custom_components.localthings.ocf.registry.by_type import dishwasher, refrigerator +from custom_components.localthings.ocf.registry.capabilities import fridge +from custom_components.localthings.ocf.registry.discovery import discover from tests.conftest import _load_resources GOLDEN = Path(__file__).parent / 'fixtures' / 'golden' diff --git a/tests/test_capability.py b/tests/test_capability.py index 70bcab4..a1c2fcf 100644 --- a/tests/test_capability.py +++ b/tests/test_capability.py @@ -1,5 +1,5 @@ -from samsung_appliance.registry.capability import Capability -from samsung_appliance.registry.entities import BinarySensorDesc +from custom_components.localthings.ocf.registry.capability import Capability +from custom_components.localthings.ocf.registry.entities import BinarySensorDesc def test_capability_defaults(): diff --git a/tests/test_common_capabilities.py b/tests/test_common_capabilities.py index 7ea21bd..2735801 100644 --- a/tests/test_common_capabilities.py +++ b/tests/test_common_capabilities.py @@ -1,5 +1,5 @@ -from samsung_appliance.registry.capabilities import common -from samsung_appliance.registry.discovery import discover +from custom_components.localthings.ocf.registry.capabilities import common +from custom_components.localthings.ocf.registry.discovery import discover def _reg(): diff --git a/tests/test_discovery.py b/tests/test_discovery.py index cfbf0c7..10b99e6 100644 --- a/tests/test_discovery.py +++ b/tests/test_discovery.py @@ -1,8 +1,8 @@ -from samsung_appliance.registry.capability import Capability -from samsung_appliance.registry.discovery import ( +from custom_components.localthings.ocf.registry.capability import Capability +from custom_components.localthings.ocf.registry.discovery import ( BoundEntity, discover, instance_suffix, ) -from samsung_appliance.registry.entities import BinarySensorDesc +from custom_components.localthings.ocf.registry.entities import BinarySensorDesc LOCK = Capability( href='/kidslock/vs/0', diff --git a/tests/test_end_to_end_v2.py b/tests/test_end_to_end_v2.py index 15fb373..e5a9517 100644 --- a/tests/test_end_to_end_v2.py +++ b/tests/test_end_to_end_v2.py @@ -1,8 +1,8 @@ import pytest from tests.conftest import _load_device -from samsung_appliance.registry.by_type import for_device, _type_key -from samsung_appliance.registry.discovery import discover -from samsung_appliance.registry.adapter import flatten, is_active +from custom_components.localthings.ocf.registry.by_type import for_device, _type_key +from custom_components.localthings.ocf.registry.discovery import discover +from custom_components.localthings.ocf.registry.adapter import flatten, is_active @pytest.mark.parametrize('name,expected_type_key', [ diff --git a/tests/test_entities.py b/tests/test_entities.py index 0a937a1..1b8f768 100644 --- a/tests/test_entities.py +++ b/tests/test_entities.py @@ -1,4 +1,4 @@ -from samsung_appliance.registry.entities import ( +from custom_components.localthings.ocf.registry.entities import ( SensorDesc, BinarySensorDesc, SelectDesc, SwitchDesc, ButtonDesc, NumberDesc, PLATFORM_OF, ) diff --git a/tests/test_fridge_multi_instance.py b/tests/test_fridge_multi_instance.py index 01244ae..4c7af69 100644 --- a/tests/test_fridge_multi_instance.py +++ b/tests/test_fridge_multi_instance.py @@ -7,9 +7,9 @@ pattern capability that auto-derives distinct keys from the href segments. """ from tests.conftest import _load_resources -from samsung_appliance.registry.adapter import _key -from samsung_appliance.registry.by_type import refrigerator -from samsung_appliance.registry.discovery import discover +from custom_components.localthings.ocf.registry.adapter import _key +from custom_components.localthings.ocf.registry.by_type import refrigerator +from custom_components.localthings.ocf.registry.discovery import discover def test_two_doors_get_distinct_keys(): diff --git a/tests/test_golden_regression.py b/tests/test_golden_regression.py index a5a1412..8f81d57 100644 --- a/tests/test_golden_regression.py +++ b/tests/test_golden_regression.py @@ -7,14 +7,14 @@ GOLDEN = Path(__file__).parent / 'fixtures' / 'golden' def _new_state_keys(name, resources): - from samsung_appliance.registry.by_type import for_device - from samsung_appliance.registry.discovery import discover - from samsung_appliance.registry.adapter import flatten + from custom_components.localthings.ocf.registry.by_type import for_device + from custom_components.localthings.ocf.registry.discovery import discover + from custom_components.localthings.ocf.registry.adapter import flatten otn = resources.get('/otninformation/vs/0', {}) one_ui = otn.get('swVersionInfo', {}).get('oneUiVersion', '') reg = for_device(one_ui) if one_ui else None if reg is None: - from samsung_appliance.registry.registry import CAPABILITIES + from custom_components.localthings.ocf.registry.registry import CAPABILITIES caps, pats = CAPABILITIES, [] else: caps, pats = reg.capabilities, reg.pattern_capabilities diff --git a/tests/test_identity.py b/tests/test_identity.py index a60e7fd..d869817 100644 --- a/tests/test_identity.py +++ b/tests/test_identity.py @@ -1,6 +1,6 @@ import cbor2 -from samsung_appliance.registry.identity import DeviceIdentity, read_identity +from custom_components.localthings.ocf.registry.identity import DeviceIdentity, read_identity class FakeSession: diff --git a/tests/test_laundry_writes.py b/tests/test_laundry_writes.py index 5da9d9f..5d83966 100644 --- a/tests/test_laundry_writes.py +++ b/tests/test_laundry_writes.py @@ -1,6 +1,6 @@ """Write-handler unit tests for laundry-family capabilities.""" -from samsung_appliance.registry.capabilities import laundry -from samsung_appliance.registry.capabilities.operational import OPERATIONAL_STATE +from custom_components.localthings.ocf.registry.capabilities import laundry +from custom_components.localthings.ocf.registry.capabilities.operational import OPERATIONAL_STATE def test_start_button_writes_run(): diff --git a/tests/test_operational_capability.py b/tests/test_operational_capability.py index a30de96..2433b42 100644 --- a/tests/test_operational_capability.py +++ b/tests/test_operational_capability.py @@ -1,5 +1,5 @@ import time -from samsung_appliance.registry.capabilities.operational import OPERATIONAL_STATE +from custom_components.localthings.ocf.registry.capabilities.operational import OPERATIONAL_STATE def test_machine_state_maps_samsung_to_ocf(): diff --git a/tests/test_oven_capabilities.py b/tests/test_oven_capabilities.py index df4b737..b69c080 100644 --- a/tests/test_oven_capabilities.py +++ b/tests/test_oven_capabilities.py @@ -1,6 +1,6 @@ """Unit tests for oven-family capabilities.""" -from samsung_appliance.registry.capabilities import oven -from samsung_appliance.registry.discovery import discover +from custom_components.localthings.ocf.registry.capabilities import oven +from custom_components.localthings.ocf.registry.discovery import discover # --------------------------------------------------------------------------- diff --git a/tests/test_registry.py b/tests/test_registry.py index b4aa6f6..69cc9ba 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -1,5 +1,5 @@ """Tests for the CAPABILITIES registry.""" -from samsung_appliance.registry.registry import CAPABILITIES +from custom_components.localthings.ocf.registry.registry import CAPABILITIES def test_registry_is_keyed_by_href():