From aa55033cea1592d71e46b48a95e7da13a0ecb1fd Mon Sep 17 00:00:00 2001 From: avollkopf Date: Tue, 17 Dec 2024 20:03:39 +0100 Subject: [PATCH] fix if actor plugin is not installed and actor is still in config --- cbpi/__init__.py | 2 +- cbpi/api/dataclasses.py | 5 ++++- cbpi/controller/basic_controller2.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 938d993..25d8167 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.4.7.a1" +__version__ = "4.4.7.a2" __codename__ = "Yeast Starter" diff --git a/cbpi/api/dataclasses.py b/cbpi/api/dataclasses.py index 1c403be..704ff8b 100644 --- a/cbpi/api/dataclasses.py +++ b/cbpi/api/dataclasses.py @@ -63,7 +63,10 @@ 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): - 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: + 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) + else: + return dict(id=self.id, name=self.name, type="Not Available", props=self.props.to_dict(), state=False, power=0, timer=0) class DataType(Enum): VALUE="value" diff --git a/cbpi/controller/basic_controller2.py b/cbpi/controller/basic_controller2.py index 6a4a64f..9feda96 100644 --- a/cbpi/controller/basic_controller2.py +++ b/cbpi/controller/basic_controller2.py @@ -49,6 +49,7 @@ class BasicController: await self.start(item.id) await self.push_udpate() except Exception as e: + #logging.error(e) logging.warning("Invalid {} file - Creating empty file".format(self.path)) os.remove(self.path) with open(self.path, "w") as file: