variable CONFIG_STATUS (cbpi version)

This commit is contained in:
avollkopf 2023-04-08 12:26:10 +02:00
parent 9041ad7daa
commit efc3e3737c
2 changed files with 20 additions and 18 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.8.a8" __version__ = "4.1.8.a9"
__codename__ = "Groundhog Day" __codename__ = "Groundhog Day"

View file

@ -8,6 +8,7 @@ import json
from cbpi.api import * from cbpi.api import *
from cbpi.api.config import ConfigType from cbpi.api.config import ConfigType
from cbpi.api.base import CBPiBase from cbpi.api.base import CBPiBase
from cbpi import __version__
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -61,6 +62,7 @@ class ConfigUpdate(CBPiExtension):
RecipeCreationPath = self.cbpi.config.get("RECIPE_CREATION_PATH", None) RecipeCreationPath = self.cbpi.config.get("RECIPE_CREATION_PATH", None)
BoilKettle = self.cbpi.config.get("BoilKettle", None) BoilKettle = self.cbpi.config.get("BoilKettle", None)
CONFIG_STATUS = self.cbpi.config.get("CONFIG_STATUS", None) CONFIG_STATUS = self.cbpi.config.get("CONFIG_STATUS", None)
self.version=__version__
if boil_temp is None: if boil_temp is None:
@ -70,7 +72,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_boil_temp", boil_temp, type=ConfigType.NUMBER, description="Default Boil Temperature for Recipe Creation", source="steps") await self.cbpi.config.add("steps_boil_temp", boil_temp, type=ConfigType.NUMBER, description="Default Boil Temperature for Recipe Creation", source="steps")
if cooldown_sensor is None: if cooldown_sensor is None:
@ -80,7 +82,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_cooldown_sensor", cooldown_sensor, type=ConfigType.SENSOR, description="Alternative Sensor to monitor temperature durring cooldown (if not selected, Kettle Sensor will be used)", source="steps") await self.cbpi.config.add("steps_cooldown_sensor", cooldown_sensor, type=ConfigType.SENSOR, description="Alternative Sensor to monitor temperature durring cooldown (if not selected, Kettle Sensor will be used)", source="steps")
if cooldown_actor is None: if cooldown_actor is None:
@ -90,7 +92,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_cooldown_actor", cooldown_actor, type=ConfigType.ACTOR, description="Actor to trigger cooldown water on and off (default: None)", source="steps") await self.cbpi.config.add("steps_cooldown_actor", cooldown_actor, type=ConfigType.ACTOR, description="Actor to trigger cooldown water on and off (default: None)", source="steps")
if cooldown_temp is None: if cooldown_temp is None:
@ -100,7 +102,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_cooldown_temp", cooldown_temp, type=ConfigType.NUMBER, description="Cooldown temp will send notification when this temeprature is reached", source="steps") await self.cbpi.config.add("steps_cooldown_temp", cooldown_temp, type=ConfigType.NUMBER, description="Cooldown temp will send notification when this temeprature is reached", source="steps")
if cooldown_step is None: if cooldown_step is None:
@ -110,7 +112,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_cooldown", cooldown_step, type=ConfigType.STEP, description="Cooldown step type", source="steps") await self.cbpi.config.add("steps_cooldown", cooldown_step, type=ConfigType.STEP, description="Cooldown step type", source="steps")
if mashin_step is None: if mashin_step is None:
@ -120,7 +122,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_mashin", mashin_step, type=ConfigType.STEP, description="MashIn step type", source="steps") await self.cbpi.config.add("steps_mashin", mashin_step, type=ConfigType.STEP, description="MashIn step type", source="steps")
if mash_step is None: if mash_step is None:
@ -130,7 +132,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_mash", mash_step, type=ConfigType.STEP, description="Mash step type", source="steps") await self.cbpi.config.add("steps_mash", mash_step, type=ConfigType.STEP, description="Mash step type", source="steps")
if mashout_step is None: if mashout_step is None:
@ -140,7 +142,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_mashout", mashout_step, type=ConfigType.STEP, description="MashOut step type", source="steps") await self.cbpi.config.add("steps_mashout", mashout_step, type=ConfigType.STEP, description="MashOut step type", source="steps")
if boil_step is None: if boil_step is None:
@ -150,7 +152,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("steps_boil", boil_step, type=ConfigType.STEP, description="Boil step type", source="steps") await self.cbpi.config.add("steps_boil", boil_step, type=ConfigType.STEP, description="Boil step type", source="steps")
if max_dashboard_number is None: if max_dashboard_number is None:
@ -179,7 +181,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("current_dashboard_number", current_dashboard_number, type=ConfigType.NUMBER, description="Number of current Dashboard",source="hidden") await self.cbpi.config.add("current_dashboard_number", current_dashboard_number, type=ConfigType.NUMBER, description="Number of current Dashboard",source="hidden")
## Check if AtuoMode for Steps is in config ## Check if AtuoMode for Steps is in config
@ -194,7 +196,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("AutoMode", AutoMode, type=ConfigType.SELECT, description="Use AutoMode in steps", options= await self.cbpi.config.add("AutoMode", AutoMode, type=ConfigType.SELECT, description="Use AutoMode in steps", options=
[{"label": "Yes", "value": "Yes"}, [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}], {"label": "No", "value": "No"}],
@ -212,7 +214,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("AddMashInStep", AddMashIn, type=ConfigType.SELECT, description="Add MashIn Step automatically if not defined in recipe", await self.cbpi.config.add("AddMashInStep", AddMashIn, type=ConfigType.SELECT, description="Add MashIn Step automatically if not defined in recipe",
options= [{"label": "Yes", "value": "Yes"}, options= [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}], {"label": "No", "value": "No"}],
@ -254,7 +256,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("BoilKettle", BoilKettle, type=ConfigType.KETTLE, description="Define Kettle that is used for Boil, Whirlpool and Cooldown. If not selected, MASH_TUN will be used",source="steps") await self.cbpi.config.add("BoilKettle", BoilKettle, type=ConfigType.KETTLE, description="Define Kettle that is used for Boil, Whirlpool and Cooldown. If not selected, MASH_TUN will be used",source="steps")
if MASH_TUN is None: if MASH_TUN is None:
@ -264,7 +266,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add("MASH_TUN", MASH_TUN, type=ConfigType.KETTLE, description="Default Mash Tun",source="steps") await self.cbpi.config.add("MASH_TUN", MASH_TUN, type=ConfigType.KETTLE, description="Default Mash Tun",source="steps")
## Check if CSV logfiles is on config ## Check if CSV logfiles is on config
@ -417,7 +419,7 @@ class ConfigUpdate(CBPiExtension):
except: except:
logging.warning('Unable to update database') logging.warning('Unable to update database')
else: else:
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
await self.cbpi.config.add('BoilAutoTimer', BoilAutoTimer, type=ConfigType.SELECT, await self.cbpi.config.add('BoilAutoTimer', BoilAutoTimer, type=ConfigType.SELECT,
description='Start Boil timer automatically if Temp does not change for 5 Minutes and is above 95C/203F', description='Start Boil timer automatically if Temp does not change for 5 Minutes and is above 95C/203F',
options=[{"label": "Yes", "value": "Yes"}, options=[{"label": "Yes", "value": "Yes"},
@ -426,10 +428,10 @@ class ConfigUpdate(CBPiExtension):
## Check if influxdbname is in config ## Check if influxdbname is in config
if CONFIG_STATUS is None: if CONFIG_STATUS is None or CONFIG_STATUS != self.version:
logger.warning("Setting Config Status") logger.warning("Setting Config Status")
try: try:
await self.cbpi.config.add("CONFIG_STATUS", "4.1.8", type=ConfigType.STRING, description="Status of the cofig file. Internal use for maintenance", source="hidden") await self.cbpi.config.add("CONFIG_STATUS", self.version, type=ConfigType.STRING, description="Status of the config file. Internal use for maintenance", source="hidden")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')