From f12df2eace85a0e44fa1516be3f0fee725f07946 Mon Sep 17 00:00:00 2001 From: Tobias Sauerwein Date: Sat, 21 Oct 2023 22:39:36 +0200 Subject: [PATCH] Add test for missing device type --- src/pyatmo/modules/device_types.py | 3 --- src/pyatmo/modules/module.py | 6 +----- tests/test_pyatmo_refactor.py | 7 +++++++ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pyatmo/modules/device_types.py b/src/pyatmo/modules/device_types.py index 042dfbfa..7c823c84 100644 --- a/src/pyatmo/modules/device_types.py +++ b/src/pyatmo/modules/device_types.py @@ -15,9 +15,6 @@ class DeviceType(str, Enum): # temporarily disable locally-disabled and locally-enabled # pylint: disable=C0103 - # Unknown - UNKNOWN = "UNKNOWN" - # Climate/Energy NAPlug = "NAPlug" # Smart thermostat gateway NATherm1 = "NATherm1" # Smart thermostat diff --git a/src/pyatmo/modules/module.py b/src/pyatmo/modules/module.py index 0e52befc..95a94713 100644 --- a/src/pyatmo/modules/module.py +++ b/src/pyatmo/modules/module.py @@ -660,11 +660,7 @@ def __init__(self, home: Home, module: ModuleT) -> None: super().__init__(module) - try: - self.device_type = DeviceType(module["type"]) - except ValueError: - LOG.error("Unknown device type %s", module["type"]) - self.device_type = DeviceType.UNKNOWN + self.device_type = DeviceType(module["type"]) self.home = home self.room_id = module.get("room_id") diff --git a/tests/test_pyatmo_refactor.py b/tests/test_pyatmo_refactor.py index 05c0c885..956f5cb7 100644 --- a/tests/test_pyatmo_refactor.py +++ b/tests/test_pyatmo_refactor.py @@ -1128,3 +1128,10 @@ async def test_historical_data_retrieval(async_account): "endTime": "2022-02-12T08:29:49Z", } assert len(module.historical_data) == 168 + + +def test_device_types_missing(): + """Test handling of missing device types.""" + + assert DeviceType("NOC") == DeviceType.NOC + assert DeviceType("UNKNOWN") == DeviceType.NLunknown