automatic config update test

This commit is contained in:
avollkopf 2023-04-02 16:14:33 +02:00
parent 5f3e3ea60d
commit be77d90c7e
6 changed files with 151 additions and 181 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.8.a2" __version__ = "4.1.8.a3"
__codename__ = "Groundhog Day" __codename__ = "Groundhog Day"

View file

@ -17,8 +17,8 @@ class CBPiBase(metaclass=ABCMeta):
async def set_config_value(self,name,value): async def set_config_value(self,name,value):
return await self.cbpi.config.set(name,value) return await self.cbpi.config.set(name,value)
async def add_config_value(self, name, value, type: ConfigType, description, options=None): async def add_config_value(self, name, value, type: ConfigType, description, source, options=None):
await self.cbpi.config.add(name, value, type, description, options=None) await self.cbpi.config.add(name, value, type, description, source,options=None)
def get_kettle(self,id): def get_kettle(self,id):
return self.cbpi.kettle.find_by_id(id) return self.cbpi.kettle.find_by_id(id)

View file

@ -198,8 +198,8 @@ class Config:
value: Any = None value: Any = None
description: str = None description: str = None
type: ConfigType = ConfigType.STRING type: ConfigType = ConfigType.STRING
options: Any = None
source: str = None source: str = None
options: Any = None
def __str__(self): def __str__(self):
return "....name={} value={}".format(self.name, self.value) return "....name={} value={}".format(self.name, self.value)

View file

@ -4,6 +4,7 @@
"name": "AUTHOR", "name": "AUTHOR",
"options": null, "options": null,
"type": "string", "type": "string",
"source": "craftbeerpi",
"value": "John Doe" "value": "John Doe"
}, },
"BREWERY_NAME": { "BREWERY_NAME": {
@ -11,52 +12,9 @@
"name": "BREWERY_NAME", "name": "BREWERY_NAME",
"options": null, "options": null,
"type": "string", "type": "string",
"source": "craftbeerpi",
"value": "CraftBeerPi Brewery" "value": "CraftBeerPi Brewery"
}, },
"MASH_TUN": {
"description": "Default Mash Tun",
"name": "MASH_TUN",
"options": null,
"type": "kettle",
"value": ""
},
"AddMashInStep": {
"description": "Add MashIn Step automatically if not defined in recipe",
"name": "AddMashInStep",
"options": [
{
"label": "Yes",
"value": "Yes"
},
{
"label": "No",
"value": "No"
}
],
"type": "select",
"value": "Yes"
},
"RECIPE_CREATION_PATH": {
"description": "API path to creation plugin. Default: empty",
"name": "RECIPE_CREATION_PATH",
"options": null,
"type": "string",
"value": ""
},
"brewfather_api_key": {
"description": "Brewfather API Kay",
"name": "brewfather_api_key",
"options": null,
"type": "string",
"value": ""
},
"brewfather_user_id": {
"description": "Brewfather User ID",
"name": "brewfather_user_id",
"options": null,
"type": "string",
"value": ""
},
"TEMP_UNIT": { "TEMP_UNIT": {
"description": "Temperature Unit", "description": "Temperature Unit",
"name": "TEMP_UNIT", "name": "TEMP_UNIT",
@ -71,78 +29,9 @@
} }
], ],
"type": "select", "type": "select",
"source": "craftbeerpi",
"value": "C" "value": "C"
},
"AutoMode": {
"description": "Use AutoMode in steps",
"name": "AutoMode",
"options": [
{
"label": "Yes",
"value": "Yes"
},
{
"label": "No",
"value": "No"
}
],
"type": "select",
"value": "Yes"
},
"steps_boil": {
"description": "Boil step type",
"name": "steps_boil",
"options": null,
"type": "step",
"value": "BoilStep"
},
"steps_boil_temp": {
"description": "Default Boil Temperature for Recipe Creation",
"name": "steps_boil_temp",
"options": null,
"type": "number",
"value": "99"
},
"steps_cooldown": {
"description": "Cooldown step type",
"name": "steps_cooldown",
"options": null,
"type": "step",
"value": "CooldownStep"
},
"steps_cooldown_sensor": {
"description": "Alternative Sensor to monitor temperature durring cooldown (if not selected, Kettle Sensor will be used)",
"name": "steps_cooldown_sensor",
"options": null,
"type": "sensor",
"value": ""
},
"steps_cooldown_temp": {
"description": "Cooldown temp will send notification when this temeprature is reached",
"name": "steps_cooldown_temp",
"options": null,
"type": "number",
"value": "20"
},
"steps_mash": {
"description": "Mash step type",
"name": "steps_mash",
"options": null,
"type": "step",
"value": "MashStep"
},
"steps_mashin": {
"description": "MashIn step type",
"name": "steps_mashin",
"options": null,
"type": "step",
"value": "MashInStep"
},
"steps_mashout": {
"description": "MashOut step type",
"name": "steps_mashout",
"options": null,
"type": "step",
"value": "NotificationStep"
} }
} }

View file

@ -50,8 +50,8 @@ class ConfigController:
with open(self.path, "w") as file: with open(self.path, "w") as file:
json.dump(data, file, indent=4, sort_keys=True) json.dump(data, file, indent=4, sort_keys=True)
async def add(self, name, value, type: ConfigType, description, options=None): async def add(self, name, value, type: ConfigType, description, source="", options=None):
self.cache[name] = Config(name,value,description,type,options) self.cache[name] = Config(name,value,description,type,source,options)
data = {} data = {}
for key, value in self.cache.items(): for key, value in self.cache.items():
data[key] = value.to_dict() data[key] = value.to_dict()

View file

@ -40,7 +40,6 @@ class ConfigUpdate(CBPiExtension):
logfiles = self.cbpi.config.get("CSVLOGFILES", None) logfiles = self.cbpi.config.get("CSVLOGFILES", None)
influxdb = self.cbpi.config.get("INFLUXDB", None) influxdb = self.cbpi.config.get("INFLUXDB", None)
influxdbaddr = self.cbpi.config.get("INFLUXDBADDR", None) influxdbaddr = self.cbpi.config.get("INFLUXDBADDR", None)
#influxdbport = self.cbpi.config.get("INFLUXDBPORT", None)
influxdbname = self.cbpi.config.get("INFLUXDBNAME", None) influxdbname = self.cbpi.config.get("INFLUXDBNAME", None)
influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None) influxdbuser = self.cbpi.config.get("INFLUXDBUSER", None)
influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None) influxdbpwd = self.cbpi.config.get("INFLUXDBPWD", None)
@ -54,76 +53,112 @@ class ConfigUpdate(CBPiExtension):
NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", None) NOTIFY_ON_ERROR = self.cbpi.config.get("NOTIFY_ON_ERROR", None)
PLAY_BUZZER = self.cbpi.config.get("PLAY_BUZZER", None) PLAY_BUZZER = self.cbpi.config.get("PLAY_BUZZER", None)
BoilAutoTimer = self.cbpi.config.get("BoilAutoTimer", None) BoilAutoTimer = self.cbpi.config.get("BoilAutoTimer", None)
MASH_TUN = self.cbpi.config.get("MASH_TUN", None)
AutoMode = self.cbpi.config.get("AutoMode", None)
AddMashIn = self.cbpi.config.get("AddMashInStep", None)
bfuserid = self.cbpi.config.get("brewfather_user_id", None)
bfapikey = self.cbpi.config.get("brewfather_api_key", None)
RecipeCreationPath = self.cbpi.config.get("RECIPE_CREATION_PATH", None)
BoilKettle = self.cbpi.config.get("BoilKettle", None)
CONFIG_STATUS = self.cbpi.config.get("CONFIG_STATUS", 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:
await self.cbpi.config.add("steps_boil_temp", default_boil_temp, ConfigType.NUMBER, "Default Boil Temperature for Recipe Creation") await self.cbpi.config.add("steps_boil_temp", default_boil_temp, type=ConfigType.NUMBER, description="Default Boil Temperature for Recipe Creation", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT Cooldown Sensor Setting") logger.info("INIT Cooldown Sensor Setting")
try: try:
await self.cbpi.config.add("steps_cooldown_sensor", "", ConfigType.SENSOR, "Alternative Sensor to monitor temperature durring cooldown (if not selected, Kettle Sensor will be used)") await self.cbpi.config.add("steps_cooldown_sensor", "", type=ConfigType.SENSOR, description="Alternative Sensor to monitor temperature durring cooldown (if not selected, Kettle Sensor will be used)", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT Cooldown Actor Setting") logger.info("INIT Cooldown Actor Setting")
try: try:
await self.cbpi.config.add("steps_cooldown_actor", "", ConfigType.ACTOR, "Actor to trigger cooldown water on and off (default: None)") await self.cbpi.config.add("steps_cooldown_actor", "", type=ConfigType.ACTOR, description="Actor to trigger cooldown water on and off (default: None)", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT Cooldown Temp Setting") logger.info("INIT Cooldown Temp Setting")
try: try:
await self.cbpi.config.add("steps_cooldown_temp", default_cool_temp, ConfigType.NUMBER, "Cooldown temp will send notification when this temeprature is reached") await self.cbpi.config.add("steps_cooldown_temp", default_cool_temp, type=ConfigType.NUMBER, description="Cooldown temp will send notification when this temeprature is reached", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT Cooldown Step Type") logger.info("INIT Cooldown Step Type")
try: try:
await self.cbpi.config.add("steps_cooldown", "", ConfigType.STEP, "Cooldown step type") await self.cbpi.config.add("steps_cooldown", "", type=ConfigType.STEP, description="Cooldown step type", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT MashIn Step Type") logger.info("INIT MashIn Step Type")
try: try:
await self.cbpi.config.add("steps_mashin", "", ConfigType.STEP, "MashIn step type") await self.cbpi.config.add("steps_mashin", "", type=ConfigType.STEP, description="MashIn step type", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT Mash Step Type") logger.info("INIT Mash Step Type")
try: try:
await self.cbpi.config.add("steps_mash", "", ConfigType.STEP, "Mash step type") await self.cbpi.config.add("steps_mash", "", type=ConfigType.STEP, description="Mash step type", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT MashOut Step Type") logger.info("INIT MashOut Step Type")
try: try:
await self.cbpi.config.add("steps_mashout", "", ConfigType.STEP, "MashOut step type") await self.cbpi.config.add("steps_mashout", "", type=ConfigType.STEP, description="MashOut step type", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT Boil Step Type") logger.info("INIT Boil Step Type")
try: try:
await self.cbpi.config.add("steps_boil", "", ConfigType.STEP, "Boil step type") await self.cbpi.config.add("steps_boil", "", type=ConfigType.STEP, description="Boil step type", source="steps")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT Max Dashboard Numbers for multiple dashboards") logger.info("INIT Max Dashboard Numbers for multiple dashboards")
try: try:
await self.cbpi.config.add("max_dashboard_number", 4, ConfigType.SELECT, "Max Number of Dashboards", await self.cbpi.config.add("max_dashboard_number", 4, type=ConfigType.SELECT, description="Max Number of Dashboards",
[{"label": "1", "value": 1},
options= [{"label": "1", "value": 1},
{"label": "2", "value": 2}, {"label": "2", "value": 2},
{"label": "3", "value": 3}, {"label": "3", "value": 3},
{"label": "4", "value": 4}, {"label": "4", "value": 4},
@ -132,81 +167,109 @@ class ConfigUpdate(CBPiExtension):
{"label": "7", "value": 7}, {"label": "7", "value": 7},
{"label": "8", "value": 8}, {"label": "8", "value": 8},
{"label": "9", "value": 9}, {"label": "9", "value": 9},
{"label": "10", "value": 10}]) {"label": "10", "value": 10}],
source="craftbeerpi")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
if current_dashboard_number is None: if current_dashboard_number is None:
logger.info("INIT Current Dashboard Number") logger.info("INIT Current Dashboard Number")
try: try:
await self.cbpi.config.add("current_dashboard_number", 1, ConfigType.NUMBER, "Number of current Dashboard") await self.cbpi.config.add("current_dashboard_number", 1, type=ConfigType.NUMBER, description="Number of current Dashboard",source="hidden")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
## Check if AtuoMode for Steps is in config ## Check if AtuoMode for Steps is in config
AutoMode = self.cbpi.config.get("AutoMode", None)
if AutoMode is None: if AutoMode is None:
logger.info("INIT AutoMode") logger.info("INIT AutoMode")
try: try:
await self.cbpi.config.add("AutoMode", "Yes", ConfigType.SELECT, "Use AutoMode in steps", await self.cbpi.config.add("AutoMode", "Yes", type=ConfigType.SELECT, description="Use AutoMode in steps",
[{"label": "Yes", "value": "Yes"}, options=[{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}],
source="steps")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
else:
if CONFIG_STATUS is None:
await self.cbpi.config.add("AutoMode", AutoMode, type=ConfigType.SELECT, description="Use AutoMode in steps", options=
[{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}],
source="steps")
## Check if AddMashInStep for Steps is in config ## Check if AddMashInStep for Steps is in config
AddMashIn = self.cbpi.config.get("AddMashInStep", None)
if AddMashIn is None: if AddMashIn is None:
logger.info("INIT AddMashInStep") logger.info("INIT AddMashInStep")
try: try:
await self.cbpi.config.add("AddMashInStep", "Yes", ConfigType.SELECT, "Add MashIn Step automatically if not defined in recipe", await self.cbpi.config.add("AddMashInStep", "Yes", type=ConfigType.SELECT, description= "Add MashIn Step automatically if not defined in recipe",
[{"label": "Yes", "value": "Yes"}, options = [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}],
source="steps")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
else:
if CONFIG_STATUS is None:
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"},
{"label": "No", "value": "No"}],
source="steps")
## Check if Brewfather UserID is in config ## Check if Brewfather UserID is in config
bfuserid = self.cbpi.config.get("brewfather_user_id", None)
if bfuserid is None: if bfuserid is None:
logger.info("INIT Brewfather User ID") logger.info("INIT Brewfather User ID")
try: try:
await self.cbpi.config.add("brewfather_user_id", "", ConfigType.STRING, "Brewfather User ID") await self.cbpi.config.add("brewfather_user_id", "", type=ConfigType.STRING, description="Brewfather User ID")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
## Check if Brewfather API Key is in config ## Check if Brewfather API Key is in config
bfapikey = self.cbpi.config.get("brewfather_api_key", None)
if bfapikey is None: if bfapikey is None:
logger.info("INIT Brewfather API Key") logger.info("INIT Brewfather API Key")
try: try:
await self.cbpi.config.add("brewfather_api_key", "", ConfigType.STRING, "Brewfather API Key") await self.cbpi.config.add("brewfather_api_key", "", type=ConfigType.STRING, description="Brewfather API Key")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
## Check if Brewfather API Key is in config ## Check if Brewfather API Key is in config
RecipeCreationPath = self.cbpi.config.get("RECIPE_CREATION_PATH", None)
if RecipeCreationPath is None: if RecipeCreationPath is None:
logger.info("INIT Recipe Creation Path") logger.info("INIT Recipe Creation Path")
try: try:
await self.cbpi.config.add("RECIPE_CREATION_PATH", "upload", ConfigType.STRING, "API path to creation plugin. Default: upload . CHANGE ONLY IF USING A RECIPE CREATION PLUGIN") await self.cbpi.config.add("RECIPE_CREATION_PATH", "upload", type=ConfigType.STRING, description="API path to creation plugin. Default: upload . CHANGE ONLY IF USING A RECIPE CREATION PLUGIN")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
## Check if Kettle for Boil, Whirlpool and Cooldown is in config ## Check if Kettle for Boil, Whirlpool and Cooldown is in config
BoilKettle = self.cbpi.config.get("BoilKettle", None)
if BoilKettle is None: if BoilKettle is None:
logger.info("INIT BoilKettle") logger.info("INIT BoilKettle")
try: try:
await self.cbpi.config.add("BoilKettle", "", ConfigType.KETTLE, "Define Kettle that is used for Boil, Whirlpool and Cooldown. If not selected, MASH_TUN will be used") await self.cbpi.config.add("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")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
else:
if CONFIG_STATUS is None:
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:
logger.info("INIT MASH_TUN")
try:
await self.cbpi.config.add("MASH_TUN", "", type=ConfigType.KETTLE, description="Default Mash Tun",source="steps")
except:
logger.warning('Unable to update config')
else:
if CONFIG_STATUS is None:
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
if logfiles is None: if logfiles is None:
logger.info("INIT CSV logfiles") logger.info("INIT CSV logfiles")
try: try:
await self.cbpi.config.add("CSVLOGFILES", "Yes", ConfigType.SELECT, "Write sensor data to csv logfiles", await self.cbpi.config.add("CSVLOGFILES", "Yes", type=ConfigType.SELECT, description="Write sensor data to csv logfiles",
[{"label": "Yes", "value": "Yes"}, options= [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}])
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -215,8 +278,8 @@ class ConfigUpdate(CBPiExtension):
if influxdb is None: if influxdb is None:
logger.info("INIT Influxdb") logger.info("INIT Influxdb")
try: try:
await self.cbpi.config.add("INFLUXDB", "No", ConfigType.SELECT, "Write sensor data to influxdb", await self.cbpi.config.add("INFLUXDB", "No", type=ConfigType.SELECT, description="Write sensor data to influxdb",
[{"label": "Yes", "value": "Yes"}, options= [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}])
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -225,7 +288,7 @@ class ConfigUpdate(CBPiExtension):
if influxdbaddr is None: if influxdbaddr is None:
logger.info("INIT Influxdbaddr") logger.info("INIT Influxdbaddr")
try: try:
await self.cbpi.config.add("INFLUXDBADDR", "http://localhost:8086", ConfigType.STRING, "URL Address of your influxdb server (If INFLUXDBCLOUD set to Yes use URL Address of your influxdb cloud server)") await self.cbpi.config.add("INFLUXDBADDR", "http://localhost:8086", type=ConfigType.STRING, description="URL Address of your influxdb server (If INFLUXDBCLOUD set to Yes use URL Address of your influxdb cloud server)")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -233,7 +296,7 @@ class ConfigUpdate(CBPiExtension):
if influxdbname is None: if influxdbname is None:
logger.info("INIT Influxdbname") logger.info("INIT Influxdbname")
try: try:
await self.cbpi.config.add("INFLUXDBNAME", "cbpi4", ConfigType.STRING, "Name of your influxdb database name (If INFLUXDBCLOUD set to Yes use bucket of your influxdb cloud database)") await self.cbpi.config.add("INFLUXDBNAME", "cbpi4", type=ConfigType.STRING, description="Name of your influxdb database name (If INFLUXDBCLOUD set to Yes use bucket of your influxdb cloud database)")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -241,7 +304,7 @@ class ConfigUpdate(CBPiExtension):
if influxdbuser is None: if influxdbuser is None:
logger.info("INIT Influxdbuser") logger.info("INIT Influxdbuser")
try: try:
await self.cbpi.config.add("INFLUXDBUSER", " ", ConfigType.STRING, "User name for your influxdb database (only if required)(If INFLUXDBCLOUD set to Yes use organisation of your influxdb cloud database)") await self.cbpi.config.add("INFLUXDBUSER", " ", type=ConfigType.STRING, description="User name for your influxdb database (only if required)(If INFLUXDBCLOUD set to Yes use organisation of your influxdb cloud database)")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -249,7 +312,7 @@ class ConfigUpdate(CBPiExtension):
if influxdbpwd is None: if influxdbpwd is None:
logger.info("INIT Influxdbpwd") logger.info("INIT Influxdbpwd")
try: try:
await self.cbpi.config.add("INFLUXDBPWD", " ", ConfigType.STRING, "Password for your influxdb database (only if required)(If INFLUXDBCLOUD set to Yes use token of your influxdb cloud database)") await self.cbpi.config.add("INFLUXDBPWD", " ", type=ConfigType.STRING, description="Password for your influxdb database (only if required)(If INFLUXDBCLOUD set to Yes use token of your influxdb cloud database)")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -257,8 +320,8 @@ class ConfigUpdate(CBPiExtension):
if influxdbcloud is None: if influxdbcloud is None:
logger.info("INIT influxdbcloud") logger.info("INIT influxdbcloud")
try: try:
await self.cbpi.config.add("INFLUXDBCLOUD", "No", ConfigType.SELECT, "Write sensor data to influxdb cloud (INFLUXDB must set to Yes)", await self.cbpi.config.add("INFLUXDBCLOUD", "No", type=ConfigType.SELECT, description="Write sensor data to influxdb cloud (INFLUXDB must set to Yes)",
[{"label": "Yes", "value": "Yes"}, options= [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}])
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -267,15 +330,15 @@ class ConfigUpdate(CBPiExtension):
if influxdbmeasurement is None: if influxdbmeasurement is None:
logger.info("INIT Influxdb measurementname") logger.info("INIT Influxdb measurementname")
try: try:
await self.cbpi.config.add("INFLUXDBMEASUREMENT", "measurement", ConfigType.STRING, "Name of the measurement in your INFLUXDB database (default: measurement)") await self.cbpi.config.add("INFLUXDBMEASUREMENT", "measurement", type=ConfigType.STRING, description="Name of the measurement in your INFLUXDB database (default: measurement)")
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
if mqttupdate is None: if mqttupdate is None:
logger.info("INIT MQTT update frequency for Kettles and Fermenters") logger.info("INIT MQTT update frequency for Kettles and Fermenters")
try: try:
await self.cbpi.config.add("MQTTUpdate", 0, ConfigType.SELECT, "Forced MQTT Update frequency in s for Kettle and Fermenter (no changes in payload required). Restart required after change", await self.cbpi.config.add("MQTTUpdate", 0, type=ConfigType.SELECT, description="Forced MQTT Update frequency in s for Kettle and Fermenter (no changes in payload required). Restart required after change",
[{"label": "30", "value": 30}, options= [{"label": "30", "value": 30},
{"label": "60", "value": 60}, {"label": "60", "value": 60},
{"label": "120", "value": 120}, {"label": "120", "value": 120},
{"label": "300", "value": 300}, {"label": "300", "value": 300},
@ -287,8 +350,8 @@ class ConfigUpdate(CBPiExtension):
if PRESSURE_UNIT is None: if PRESSURE_UNIT is None:
logger.info("INIT PRESSURE_UNIT") logger.info("INIT PRESSURE_UNIT")
try: try:
await self.cbpi.config.add("PRESSURE_UNIT", "kPa", ConfigType.SELECT, "Set unit for pressure", await self.cbpi.config.add("PRESSURE_UNIT", "kPa", type=ConfigType.SELECT, description="Set unit for pressure",
[{"label": "kPa", "value": "kPa"}, options= [{"label": "kPa", "value": "kPa"},
{"label": "PSI", "value": "PSI"}]) {"label": "PSI", "value": "PSI"}])
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -297,7 +360,7 @@ class ConfigUpdate(CBPiExtension):
if SENSOR_LOG_BACKUP_COUNT is None: if SENSOR_LOG_BACKUP_COUNT is None:
logger.info("INIT SENSOR_LOG_BACKUP_COUNT") logger.info("INIT SENSOR_LOG_BACKUP_COUNT")
try: try:
await self.cbpi.config.add("SENSOR_LOG_BACKUP_COUNT", 3, ConfigType.NUMBER, "Max. number of backup logs") await self.cbpi.config.add("SENSOR_LOG_BACKUP_COUNT", 3, type=ConfigType.NUMBER, description="Max. number of backup logs")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
@ -305,7 +368,7 @@ class ConfigUpdate(CBPiExtension):
if SENSOR_LOG_MAX_BYTES is None: if SENSOR_LOG_MAX_BYTES is None:
logger.info("Init maximum size of sensor logfiles") logger.info("Init maximum size of sensor logfiles")
try: try:
await self.cbpi.config.add("SENSOR_LOG_MAX_BYTES", 100000, ConfigType.NUMBER, "Max. number of bytes in sensor logs") await self.cbpi.config.add("SENSOR_LOG_MAX_BYTES", 100000, type=ConfigType.NUMBER, description="Max. number of bytes in sensor logs")
except: except:
logger.warning('Unable to update database') logger.warning('Unable to update database')
@ -313,8 +376,8 @@ class ConfigUpdate(CBPiExtension):
if slow_pipe_animation is None: if slow_pipe_animation is None:
logger.info("INIT slow_pipe_animation") logger.info("INIT slow_pipe_animation")
try: try:
await self.cbpi.config.add("slow_pipe_animation", "Yes", ConfigType.SELECT, "Slow down dashboard pipe animation taking up close to 100% of the CPU's capacity", await self.cbpi.config.add("slow_pipe_animation", "Yes", type=ConfigType.SELECT, description="Slow down dashboard pipe animation taking up close to 100% of the CPU's capacity",
[{"label": "Yes", "value": "Yes"}, options= [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}])
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -323,8 +386,8 @@ class ConfigUpdate(CBPiExtension):
if NOTIFY_ON_ERROR is None: if NOTIFY_ON_ERROR is None:
logger.info("INIT NOTIFY_ON_ERROR") logger.info("INIT NOTIFY_ON_ERROR")
try: try:
await self.cbpi.config.add("NOTIFY_ON_ERROR", "No", ConfigType.SELECT, "Send Notification on Logging Error", await self.cbpi.config.add("NOTIFY_ON_ERROR", "No", type=ConfigType.SELECT, description="Send Notification on Logging Error",
[{"label": "Yes", "value": "Yes"}, options= [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}])
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -333,8 +396,8 @@ class ConfigUpdate(CBPiExtension):
if PLAY_BUZZER is None: if PLAY_BUZZER is None:
logger.info("INIT PLAY_BUZZER") logger.info("INIT PLAY_BUZZER")
try: try:
await self.cbpi.config.add("PLAY_BUZZER", "No", ConfigType.SELECT, "Play buzzer sound in Web interface on Notifications", await self.cbpi.config.add("PLAY_BUZZER", "No", type=ConfigType.SELECT, description="Play buzzer sound in Web interface on Notifications",
[{"label": "Yes", "value": "Yes"}, options= [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}])
except: except:
logger.warning('Unable to update config') logger.warning('Unable to update config')
@ -342,13 +405,31 @@ class ConfigUpdate(CBPiExtension):
if BoilAutoTimer is None: if BoilAutoTimer is None:
logging.info("INIT BoilAutoTimer") logging.info("INIT BoilAutoTimer")
try: try:
await self.cbpi.config.add('BoilAutoTimer', 'No', ConfigType.SELECT, await self.cbpi.config.add('BoilAutoTimer', 'No', type=ConfigType.SELECT,
'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',
[{"label": "Yes", "value": "Yes"}, options= [{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}]) {"label": "No", "value": "No"}],
source="steps")
BoilAutoTimer = self.cbpi.config.get("BoilAutoTimer", "No") BoilAutoTimer = self.cbpi.config.get("BoilAutoTimer", "No")
except: except:
logging.warning('Unable to update database') logging.warning('Unable to update database')
else:
if CONFIG_STATUS is None:
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',
options=[{"label": "Yes", "value": "Yes"},
{"label": "No", "value": "No"}],
source="steps")
## Check if influxdbname is in config
if CONFIG_STATUS is None:
logger.warning("Setting Config Status")
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")
except:
logger.warning('Unable to update config')
def setup(cbpi): def setup(cbpi):
cbpi.plugin.register("ConfigUpdate", ConfigUpdate) cbpi.plugin.register("ConfigUpdate", ConfigUpdate)