Logfile size and backup logfile count in config.json

This commit is contained in:
phylax2020 2022-07-19 09:39:27 +02:00
parent 8621888d81
commit abe87b4218
2 changed files with 21 additions and 17 deletions

View file

@ -144,19 +144,5 @@
"options": null, "options": null,
"type": "step", "type": "step",
"value": "NotificationStep" "value": "NotificationStep"
}, }
"SENSOR_LOG_BACKUP_COUNT": {
"description": "Max. number of backup logs",
"name": "SENSOR_LOG_BACKUP_COUNT",
"options": null,
"type": "number",
"value": 3
},
"SENSOR_LOG_MAX_BYTES": {
"description": "Max. number of bytes in sensor logs",
"name": "SENSOR_LOG_MAX_BYTES",
"options": null,
"type": "number",
"value": "100000"
}
} }

View file

@ -47,8 +47,9 @@ class ConfigUpdate(CBPiExtension):
influxdbcloud = self.cbpi.config.get("INFLUXDBCLOUD", None) influxdbcloud = self.cbpi.config.get("INFLUXDBCLOUD", None)
mqttupdate = self.cbpi.config.get("MQTTUpdate", None) mqttupdate = self.cbpi.config.get("MQTTUpdate", None)
PRESSURE_UNIT = self.cbpi.config.get("PRESSURE_UNIT", None) PRESSURE_UNIT = self.cbpi.config.get("PRESSURE_UNIT", 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)
if boil_temp is None: if boil_temp is None:
logger.info("INIT Boil Temp Setting") logger.info("INIT Boil Temp Setting")
try: try:
@ -285,6 +286,23 @@ class ConfigUpdate(CBPiExtension):
{"label": "PSI", "value": "PSI"}]) {"label": "PSI", "value": "PSI"}])
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
# check if SENSOR_LOG_BACKUP_COUNT exists in config
if SENSOR_LOG_BACKUP_COUNT is None:
logger.info("INIT SENSOR_LOG_BACKUP_COUNT")
try:
await self.cbpi.config.add("SENSOR_LOG_BACKUP_COUNT", 3, ConfigType.NUMBER, "Max. number of backup logs")
except:
logger.warning('Unable to update database')
# check if SENSOR_LOG_MAX_BYTES exists in config
if SENSOR_LOG_MAX_BYTES is None:
logger.info("INIT SENSOR_LOG_MAX_BYTES")
try:
await self.cbpi.config.add("SENSOR_LOG_MAX_BYTES", 100000, ConfigType.NUMBER, "Max. number of bytes in sensor logs")
except:
logger.warning('Unable to update database')
def setup(cbpi): def setup(cbpi):
cbpi.plugin.register("ConfigUpdate", ConfigUpdate) cbpi.plugin.register("ConfigUpdate", ConfigUpdate)