diff --git a/cbpi/config/config.json b/cbpi/config/config.json index cdb9b15..56f98c5 100644 --- a/cbpi/config/config.json +++ b/cbpi/config/config.json @@ -144,19 +144,5 @@ "options": null, "type": "step", "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" - } + } } diff --git a/cbpi/extension/ConfigUpdate/__init__.py b/cbpi/extension/ConfigUpdate/__init__.py index e5dc9ac..77d9677 100644 --- a/cbpi/extension/ConfigUpdate/__init__.py +++ b/cbpi/extension/ConfigUpdate/__init__.py @@ -47,8 +47,9 @@ class ConfigUpdate(CBPiExtension): influxdbcloud = self.cbpi.config.get("INFLUXDBCLOUD", None) mqttupdate = self.cbpi.config.get("MQTTUpdate", 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: logger.info("INIT Boil Temp Setting") try: @@ -285,6 +286,23 @@ class ConfigUpdate(CBPiExtension): {"label": "PSI", "value": "PSI"}]) except: 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): cbpi.plugin.register("ConfigUpdate", ConfigUpdate)