From e2bf72bbce93115b40135a601602419cd190a2a7 Mon Sep 17 00:00:00 2001 From: avollkopf Date: Wed, 18 Dec 2024 20:01:01 +0100 Subject: [PATCH] Add notifications if sensors,, actors,... can't be started --- cbpi/__init__.py | 2 +- cbpi/api/dataclasses.py | 2 +- cbpi/controller/basic_controller2.py | 6 ++++-- cbpi/controller/upload_controller.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index c2c20b4..b9bd64c 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.4.7.a3" +__version__ = "4.4.7.a4" __codename__ = "Yeast Starter" diff --git a/cbpi/api/dataclasses.py b/cbpi/api/dataclasses.py index c0bf08e..4515012 100644 --- a/cbpi/api/dataclasses.py +++ b/cbpi/api/dataclasses.py @@ -68,7 +68,7 @@ class Actor: actortype = self.type else: state = False - actortype = "!!! MISSING TYPE !!!" + actortype = self.type # !!! MISSING TYPE !!! return dict(id=self.id, name=self.name, type=actortype, props=self.props.to_dict(), state=state, power=self.power, timer=self.timer) class DataType(Enum): diff --git a/cbpi/controller/basic_controller2.py b/cbpi/controller/basic_controller2.py index 9feda96..a7f7f82 100644 --- a/cbpi/controller/basic_controller2.py +++ b/cbpi/controller/basic_controller2.py @@ -2,7 +2,7 @@ import logging import os.path import json -from cbpi.api.dataclasses import Fermenter, Actor, Props +from cbpi.api.dataclasses import Fermenter, Actor, Props, NotificationType import sys, os import shortuuid import asyncio @@ -130,7 +130,9 @@ class BasicController: # await self.push_udpate() except Exception as e: - logging.error("{} Cant start {} - {}".format(self.name, id, e)) + line="{} Cant start {} - {}".format(self.name, id, e) + logging.error(line) + self.cbpi.notify("Error", line, NotificationType.ERROR) def get_types(self): # logging.info("{} Get Types".format(self.name)) diff --git a/cbpi/controller/upload_controller.py b/cbpi/controller/upload_controller.py index f3614dc..0e267d2 100644 --- a/cbpi/controller/upload_controller.py +++ b/cbpi/controller/upload_controller.py @@ -170,7 +170,7 @@ class UploadController: f.close() self.cbpi.notify("Success", "XML Recipe {} has been uploaded".format(filename), NotificationType.SUCCESS) except Exception as e: - self.cbpi.notify("Error" "XML Recipe upload failed: {}".format(e), NotificationType.ERROR) + self.cbpi.notify("Error", "XML Recipe upload failed: {}".format(e), NotificationType.ERROR) pass elif content_type == 'application/json':