コード例 #1
0
 def webform_load(self):  # create html page for settings
     webserver.addFormTextBox("RTSP stream", "plugin_522_url",
                              str(self.taskdevicepluginconfig[0]), 255)
     webserver.addFormNote(
         "Specify the full URL to access stream, with password if needed")
     webserver.addFormCheckBox("Enable resize", "plugin_522_resize",
                               self.taskdevicepluginconfig[1])
     webserver.addFormNumericBox("Width to resize", "plugin_522_w",
                                 self.taskdevicepluginconfig[2], 0, 4096)
     webserver.addFormNumericBox("Height to resize", "plugin_522_h",
                                 self.taskdevicepluginconfig[3], 0, 2160)
     webserver.addFormNote(
         "Resize is a bit resource hungry, use only if really needed")
     webserver.addFormCheckBox("Force FFMPEG UDP", "plugin_522_udp",
                               self.taskdevicepluginconfig[4])
     webserver.addFormNote(
         "Certain cheap cameras only knows UDP, and OpenCV >3.0 defaults to TCP. OpenCV >4.0 accepts override."
     )
     webserver.addFormNote(
         "In case the installed opencv is too old, upgrade manually: 'sudo apt remove python3-opencv && sudo pip3 install opencv-python'"
     )
     try:
         if self.initialized and self.enabled:
             try:
                 pname = self.gettaskname()
             except:
                 pname = ""
             if pname == "":
                 pname = "[NAME]"
             url = "image?name=" + str(pname)
             webserver.addHtml("<tr><td>Output image url:</td>")
             if pname == "[NAME]":
                 webserver.addHtml("<td>http://ipaddress:port/image?name=" +
                                   pname)
             else:
                 webserver.addHtml("<td><a href='" + url + "'>/" + url +
                                   "</a></td></tr>")
     except:
         pass
     return True
コード例 #2
0
ファイル: _C021_BLEDirect.py プロジェクト: markbirss/rpieasy
    def webform_load(self):
        webserver.addFormNote("IP and Port parameter is not used!")
        webserver.addFormNote(
            "<a href='https://github.com/enesbcs/ESPEasyRetro/blob/master/ESPEasyRetro/_C021.ino'>ESP32 reference controller</a>"
        )

        webserver.addFormCheckBox("Enable Receiver Service", "receiver",
                                  self.enablerec)
        webserver.addFormNote(
            "Enable this for Gateway/Repeater unit, Disable if you only want to send data!"
        )
        try:
            if self.bleserv is not None:
                webserver.addFormNote("Current Address: " +
                                      str(self.bleserv.getaddress()))
        except:
            pass
        webserver.addFormCheckBox("Enable Sending to Default Master Unit",
                                  "sender", self.enablesend)
        webserver.addFormCheckBox("Enable Direct Sending to Units in P2P list",
                                  "directsender", self.directsend)
        webserver.addFormNote(
            "Please respect MASTER-SLAVE nature of BLE and do not create infinite loops!"
        )
        webserver.addFormTextBox("Default BLE Master Unit address",
                                 "masteraddress", self.defaultdestination, 23)
        webserver.addFormNote(
            "Enable bluetooth then <a href='blescanner'>scan RPIEasy BLE address</a> first."
        )
        webserver.addFormNumericBox("Default destination node index",
                                    "defaultnode", self.defaultunit, 0, 255)
        webserver.addFormNote(
            "Default node index for data sending, only used when Master Unit address is setted"
        )
        return True
コード例 #3
0
    def webform_load(self):
        webserver.addFormTextBox("Command 0", "plugin_511_cmd0",
                                 str(self.taskdevicepluginconfig[0]), 512)
        webserver.addFormTextBox("Command 1", "plugin_511_cmd1",
                                 str(self.taskdevicepluginconfig[1]), 512)
        webserver.addFormNote(
            "Specify OS commands that has to be executed at the speficied state (0/1)"
        )
        webserver.addFormCheckBox("Use threading to run in background",
                                  "plugin_511_th",
                                  self.taskdevicepluginconfig[2])
        webserver.addFormCheckBox("Enable parsing command line before execute",
                                  "plugin_511_parse",
                                  self.taskdevicepluginconfig[3])

        options2 = ["None"]
        optionvalues2 = ["_"]
        for t in range(0, len(Settings.Tasks)):
            if (Settings.Tasks[t] and (type(Settings.Tasks[t])
                                       is not bool)) and (t != self.taskindex):
                for v in range(0, Settings.Tasks[t].valuecount):
                    options2.append("T" + str(t + 1) + "-" + str(v + 1) +
                                    " / " + str(Settings.Tasks[t].taskname) +
                                    "-" + str(Settings.Tasks[t].valuenames[v]))
                    optionvalues2.append(str(t) + "_" + str(v))
        webserver.addHtml("<tr><td>Trigger variable:<td>")
        webserver.addSelector_Head("p511_trigger", False)
        ddata = str(self.taskdevicepluginconfig[4])
        for o in range(len(options2)):
            webserver.addSelector_Item(options2[o], optionvalues2[o],
                                       (str(optionvalues2[o]) == str(ddata)),
                                       False)
        webserver.addSelector_Foot()
        webserver.addFormNumericBox("Trigger Low value", "p511_low",
                                    self.taskdevicepluginconfig[5], -65535,
                                    65535)
        webserver.addFormNumericBox("Trigger High value", "p511_high",
                                    self.taskdevicepluginconfig[6], -65535,
                                    65535)
        return True
コード例 #4
0
def displaytask(taskstr,confstr):
  global pluginparams
  if type(taskstr)==list:
   ts = taskstr
   cs = confstr
  else:
   ts = str(taskstr).split(",")
   cs = str(confstr).split(",")
  pp = -1
  for p in range(len(pluginparams)):
   if int(pluginparams[p]["pluginid"])==int(ts[2]):
    pp = p
    break
  options = []
  optionvalues = []
  for p in range(len(pluginparams)):
    options.append(pluginparams[p]["name"])
    optionvalues.append(pluginparams[p]["pluginid"])
  webserver.addFormSelector("Plugin","pluginid",len(options),options,optionvalues,None,int(ts[2]))
  webserver.addFormNumericBox("Interval","interval",int(ts[7]),0,32768)
  webserver.addFormNumericBox("IDX","idx",int(ts[8]),0,32768)
  if pp>-1:
   try:
    options = []
    optionvalues = []
    for p in range(17):
     options.append("GPIO"+str(p))
     optionvalues.append(p)
    for i in range(0,pluginparams[pp]["pins"]):
     webserver.addFormSelector("Pin"+str(i+1),"pin"+str(i+1),len(options),options,optionvalues,None,int(ts[3+i]))
   except:
    pass
   try:
    if pluginparams[pp]["ports"]>0:
     webserver.addFormNumericBox("Port","port",int(ts[6]),0,32768)
   except:
    pass
   try:
    if pluginparams[pp]["pullup"]>0:
     webserver.addFormCheckBox("Internal pullup","pullup",int(cs[2])==1)
   except:
    pass
   try:
    if pluginparams[pp]["inverse"]>0:
     webserver.addFormCheckBox("Inversed logic","inverse",int(cs[3])==1)
   except:
    pass
   try:
    if len(pluginparams[pp]["conf"])>0:
     for i in range(len(pluginparams[pp]["conf"])):
      typedef = pluginparams[pp]["conf"][i]
      if typedef["type"]=="select":
       webserver.addFormSelector(typedef["name"],"c"+str(i),len(typedef["options"]),typedef["options"],typedef["optionvalues"],None,int(cs[4+i]))
      elif typedef["type"]=="bool":
       webserver.addFormCheckBox(typedef["name"],"c"+str(i),int(cs[4+i])==1)
      elif typedef["type"]=="num":
       webserver.addFormNumericBox(typedef["name"],"c"+str(i),int(cs[4+i]),0,32768)
   except Exception as e:
    print(e)
コード例 #5
0
ファイル: _P005_DHT.py プロジェクト: markbirss/rpieasy
 def webform_load(self):  # create html page for settings
     choice2 = self.taskdevicepluginconfig[1]
     options = ["Adafruit Lib", "Native Python Lib (SzaZo)"]
     optionvalues = [0, 1]
     webserver.addFormSelector("Driver type", "plugin_005_drv", 2, options,
                               optionvalues, None, int(choice2))
     DHT = self.loadlib()
     try:
         choice1 = self.taskdevicepluginconfig[0]
         options = ["DHT11", "DHT22/AM2302"]
         optionvalues = [DHT.DHT11, DHT.DHT22]
         webserver.addFormSelector("Sensor type", "plugin_005_type",
                                   2, options, optionvalues, None,
                                   int(choice1))
     except:
         pass
     webserver.addFormCheckBox("Oversampling", "plugin_005_over",
                               self.timer2s)
     webserver.addFormNote(
         "Strongly recommended to enable oversampling for reliable readings!"
     )
     return True
コード例 #6
0
 def webform_load(self): # create html page for settings
  webserver.addFormTextBox("Report topic","inchannel",self.inchannel,255)
  webserver.addFormTextBox("Command topic","outchannel",self.outchannel,255)
  try:
   kp = self.keepalive
  except:
   kp = 60
  webserver.addFormNumericBox("Keepalive time","keepalive",kp,2,600)
  webserver.addUnit("s")
  try:
   am = self.authmode
   fname = self.certfile
  except:
   am = 0
   fname = ""
  options = ["MQTT","MQTTS/with cert","MQTTS/insecure"]
  optionvalues = [0,1,2]
  webserver.addFormSelector("Mode","c014_mode",len(optionvalues),options,optionvalues,None,int(am))
  webserver.addFormTextBox("Server certificate file","c014_cert",str(fname),120)
  webserver.addBrowseButton("Browse","c014_cert",startdir=str(fname))
  webserver.addFormNote("Upload certificate first at <a href='filelist'>filelist</a> then select here!")
  try:
   lwt = self.lwt_topic
   lwt1 = self.lwtconnmsg
   lwt2 = self.lwtdisconnmsg
  except:
   lwt = "%sysname%/LWT"
   lwt1 = "Online"
   lwt2 = "Offline"
  webserver.addFormTextBox("Controller lwl topic","c014_lwt",lwt,255)
  webserver.addFormTextBox("LWT Connect Message","c014_cmsg",lwt1,255)
  webserver.addFormTextBox("LWT Disconnect Message","c014_dcmsg",lwt2,255)
  webserver.addFormCheckBox("Check conn & reconnect if needed at every 30 sec","c014_reconnect",self.timer30s)
  try:
   webserver.addFormCheckBox("Use JSON payload","c014_usejson",self.useJSON)
  except:
   self.useJSON = False
  return True
コード例 #7
0
 def webform_load(self):
     webserver.addFormNote("Hint: only the Controller Port parameter used!")
     options = ["Primary net", "Secondary net", "Manual"]
     optionvalues = [0, 1, 2]
     try:
         netm = self.netmethod
     except:
         netm = 0
     webserver.addFormSelector("IP address", "c013_net", len(optionvalues),
                               options, optionvalues, None, int(netm))
     try:
         oip = self.ownip
     except:
         oip = ""
     if netm != 2:
         oip = ""
     elif oip == "":
         oip = str(OS.get_ip())
     webserver.addFormTextBox("Force own IP to broadcast", "c013_ip",
                              str(oip), 16)
     webserver.addFormCheckBox("Enable dynamic task number allocation",
                               "c013_dyntask", self.dynamictasknum)
     return True
コード例 #8
0
 def webform_load(self):  # create html page for settings
     bledevs = BLEHelper.find_hci_devices()
     options = []
     optionvalues = []
     if bledevs:
         for bd in bledevs:
             options.append(bd)
             try:
                 optionvalues.append(int(bd[3:]))
             except:
                 optionvalues.append(bd[3:])
     webserver.addFormSelector("Local Device", "plugin_512_dev",
                               len(options), options, optionvalues, None,
                               int(self.taskdevicepluginconfig[2]))
     webserver.addFormTextBox("Device Address", "plugin_512_addr",
                              str(self.taskdevicepluginconfig[0]), 20)
     webserver.addFormNote(
         "Enable blueetooth then <a href='blescanner'>scan MJ_HT_ address</a> first."
     )
     webserver.addFormCheckBox("Add Battery value for non-Domoticz system",
                               "plugin_512_bat",
                               self.taskdevicepluginconfig[1])
     return True
コード例 #9
0
ファイル: _C002_DomoMQTT.py プロジェクト: jabastien/rpieasy
 def webform_load(self):  # create html page for settings
     webserver.addFormTextBox("Controller Publish", "inchannel",
                              self.inchannel, 255)
     webserver.addFormTextBox("Controller Subscribe", "outchannel",
                              self.outchannel, 255)
     try:
         kp = self.keepalive
     except:
         kp = 60
     try:
         p = self.useping
     except:
         p = True
     webserver.addFormNumericBox("Keepalive time", "keepalive", kp, 2, 600)
     webserver.addUnit("s")
     try:
         am = self.authmode
         fname = self.certfile
     except:
         am = 0
         fname = ""
     options = ["MQTT", "MQTTS/with cert", "MQTTS/insecure"]
     optionvalues = [0, 1, 2]
     webserver.addFormSelector("Mode", "c002_mode", len(optionvalues),
                               options, optionvalues, None, int(am))
     webserver.addFormTextBox("Server certificate file", "c002_cert",
                              str(fname), 120)
     webserver.addBrowseButton("Browse", "c002_cert", startdir=str(fname))
     webserver.addFormNote(
         "Upload certificate first at <a href='filelist'>filelist</a> then select here!"
     )
     webserver.addFormCheckBox(
         "Check conn & reconnect if needed at every 30 sec",
         "c002_reconnect", self.timer30s)
     webserver.addFormCheckBox("Use PING messages to check connection",
                               "c002_ping", self.useping)
     return True
コード例 #10
0
    def webform_load(self):  # create html page for settings
        choice1 = str(self.taskdevicepluginconfig[0])  # store display type
        import luma.oled.device
        options = luma.oled.device.__all__
        webserver.addHtml("<tr><td>Display type:<td>")
        webserver.addSelector_Head("p023_type", True)
        for d in range(len(options)):
            webserver.addSelector_Item(options[d], options[d],
                                       (choice1 == options[d]), False)
        webserver.addSelector_Foot()
        choice2 = int(float(
            self.taskdevicepluginconfig[1]))  # store i2c address
        options = ["0x3c", "0x3d"]
        optionvalues = [0x3c, 0x3d]
        webserver.addFormSelector("Address", "p023_adr", len(options), options,
                                  optionvalues, None, choice2)
        webserver.addFormNote(
            "Enable <a href='pinout'>I2C bus</a> first, than <a href='i2cscanner'>search for the used address</a>!"
        )
        choice3 = int(float(
            self.taskdevicepluginconfig[2]))  # store rotation state
        options = ["Normal", "Rotate by 90", "Rotate by 180", "Rotate by 270"]
        optionvalues = [0, 1, 2, 3]
        webserver.addFormSelector("Mode", "p023_rotate", len(optionvalues),
                                  options, optionvalues, None, choice3)
        options = [
            "Default", "128x64", "128x128", "128x32", "96x96", "96x64",
            "64x48", "64x32"
        ]
        choice4 = self.taskdevicepluginconfig[3]  # store resolution
        webserver.addHtml("<tr><td>Resolution:<td>")
        webserver.addSelector_Head("p023_res", False)
        for d in range(len(options)):
            webserver.addSelector_Item(options[d], options[d],
                                       (choice4 == options[d]), False)
        webserver.addSelector_Foot()

        choice5 = int(float(
            self.taskdevicepluginconfig[4]))  # store line count
        webserver.addHtml("<tr><td>Number of lines:<td>")
        webserver.addSelector_Head("p023_linecount", False)
        for l in range(1, self.P23_Nlines + 1):
            webserver.addSelector_Item(str(l), l, (l == choice5), False)
        webserver.addSelector_Foot()
        webserver.addFormNumericBox("Try to display # characters per row",
                                    "p023_charperl",
                                    self.taskdevicepluginconfig[5], 1, 32)
        webserver.addFormNote("Leave it '1' if you do not care")
        webserver.addFormCheckBox("Clear only used lines", "p023_partialclear",
                                  self.taskdevicepluginconfig[6])
        if choice5 > 0 and choice5 < 9:
            lc = choice5
        else:
            lc = self.P23_Nlines
        for l in range(lc):
            try:
                linestr = self.lines[l]
            except:
                linestr = ""
            webserver.addFormTextBox("Line" + str(l + 1),
                                     "p023_template" + str(l), linestr, 128)

        return True
コード例 #11
0
ファイル: _P001_Switch.py プロジェクト: xelzin/rpieasy
 def webform_load(self):
  webserver.addFormNote("Please make sure to select <a href='pinout'>pin configured for input!</a>")
  webserver.addFormCheckBox("Force 10/sec periodic checking of pin","p001_per",self.taskdevicepluginconfig[0])
  return True
コード例 #12
0
    def webform_load(self):  # create html page for settings
        webserver.addFormNote(
            "SPI selector unused as library do not support changing wiring, it is hardcoded!"
        )
        choice1 = str(self.taskdevicepluginconfig[0])  # store display type
        options = [
            '1.54" (200x200)', '1.54"B (200x200)', '1.54"C (150x150)',
            '2.13" (250x122)', '2.13"B (212x104)', '2.7" (264x176)',
            '2.7"B (264x176)', '2.9" (296x128)', '2.9"B (296x128)',
            '4.2" (400x300)', '4.2"B (400x300)', '7.5" (800x480)',
            '7.5"B (800x480)', '9.7" (1200x825)'
        ]
        optionvalues = [
            "154", "154b", "154c", "213", "213b", "270", "270b", "290", "290b",
            "420", "420b", "750", "750b", "970"
        ]
        webserver.addHtml("<tr><td>Display type:<td>")
        webserver.addSelector_Head("p205_type", False)
        for d in range(len(options)):
            webserver.addSelector_Item(options[d], optionvalues[d],
                                       (str(choice1) == str(optionvalues[d])),
                                       False)
        webserver.addSelector_Foot()
        webserver.addFormNote("Enable <a href='pinout'>SPI-0</a> first!")
        webserver.addFormNote(
            "Hardware connection (OLED => Raspberry Pi)<br>VCC->3.3V, GND->GND, SDI->MOSI, SCLK->SCLK, CS-> GPIO8/CE0, D/C->GPIO25 (out), RES->GPIO17 (out), BUSY->GPIO24 (in)"
        )

        choice3 = int(float(
            self.taskdevicepluginconfig[2]))  # store rotation state
        options = ["Normal", "Rotate by 90", "Rotate by 180", "Rotate by 270"]
        optionvalues = [0, 1, 2, 3]
        webserver.addFormSelector("Mode", "p205_rotate", len(optionvalues),
                                  options, optionvalues, None, choice3)

        choice5 = int(float(
            self.taskdevicepluginconfig[4]))  # store line count
        webserver.addHtml("<tr><td>Number of lines:<td>")
        webserver.addSelector_Head("p205_linecount", False)
        for l in range(1, self.P205_Nlines + 1):
            webserver.addSelector_Item(str(l), l, (l == choice5), False)
        webserver.addSelector_Foot()
        webserver.addFormNumericBox("Try to display # characters per row",
                                    "p205_charperl",
                                    self.taskdevicepluginconfig[5], 1, 32)
        webserver.addFormNote("Leave it '1' if you do not care")
        webserver.addFormCheckBox("Clear only used lines", "p205_partialclear",
                                  self.taskdevicepluginconfig[6])
        if choice5 > 0 and choice5 < 9:
            lc = choice5
        else:
            lc = self.P205_Nlines
        for l in range(lc):
            try:
                linestr = self.lines[l]
            except:
                linestr = ""
            webserver.addFormTextBox("Line" + str(l + 1),
                                     "p205_template" + str(l), linestr, 128)

        return True
コード例 #13
0
 def webform_load(self):
  webserver.addFormNote("IP and Port parameter is not used!")
  webserver.addFormNote("SX127x hardware supported by pyLoRa library")
  webserver.addHtml("<p>Example sender sketches could be find <a href='https://github.com/enesbcs/EasyLora'>here</a>.")
#  if self.lora is not None:
#    webserver.addFormNote("LoRa version: "+str(self.lora.get_version()))
  try:
   webserver.addTableSeparator("Hardware settings",2,3)
   if BOARD.SPI_BUS==0:
    webserver.addHtml("<tr><td>SPI0 selected<td><i>(MOSI=GPIO10, MISO=GPIO9, SCK=GPIO11, NSS=GPIO8)</i>")
    spiok = False
    if gpios.HWPorts.is_spi_usable(BOARD.SPI_BUS):
     if gpios.HWPorts.is_spi_enabled(BOARD.SPI_BUS):
      webserver.addHtml(" - <b>SPI0 enabled</b>")
      spiok = True
    if spiok==False:
     webserver.addHtml("<tr><td><td>Enable SPI0 first at hardware <a href='pinout'>pinout page</a>!")
   else:
     webserver.addHtml("<tr><td><td>You have modified BOARD constants, so you are an expert!")
   webserver.addHtml("<tr><td>DIO0 (IRQ)<td>GPIO"+str(BOARD.DIO0))
   webserver.addHtml("<tr><td>DIO1<td>GPIO"+str(BOARD.DIO1))
   webserver.addHtml("<tr><td>DIO2<td>GPIO"+str(BOARD.DIO2))
   webserver.addHtml("<tr><td>DIO3<td>GPIO"+str(BOARD.DIO3))
   webserver.addHtml("<tr><td>RST<td>GPIO"+str(BOARD.RST))

   webserver.addTableSeparator("LoRa settings",2,3)
   webserver.addFormFloatNumberBox("Frequency","freq",self.freq,433,928)
   webserver.addUnit("Mhz")
   if self.lora is not None:
     try:
      afreq = self.lora.get_freq()
     except:
      afreq = "UNINITIALIZED"
     webserver.addFormNote("Current frequency: "+str(afreq)+" Mhz")
   webserver.addFormNote("Please check local regulations for your selected frequency!")

   options = ["10%","1%","0.1%"]
   optionvalues = [10,100,1000]
   webserver.addFormSelector("Duty cycle","duty",len(optionvalues),options,optionvalues,None,self.duty)
   webserver.addFormNote("Please check your local Duty cycle regulations for your selected frequency!")

   webserver.addFormNumericBox("Spreading factor","spreading",self.sf,6,12)
   options = ["7.8","10.4","15.6","20.8","31.25","41.7","62.5","125","250","500"]
   optionvalues = [BW.BW7_8, BW.BW10_4, BW.BW15_6, BW.BW20_8, BW.BW31_25, BW.BW41_7, BW.BW62_5, BW.BW125, BW.BW250, BW.BW500]
   webserver.addFormSelector("Bandwidth","bw",len(optionvalues),options,optionvalues,None,self.bw)
   webserver.addUnit("khz")

   options = ["CR4/5","CR4/6","CR4/7","CR4/8"]
   optionvalues = [CODING_RATE.CR4_5,CODING_RATE.CR4_6,CODING_RATE.CR4_7,CODING_RATE.CR4_8]
   webserver.addFormSelector("Coding rate","coding",len(optionvalues),options,optionvalues,None,self.coding)

   webserver.addFormNumericBox("Sync Word","sync",self.sync,0,255)
   webserver.addHtml("( 0x"+format(self.sync, '02x')+" )")
   webserver.addFormNote("Default 0x12, LoRaWAN is 0x34. Nodes can only communicate each other if uses same sync word!")

   webserver.addFormCheckBox("Enable Sending","sender",self.enablesend)
   webserver.addFormNumericBox("Default destination node index","defaultnode",self.defaultunit,0,255)
   webserver.addFormNote("Default node index for data sending")
  except Exception as e:
   misc.addLog(rpieGlobals.LOG_LEVEL_ERROR,str(e))
  return True
コード例 #14
0
ファイル: _P212_Dash.py プロジェクト: markbirss/rpieasy
    def webform_load(self):  # create html page for settings
        webserver.addFormCheckBox("Use standard HTML head", "p212_head",
                                  self.taskdevicepluginconfig[2])
        try:
            sp = Settings.AdvSettings["startpage"]
        except:
            sp = "/"
        webserver.addFormCheckBox("Set as startpage", "p212_start",
                                  (sp == "/dash"))
        webserver.addHtml("<tr><td>Columns:<td>")
        webserver.addSelector_Head("p212_cols", False)
        for o in range(7):
            webserver.addSelector_Item(
                str(o), o, (str(o) == str(self.taskdevicepluginconfig[0])),
                False)
        webserver.addSelector_Foot()

        webserver.addHtml("<tr><td>Rows:<td>")
        webserver.addSelector_Head("p212_rows", False)
        for o in range(16):
            webserver.addSelector_Item(
                str(o), o, (str(o) == str(self.taskdevicepluginconfig[1])),
                False)
        webserver.addSelector_Foot()

        if int(self.taskdevicepluginconfig[0]) > 0 and int(
                self.taskdevicepluginconfig[1]) > 0:
            if self.enabled:
                webserver.addHtml(
                    "<tr><td>Dashboard address:</td><td><a href='dash'>/dash</a></td></tr>"
                )
            options1 = [
                "None", "Text", "Binary input", "Switch output", "Meter",
                "Gauge", "Slider output", "Select output"
            ]
            optionvalues1 = [-1, 0, 1, 2, 3, 4, 5, 6]
            options2 = ["None"]
            optionvalues2 = ["_"]
            for t in range(0, len(Settings.Tasks)):
                if (Settings.Tasks[t]
                        and (type(Settings.Tasks[t]) is not bool)):
                    for v in range(0, Settings.Tasks[t].valuecount):
                        options2.append("T" + str(t + 1) + "-" + str(v + 1) +
                                        " / " +
                                        str(Settings.Tasks[t].taskname) + "-" +
                                        str(Settings.Tasks[t].valuenames[v]))
                        optionvalues2.append(str(t) + "_" + str(v))

            for r in range(int(self.taskdevicepluginconfig[1])):
                for c in range(int(self.taskdevicepluginconfig[0])):
                    offs = (r * int(self.taskdevicepluginconfig[0])) + c
                    try:
                        adata = self.celldata[offs]
                    except:
                        adata = {}
                    dtype = -1
                    if "type" in adata:
                        dtype = int(adata["type"])
                    webserver.addHtml("<tr><td><b>Cell" + str(offs) + " (y" +
                                      str(r) + "x" + str(c) + ")</b><td>")

                    dname = ""
                    if "name" in adata:
                        dname = str(adata["name"])
                    webserver.addFormTextBox("Name overwrite",
                                             "p212_names_" + str(offs), dname,
                                             64)

                    webserver.addFormSelector("Type", "p212_type_" + str(offs),
                                              len(options1), options1,
                                              optionvalues1, None, dtype)
                    webserver.addHtml("<tr><td>Data source:<td>")
                    ddata = "_"
                    if "data" in adata:
                        ddata = str(adata["data"])
                    webserver.addSelector_Head("p212_data_" + str(offs), False)
                    for o in range(len(options2)):
                        webserver.addSelector_Item(
                            options2[o], optionvalues2[o],
                            (str(optionvalues2[o]) == str(ddata)), False)
                    webserver.addSelector_Foot()

                    if dtype in (0, 4):
                        try:
                            udata = str(adata["unit"])
                        except:
                            udata = ""
                        webserver.addFormTextBox("Unit",
                                                 "p212_unit_" + str(offs),
                                                 udata, 16)
                    if dtype in (3, 4, 5):
                        try:
                            umin = float(adata["min"])
                        except:
                            umin = 0
                        try:
                            umax = float(adata["max"])
                        except:
                            umax = 100
                        webserver.addFormFloatNumberBox(
                            "Min value", "p212_min_" + str(offs), umin,
                            -65535.0, 65535.0)
                        webserver.addFormFloatNumberBox(
                            "Max value", "p212_max_" + str(offs), umax,
                            -65535.0, 65535.0)
                    elif dtype == 6:
                        try:
                            uon = str(adata["optionnames"])
                        except:
                            uon = ""
                        try:
                            uopt = str(adata["options"])
                        except:
                            uopt = ""
                        webserver.addFormTextBox(
                            "Option name list",
                            "p212_optionnames_" + str(offs), uon, 1024)
                        webserver.addFormTextBox("Option value list",
                                                 "p212_options_" + str(offs),
                                                 uopt, 1024)
                        webserver.addFormNote(
                            "Input comma separated values for selector boxes!")
        return True
コード例 #15
0
ファイル: _P029_DomoOutput.py プロジェクト: markbirss/rpieasy
 def webform_load(self):
  webserver.addFormNote("Please make sure to select <a href='pinout'>pin configured for Output!</a>")
  webserver.addFormCheckBox("Preserve state at startup","p029_preserve",self.taskdevicepluginconfig[0])
  webserver.addFormCheckBox("Response to remote commands for non-Domoticz controllers","p029_report",self.taskdevicepluginconfig[1])
  return True
コード例 #16
0
 def webform_load(self):
  try:
   from pyftdi.ftdi import Ftdi
  except:
   webserver.TXBuffer +="<p>pyftdi not installed!"
   return False

  devlist = get_ftdi_devices(2)
  conflist = get_ftdi_configured_devices()
  webserver.TXBuffer += "<form name='frmselect' method='post'>"
  if len(devlist)>0:
   webserver.TXBuffer += "<fieldset style='padding:5px;margin:5px;border:2px solid green;-moz-border-radius:8px;-webkit-border-radius:8px;border-radius:8px;'><legend>Add USB FTDI devices to pins</legend>"
   for d in range(len(devlist)):
    if not(devlist[d][0] in conflist):
     webserver.TXBuffer += "<input type='radio' name='newdev' value='"+str(d)+"' id='newdev"+str(d)+"'><label for='newdev"+str(d)+"'>"+str(devlist[d][0])+"/"+str(devlist[d][1])+"</label>  "
   webserver.TXBuffer += "</fieldset>"
   webserver.TXBuffer += "<BR>"
   webserver.addSubmitButton()

  webserver.TXBuffer += "<table class='normal'><tr><th colspan=10>GPIO pinout</th></tr>"
  webserver.addHtml("<tr><th>Detected function</th><th>Requested function</th><th>Pin name</th><th>#</th><th>Value</th><th>Value</th><th>#</th><th>Pin name</th><th>Requested function</th><th>Detected function</th></tr>")
  devs = get_ftdi_configured_devices()
  if len(devs)>0:
    for d in range(len(devs)):
     webserver.TXBuffer += "<TR><th colspan=10><strong>FTDI"+str(d)+": "+str(devs[d])+"</strong></td></tr>"
     allpins = 0
     firstp = 0
     lastp = 0
     for p in range(len(Settings.Pinout)):
        if Settings.Pinout[p]["ftdevice"]==devs[d]:
         allpins += 1
         if allpins==1:
          firstp = p
         lastp = p
     halfpins = int(allpins/2)
     for p in range(firstp,firstp+halfpins):
      if Settings.Pinout[p]["canchange"] != 2:
       idnum = int(Settings.Pinout[p]["ID"])

       webserver.TXBuffer += "<TR><td>"
       if Settings.Pinout[p]["canchange"]==1 and Settings.Pinout[p]["BCM"]>0:
      # print pin setup infos
        astate = Settings.Pinout[p]["actualstate"]
        if astate<0:
         astate=0
        astate = Settings.PinStates[astate]
        pinfunc = -1
#      if self.gpioinit:
        pinfunc = self.gpio_function(int(Settings.Pinout[p]["BCM"]))
        astate = str(self.gpio_function_name(pinfunc))
        webserver.TXBuffer += astate
        webserver.TXBuffer += "</td>" # actual state 
       else:
        webserver.TXBuffer += "-</td>"
       if Settings.Pinout[p]["canchange"]==1 and Settings.Pinout[p]["altfunc"]==0:
        webserver.addHtml("<td>") # startupstate
        webserver.addSelector("pinstate"+str(p),Settings.PinStatesMax,Settings.PinStates,False,None,Settings.Pinout[p]["startupstate"],False)
        webserver.addHtml("</td>")
       else:
        webserver.TXBuffer += "<td>-</td>"
       try:
        funcorder = int(Settings.Pinout[p]["altfunc"])
       except:
        funcorder = 0
       pname = ""
       if funcorder>0 and len(Settings.Pinout[p]["name"])>funcorder:
        pname = Settings.Pinout[p]["name"][funcorder]
       else:
        pname = Settings.Pinout[p]["name"][0]
       webserver.TXBuffer += "<td>"+ pname +"</td>"
       webserver.TXBuffer += "<td>"+ str(Settings.Pinout[p]["ID"]) +"</td>"
       webserver.TXBuffer += "<td style='{border-right: solid 1px #000;}'>"
       if Settings.Pinout[p]["canchange"]==1 and pinfunc in [0,1] and (astate in ["Input","Output"]):
#      if self.gpioinit:
        self.setpinstate(p,int(Settings.Pinout[p]["startupstate"]))
        try:
          webserver.TXBuffer += "("+str(self.input(int(Settings.Pinout[p]["BCM"])))+")"
        except:
          webserver.TXBuffer += "E" 
#      else:
#       webserver.TXBuffer += "X" 
        webserver.TXBuffer += "</td>" # add pin value
       else:
        webserver.TXBuffer += "-</td>"
       #right
       q = p + halfpins
       if q<len(Settings.Pinout):
        pinfunc = -1
        if Settings.Pinout[q]["canchange"]==1 and Settings.Pinout[q]["BCM"]>0:
         webserver.TXBuffer += "<td>"
         pinfunc = self.gpio_function(int(Settings.Pinout[q]["BCM"]))
         if pinfunc in [0,1] and Settings.Pinout[q]["altfunc"]==0:
           self.setpinstate(q,int(Settings.Pinout[q]["startupstate"]))
           try:
            webserver.TXBuffer += "("+str(self.input(int(Settings.Pinout[q]["BCM"])))+")"
           except:
            webserver.TXBuffer += "E" 
         webserver.TXBuffer += "</td>" # add pin value
        else:
         webserver.TXBuffer += "<td>-</td>"
        webserver.TXBuffer += "<td>"+ str(Settings.Pinout[q]["ID"]) +"</td>"
        try:
         funcorder = int(Settings.Pinout[q]["altfunc"])
        except:
         funcorder = 0
        pname = ""
        if funcorder>0 and len(Settings.Pinout[q]["name"])>funcorder:
         pname = Settings.Pinout[q]["name"][funcorder]
        else:
         pname = Settings.Pinout[q]["name"][0]
        webserver.TXBuffer += "<td>"+ pname +"</td>"
        webserver.TXBuffer += "<td>"
        if Settings.Pinout[q]["canchange"]==1 and Settings.Pinout[q]["altfunc"]==0:
       # print pin setup infos
         webserver.addSelector("pinstate"+str(q),Settings.PinStatesMax,Settings.PinStates,False,None,Settings.Pinout[q]["startupstate"],False)
         webserver.addHtml("</td>")
        else:
         webserver.TXBuffer += "-</td>"
        webserver.addHtml("<td>") # startupstate
        if Settings.Pinout[q]["canchange"]==1 and Settings.Pinout[q]["BCM"]>0:
         astate = Settings.Pinout[q]["actualstate"]
         if astate<0:
           astate=0
         astate = Settings.PinStates[astate]
 #      if self.gpioinit:
         astate = str(self.gpio_function_name(pinfunc))
         webserver.TXBuffer += str(astate)+"</td>" # actual state 
        else:
         webserver.TXBuffer += "<td>-</td>"
       webserver.TXBuffer += "</TR>"

  webserver.TXBuffer += "</table>"

  webserver.TXBuffer += "<table class='normal'><TR>"
  webserver.addFormHeader("Advanced features")
  devcount = len(get_ftdi_configured_devices())
  for i in range(0,devcount):
   if self.is_i2c_usable(i):
    webserver.addFormCheckBox("Enable I2C-"+str(i),"i2c"+str(i),self.is_i2c_enabled(i))
    webserver.addFormCheckBox("Enable SPI-"+str(i),"spi"+str(i),self.is_spi_enabled(i))
    options = ["1","2","3","4","5"]
    optionvalues = [1,2,3,4,5]
    webserver.addFormSelector("SPI-"+str(i)+" CE count","i2c"+str(i)+"ce",len(optionvalues),options,optionvalues,None,self.get_spi_cs_count(i))

  webserver.addFormSeparator(2)
  webserver.TXBuffer += "<tr><td colspan=2>"
  webserver.addSubmitButton()
  webserver.addSubmitButton("Reread config","reread")
  webserver.TXBuffer += "</td></tr>"
  webserver.addFormNote("WARNING: Some changes needed to reboot after submitting changes! And some changes requires root permission.")
  webserver.addHtml("</table></form>")

  return True