fix if actor plugin is not installed and actor is still in config

This commit is contained in:
avollkopf 2024-12-17 20:03:39 +01:00
parent 5d66521cd5
commit aa55033cea
3 changed files with 6 additions and 2 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.4.7.a1" __version__ = "4.4.7.a2"
__codename__ = "Yeast Starter" __codename__ = "Yeast Starter"

View file

@ -63,7 +63,10 @@ class Actor:
def __str__(self): def __str__(self):
return "name={} props={}, state={}, type={}, power={}, timer={}".format(self.name, self.props, self.state, self.type, self.power, self.timer) return "name={} props={}, state={}, type={}, power={}, timer={}".format(self.name, self.props, self.state, self.type, self.power, self.timer)
def to_dict(self): 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): class DataType(Enum):
VALUE="value" VALUE="value"

View file

@ -49,6 +49,7 @@ class BasicController:
await self.start(item.id) await self.start(item.id)
await self.push_udpate() await self.push_udpate()
except Exception as e: except Exception as e:
#logging.error(e)
logging.warning("Invalid {} file - Creating empty file".format(self.path)) logging.warning("Invalid {} file - Creating empty file".format(self.path))
os.remove(self.path) os.remove(self.path)
with open(self.path, "w") as file: with open(self.path, "w") as file: