From 153a2a0eed96482f0c48e8cc7c322dc6664c1ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Maccagnoni?= Date: Sat, 20 May 2023 21:10:57 +0200 Subject: [PATCH] have a Default class for unknown Calaos IOs (so that we can test that a device is unknown specifically, which cannot be done when it directly uses the Item class) --- pycalaos/item/__init__.py | 5 ++--- pycalaos/item/common.py | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pycalaos/item/__init__.py b/pycalaos/item/__init__.py index 378e997..f291e0f 100644 --- a/pycalaos/item/__init__.py +++ b/pycalaos/item/__init__.py @@ -1,7 +1,6 @@ import logging -from .common import Item - +from .common import Default from . import io _LOGGER = logging.getLogger(__name__) @@ -32,4 +31,4 @@ def new_item(data, room, conn): return types[data["type"]](data, room, conn) except: _LOGGER.error(f"Unknown Calaos item type, using generic item for: {data}") - return Item(data, room, conn) + return Default(data, room, conn) diff --git a/pycalaos/item/common.py b/pycalaos/item/common.py index d13f2f7..2ef3f0a 100644 --- a/pycalaos/item/common.py +++ b/pycalaos/item/common.py @@ -121,3 +121,7 @@ def _update_state(self): def _translate(self, state): return state + + +class Default(Item): + pass