mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-28 17:54:15 +01:00
Add parameter for Notify on Error
This commit is contained in:
parent
7e0eb0f30d
commit
9f655c9393
3 changed files with 17 additions and 3 deletions
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.0.7.rc1"
|
__version__ = "4.0.7.rc2"
|
||||||
__codename__ = "November Rain"
|
__codename__ = "November Rain"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
from email import message
|
from email import message
|
||||||
from cbpi.api.dataclasses import NotificationType
|
from cbpi.api.dataclasses import NotificationType
|
||||||
|
from cbpi.api import *
|
||||||
import logging
|
import logging
|
||||||
import shortuuid
|
import shortuuid
|
||||||
class NotificationController:
|
class NotificationController:
|
||||||
|
@ -11,6 +12,8 @@ class NotificationController:
|
||||||
'''
|
'''
|
||||||
self.cbpi = cbpi
|
self.cbpi = cbpi
|
||||||
self.logger = logging.getLogger(__name__)
|
self.logger = logging.getLogger(__name__)
|
||||||
|
NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", "No")
|
||||||
|
if NOTIFY_ON_ERROR == "Yes":
|
||||||
logging.root.addFilter(self.notify_log_event)
|
logging.root.addFilter(self.notify_log_event)
|
||||||
self.callback_cache = {}
|
self.callback_cache = {}
|
||||||
self.listener = {}
|
self.listener = {}
|
||||||
|
|
|
@ -50,6 +50,7 @@ class ConfigUpdate(CBPiExtension):
|
||||||
SENSOR_LOG_BACKUP_COUNT = self.cbpi.config.get("SENSOR_LOG_BACKUP_COUNT", None)
|
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)
|
SENSOR_LOG_MAX_BYTES = self.cbpi.config.get("SENSOR_LOG_MAX_BYTES", None)
|
||||||
slow_pipe_animation = self.cbpi.config.get("slow_pipe_animation", 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:
|
if boil_temp is None:
|
||||||
logger.info("INIT Boil Temp Setting")
|
logger.info("INIT Boil Temp Setting")
|
||||||
|
@ -314,6 +315,16 @@ class ConfigUpdate(CBPiExtension):
|
||||||
except:
|
except:
|
||||||
logger.warning('Unable to update config')
|
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):
|
def setup(cbpi):
|
||||||
cbpi.plugin.register("ConfigUpdate", ConfigUpdate)
|
cbpi.plugin.register("ConfigUpdate", ConfigUpdate)
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue