From 47f5e82e774209bb76637882ee51e028f1b44b3d Mon Sep 17 00:00:00 2001 From: avollkopf Date: Tue, 17 Dec 2024 21:16:52 +0100 Subject: [PATCH] adapt missing actor type in dataclass to other dataclasses --- cbpi/__init__.py | 2 +- cbpi/api/dataclasses.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 25d8167..c2c20b4 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.4.7.a2" +__version__ = "4.4.7.a3" __codename__ = "Yeast Starter" diff --git a/cbpi/api/dataclasses.py b/cbpi/api/dataclasses.py index 704ff8b..014756e 100644 --- a/cbpi/api/dataclasses.py +++ b/cbpi/api/dataclasses.py @@ -63,10 +63,13 @@ class Actor: def __str__(self): return "name={} props={}, state={}, type={}, power={}, timer={}".format(self.name, self.props, self.state, self.type, self.power, self.timer) def to_dict(self): - if self.instance: - return dict(id=self.id, name=self.name, type=self.type, props=self.props.to_dict(), state=self.instance.get_state(), power=self.power, timer=self.timer) + if self.instance is not None: + state = self.instance.get_state() + type = self.type else: - return dict(id=self.id, name=self.name, type="Not Available", props=self.props.to_dict(), state=False, power=0, timer=0) + state = False + type = "!!! MISSING TYPE !!!" + return dict(id=self.id, name=self.name, type=type, props=self.props.to_dict(), state=state, power=self.power, timer=self.timer) class DataType(Enum): VALUE="value"