Exemplo n.º 1
0
def set_parameter_fermID():
    fermid = cbpi.get_config_parameter("NEXTION_Fermenter_ID", None)
    if fermid is None:
        fermid = 1
        cbpi.add_config_parameter("NEXTION_Fermenter_ID", 1, "number", "Select Fermenter (Number), NO! CBPi reboot required")
        cbpi.app.logger.info("NEXTIONDisplay - FermenterID added: %s" % fermid)
    return fermid
Exemplo n.º 2
0
def set_StartscreenOn():
    startsc = cbpi.get_config_parameter("TFT_StartscreenOn", None)
    if startsc is None:
        startsc = "on"
        cbpi.add_config_parameter ("TFT_StartscreenOn", "on", "select", "Skip the CBPI Logo and start chart of kettle at power on, NO! CBPi reboot required", ["on", "off"])
        cbpi.app.logger.info("TFTDisplay  - TFT_StartscreenOn added: %s" % (startsc))
    return startsc
Exemplo n.º 3
0
 def init(self):
     unit = cbpi.get_config_parameter("flowunit", None)
     if unit is None:
         print("INIT FLOW DB")
         try:
             cbpi.add_config_parameter(
                 "flowunit",
                 "L",
                 "select",
                 "Flowmeter unit",
                 options=["L", "gal(us)", "gal(uk)", "qt"])
         except:
             cbpi.notify("Flowmeter Error",
                         "Unable to update database.",
                         type="danger",
                         timeout=None)
     try:
         GPIO.setup(int(self.gpio), GPIO.IN, pull_up_down=GPIO.PUD_UP)
         GPIO.add_event_detect(int(self.gpio),
                               GPIO.RISING,
                               callback=self.doAClick,
                               bouncetime=20)
         self.fms[int(self.gpio)] = FlowMeterData()
     except Exception as e:
         print(e)
Exemplo n.º 4
0
def init(cbpi):
    cbpi.app.logger.info("brewstat.us plugin Initialize")
    log("Brewstat.us params")
    global brewstatus_comment
    global brewstatus_url
    brewstatus_comment = cbpi.get_config_parameter("brewstatus_comment", None)
    log("Brewstat.us brewstatus_comment %s" % brewstatus_comment)
    brewstatus_url = cbpi.get_config_parameter("brewstatus_url", None)
    log("Brewstat.us brewstatus_url %s" % brewstatus_url)
    if brewstatus_comment is None:
        log("Init brewstat.us config Comment")
        try:
            # TODO: is param2 a default value?
            cbpi.add_config_parameter("brewstatus_comment", "", "text",
                                      "Brewstat.us comment")
        except:
            cbpi.notify("Brewstat.us Error",
                        "Unable to update config parameter",
                        type="danger")
    if brewstatus_url is None:
        log("Init brewstat.us config url")
        try:
            # TODO: is param2 a default value?
            cbpi.add_config_parameter("brewstatus_url", "", "text",
                                      "Brewstat.us url")
        except:
            cbpi.notify("Brewstat.us Error",
                        "Unable to update config parameter",
                        type="danger")
    log("Brewstat.us params ends")
Exemplo n.º 5
0
def set_fontsize():
    fosi = cbpi.get_config_parameter("TFT_Fontsize", None)
    if fosi is None:
        fosi = 16
        cbpi.add_config_parameter ("TFT_Fontsize", 16, "number", "Choose fontsize of grid default is 16, NO! CBPi reboot required")
        cbpi.app.logger.info("TFTDisplay  - TFT_Fontsize added: %s" % (fosi))
    return fosi
Exemplo n.º 6
0
def set_parameter_kettleID():
    kettleid = cbpi.get_config_parameter("NEXTION_Kettle_ID", None)
    if kettleid is None:
        kettleid = 1
        cbpi.add_config_parameter("NEXTION_Kettle_ID", 1, "kettle", "Select kettle (Number), NO! CBPi reboot required")
        cbpi.app.logger.info("NEXTIONDisplay - KettleID added: %s" % kettleid)
    return kettleid
Exemplo n.º 7
0
def set_TFTw():
    TFTbr = (cbpi.get_config_parameter("TFT_Width", None))
    if TFTbr is None:
        cbpi.add_config_parameter("TFT_Width", 388, "number", "Choose TFTDisplay width [pixel], default 388, NO! CBPi reboot required")
        TFTbr = (cbpi.get_config_parameter("TFT_Width", None))
        cbpi.app.logger.info("TFTDisplay  - TFTbr added: %s" % (TFTbr))
    return TFTbr
Exemplo n.º 8
0
def set_parameter_id3():
    TFTid3 = cbpi.get_config_parameter("TFT_Kettle_ID", None)
    if TFTid3 is None:
        TFTid3 = 1
        cbpi.add_config_parameter ("TFT_Kettle_ID", 1, "number", "Choose kettle (Number), NO! CBPi reboot required")      
        cbpi.app.logger.info("TFTDisplay  - TFTid added: %s" % (TFTid3))
    return TFTid3
Exemplo n.º 9
0
def set_DigitOn():
    digit = cbpi.get_config_parameter("TFT_digitOn", None)
    if digit is None:
        digit = "off"
        cbpi.add_config_parameter ("TFT_digitOn", "off", "select", "No graph just big digits showing temperature, NO! CBPi reboot required", ["on", "off"])
        cbpi.app.logger.info("TFTDisplay  - TFT_digitOn added:  %s" % (digit))
    return digit
Exemplo n.º 10
0
def set_TFTh():
    TFThoehe = (cbpi.get_config_parameter("TFT_Hight", None))
    if TFThoehe is None:
        cbpi.add_config_parameter("TFT_Hight", 400, "number", "Choose TFTDisplay hight [pixel], default 400, NO! CBPi reboot required")
        TFThoehe = (cbpi.get_config_parameter("TFT_Hight", None))
        cbpi.app.logger.info("TFTDisplay  - TFThoehe added: %s" % (TFThoehe))
    return TFThoehe
Exemplo n.º 11
0
def auth_password():
  password = cbpi.get_config_parameter('auth_password', None)
  if password is None:
    cbpi.add_config_parameter("auth_password", "password", "text", "HTTP Auth password")
    return "password"
  else:
    return password
Exemplo n.º 12
0
def set_lcd_address():
    adr = cbpi.get_config_parameter('LCD_Address', None)
    if adr is None:
        cbpi.add_config_parameter('LCD_Address', '0x27', 'string',
                                  'Address of the LCD, CBPi reboot required')
        adr = cbpi.get_config_parameter('LCD_Address', None)
    return adr
Exemplo n.º 13
0
def init(cbpi):
    cbpi.app.logger.info("JSONServer: start init")

    try:

        cbpi.app.logger.info("JSONServer: initiate parameters")
        # setup json server parameters
        param = cbpi.get_config_parameter('json_server_port', None)
        if param is None:
            cbpi.app.logger.info("JSONServer: create json_server_port system parameter")
            try:
                cbpi.add_config_parameter('json_server_port', DEFAULT_SERVER_PORT, 'number', "JSON Server Port")
            except Exception as e:
                cbpi.app.logger.error("JSONServer: {}".format(e))

        param = cbpi.get_config_parameter('json_cache_age', None)
        if param is None:
            cbpi.app.logger.info("JSONServer: create json_cache_age system parameter")
            try:
                cbpi.add_config_parameter('json_cache_age', DEFAULT_CACHE_AGE, 'number', "JSON Data Cache Age (Seconds)")
            except Exception as e:
                cbpi.app.logger.error("JSONServer: {}".format(e))

        cbpi.app.logger.info("JSONServer: initiate http server")
        port = int(cbpi.get_config_parameter('json_server_port', DEFAULT_SERVER_PORT))
        httpd = HTTPServer(('',port), cbpi_json_request_handler)
        server_thread = Thread(target=httpd.serve_forever)
        server_thread.daemon = True
        server_thread.start()

        cbpi.app.logger.info("JSONServer: end init")

    except Exception as e:
        cbpi.app.logger.error(repr(e))
Exemplo n.º 14
0
def init(cbpi):
    cbpi.app.logger.info("LogLimiter: initialize")

    # setup max lines parameter for sensor etc logs
    param = cbpi.get_config_parameter("max_log_lines", None)
    if param is None:
        cbpi.app.logger.info("LogLimiter: create system parameter")
        try:
            cbpi.add_config_parameter("max_log_lines", DEFAULT_LOG_LINES,
                                      "number", "Max Log Lines")
        except Exception as e:
            cbpi.app.logger.error("LogLimiter: {}".format(e))
    update_max_log_globals()

    # replace default file handler with rotating handler for main app.log
    try:
        new_file_handler = logging.handlers.TimedRotatingFileHandler(
            APP_LOG, when='midnight', interval=1, backupCount=7)
        new_file_handler.setFormatter(logging.Formatter(LOG_FORMAT))
        root_logger = logging.getLogger()
        for one_handler in root_logger.handlers:
            if isinstance(one_handler, logging.FileHandler):
                root_logger.removeHandler(one_handler)
        root_logger.addHandler(new_file_handler)
        cbpi.app.logger.info("LogLimiter: logger file handler replaced")
    except Exception as e:
        cbpi.app.logger.error("LogLimiter: {}".format(e))
Exemplo n.º 15
0
def set_FermentationOn():
    fermon = cbpi.get_config_parameter("TFT_Fermenter_ID", None)
    if fermon is None:
        fermon = 1
        cbpi.add_config_parameter ("TFT_Fermenter_ID", 1, "number", "Choose fermenter (Number) NO! CBPi reboot required")
        cbpi.app.logger.info("TFTDisplay  - TFT_Fermenter_ID added: %s" % (fermon))
    return fermon
Exemplo n.º 16
0
def init(cbpi):
    log("Brefather Fermenter plugin Initialize", True)

    global brewfather_fermenter_comment
    global brewfather_custom_stream

    brewfather_fermenter_comment = cbpi.get_config_parameter(
        "brewfather_fermenter_comment", None)
    brewfather_custom_stream = cbpi.get_config_parameter(
        "brewfather_custom_stream", None)

    if brewfather_fermenter_comment is None:
        try:
            cbpi.add_config_parameter("brewfather_fermenter_comment", "",
                                      "text", "Brefather Fermenter Comment")
        except:
            cbpi.notify("Brefather Error",
                        "Unable to update Brefather comment parameter",
                        type="danger")

    if brewfather_custom_stream is None:
        try:
            cbpi.add_config_parameter("brewfather_custom_stream", "", "text",
                                      "Brefather custom data string")
        except:
            cbpi.notify("Brefather Error",
                        "Unable to update Brefather custom data string",
                        type="danger")
    pass
Exemplo n.º 17
0
def set_parameter_id1():
    kid1 = cbpi.get_config_parameter("LCD_Singledisplay", None)
    if kid1 is None:
        cbpi.add_config_parameter(
            "LCD_Singledisplay", 1, "number",
            "Choose Kettle (Number), NO! CBPi reboot required")
        kid1 = cbpi.get_config_parameter('LCD_Singledisplay', None)
    return kid1
Exemplo n.º 18
0
def set_duration():
    dur = cbpi.get_config_parameter("TFT_Duration", None)
    if dur is None:
        dur = "40m"
        cbpi.add_config_parameter ("TFT_Duration", "40m", "string", "Choose time elapsed to be displayed, default is 40m (40 minutes), have a look at readme, NO! CBPi reboot required")        
        cbpi.app.logger.info("TFTDisplay  - TFT_Duration added: %s" % (dur))
    dur = ("-%s" % (dur))
    return dur
Exemplo n.º 19
0
def set_TFT_RedrawTime():
    rt = cbpi.get_config_parameter("TFT_RedrawTime", None)
    if rt is None:
        rt = 120
        cbpi.add_config_parameter ("TFT_RedrawTime", 120, "number", "Choose time [sec] between redraws (flashes), default is 120sec, NO! CBPi reboot required")
        cbpi.app.logger.info("TFTDisplay  - TFT_RedrawTime added: %s" % (rt))
    rt = (int(rt) / 2)  # intervall of backgroundtask is 2sec so if we want sec in the parameter we devide with 2
    return rt    
Exemplo n.º 20
0
def bc_api_key():
    api_key = cbpi.get_config_parameter('brewerschronicle_api_key', None)
    if api_key is None:
        cbpi.add_config_parameter("brewerschronicle_api_key", "", "text",
                                  "Brewers Chronicle API Key")
        return ""
    else:
        return api_key
Exemplo n.º 21
0
def set_serial_port():
    port = cbpi.get_config_parameter("NEXTION_Serial_Port", None)
    if port is None:
        port = "/dev/ttyUSB0"
        cbpi.add_config_parameter("NEXTION_Serial_Port", "/dev/ttyUSB0", "string",
                                  "Select the Serial Port, Windows like COM1, Linux like dev/ttyS0,"
                                  " /dev/ttyAM0, /dev/ttyUSB0, etc.")
        cbpi.app.logger.info("TFTDisplay - NEXTION_Serial_Port added: %s" % port)
    return port
Exemplo n.º 22
0
def set_time_between_display_change():
    ref = cbpi.get_config_parameter('LCD_Show_temp_time', None)
    if ref is None:
        cbpi.add_config_parameter(
            'LCD_Show_temp_time', 2, 'select',
            'Time to remain till next temperature display in sec, NO! CBPi reboot required',
            [1, 2, 3, 4, 5, 6])
        ref = cbpi.get_config_parameter('LCD_Refresh', None)
    return ref
Exemplo n.º 23
0
 def get_dev(self):
     self.speed = cbpi.get_config_parameter("PCA_" + self.a_busad + "_Hz",
                                            None)
     if self.speed is None:
         self.speed = "50"
         cbpi.add_config_parameter("PCA_" + self.a_busad + "_Hz", "50",
                                   "text", "PCA Frequency")
     print self.speed
     self.dev = Device(self.busad)
Exemplo n.º 24
0
def set_parameter_multidisplay():
    multi = cbpi.get_config_parameter('LCD_Multidisplay', None)
    if multi is None:
        cbpi.add_config_parameter(
            'LCD_Multidisplay', 'on', 'select',
            'Toggle between all Kettles or show only one Kette constantly, NO! CBPi reboot required',
            ['on', 'off'])
        multi = cbpi.get_config_parameter('LCD_Multidisplay', None)
    return multi
Exemplo n.º 25
0
def blynkDB():
	global blynk_auth	
	blynk_auth = cbpi.get_config_parameter("blynk_auth_token", None)
	if blynk_auth is None:
		print "INIT BLYNK DB"
		try:
			cbpi.add_config_parameter("blynk_auth_token", "", "text", "Blynk Authentication Token")
		except:
			cbpi.notify("Blynk Error", "Unable to update database. Update CraftBeerPi and reboot.", type="danger", timeout=10000)
Exemplo n.º 26
0
def ubidotsAPI():
    global ubidots_token
    ubidots_token = cbpi.get_config_parameter("ubidots_token", None)
    if ubidots_token is None:
        log("Init Ubidots Token")
        try:
            cbpi.add_config_parameter("ubidots_token", "", "text", "Ubidots API Token")
        except:
            cbpi.notify("Ubidots Error", "Unable to update config parameter", type="danger")
Exemplo n.º 27
0
def ubidotsLabel():
    global ubidots_label
    ubidots_label = cbpi.get_config_parameter("ubidots_label", None)
    if ubidots_label is None:
        log("Init Ubidots Config Label ID")
        try:
            cbpi.add_config_parameter("ubidots_label", "", "text", "Ubidots API Label")
        except:
            cbpi.notify("Ubidots Error", "Unable to update config parameter", type="danger")
Exemplo n.º 28
0
def thingspeakChnID():
    global thingspeak_chnid
    thingspeak_chnid = cbpi.get_config_parameter("thingspeak_chnid", None)
    if thingspeak_chnid is None:
        log("Init ThingSpeak Config Channel ID")
        try:
            cbpi.add_config_parameter("thingspeak_chnid", "", "text", "ThingSpeak Channel ID")
        except:
            cbpi.notify("ThingSpeak Error", "Unable to update config parameter", type="danger")
Exemplo n.º 29
0
def thingspeakAPI():
    global thingspeak_api
    thingspeak_api = cbpi.get_config_parameter("thingspeak_api", None)
    if thingspeak_api is None:
        log("Init ThingSpeak Config API Key")
        try:
            cbpi.add_config_parameter("thingspeak_api", "", "text", "ThingSpeak USER API key")
        except:
            cbpi.notify("ThingSpeak Error", "Unable to update config parameter", type="danger")
Exemplo n.º 30
0
def set_parameter_refresh():
    ref = cbpi.get_config_parameter('LCD_Refresh', None)
    if ref is None:
        cbpi.add_config_parameter(
            'LCD_Refresh', 3, 'select',
            'Time to remain till next display in sec, NO! CBPi reboot required',
            [1, 2, 3, 4, 5, 6])
        ref = cbpi.get_config_parameter('LCD_Refresh', None)
    return ref