diff --git a/cbpi/__init__.py b/cbpi/__init__.py index df87e13..2260e28 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.0.7.rc1" +__version__ = "4.0.7.rc2" __codename__ = "November Rain" diff --git a/cbpi/controller/notification_controller.py b/cbpi/controller/notification_controller.py index 26c25b4..33e6fb1 100644 --- a/cbpi/controller/notification_controller.py +++ b/cbpi/controller/notification_controller.py @@ -1,6 +1,7 @@ import asyncio from email import message from cbpi.api.dataclasses import NotificationType +from cbpi.api import * import logging import shortuuid class NotificationController: @@ -11,7 +12,9 @@ class NotificationController: ''' self.cbpi = cbpi self.logger = logging.getLogger(__name__) - logging.root.addFilter(self.notify_log_event) + NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", "No") + if NOTIFY_ON_ERROR == "Yes": + logging.root.addFilter(self.notify_log_event) self.callback_cache = {} self.listener = {} diff --git a/cbpi/extension/ConfigUpdate/__init__.py b/cbpi/extension/ConfigUpdate/__init__.py index 80808c3..4b4de2a 100644 --- a/cbpi/extension/ConfigUpdate/__init__.py +++ b/cbpi/extension/ConfigUpdate/__init__.py @@ -50,6 +50,7 @@ class ConfigUpdate(CBPiExtension): SENSOR_LOG_BACKUP_COUNT = self.cbpi.config.get("SENSOR_LOG_BACKUP_COUNT", None) SENSOR_LOG_MAX_BYTES = self.cbpi.config.get("SENSOR_LOG_MAX_BYTES", None) slow_pipe_animation = self.cbpi.config.get("slow_pipe_animation", None) + NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", None) if boil_temp is None: logger.info("INIT Boil Temp Setting") @@ -313,7 +314,17 @@ class ConfigUpdate(CBPiExtension): {"label": "No", "value": "No"}]) except: logger.warning('Unable to update config') - + + ## Check if NOTIFY_ON_ERROR is in config + if NOTIFY_ON_ERROR is None: + logger.info("INIT NOTIFY_ON_ERROR") + try: + await self.cbpi.config.add("NOTIFY_ON_ERROR", "No", ConfigType.SELECT, "Send Notification on Logging Error", + [{"label": "Yes", "value": "Yes"}, + {"label": "No", "value": "No"}]) + except: + logger.warning('Unable to update config') + def setup(cbpi): cbpi.plugin.register("ConfigUpdate", ConfigUpdate) pass