mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-12-25 15:04:56 +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"
|
||||
|
||||
|
|
|
@ -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 = {}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue