當前位置: 首頁>>代碼示例>>Python>>正文


Python Domoticz.Error方法代碼示例

本文整理匯總了Python中Domoticz.Error方法的典型用法代碼示例。如果您正苦於以下問題:Python Domoticz.Error方法的具體用法?Python Domoticz.Error怎麽用?Python Domoticz.Error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Domoticz的用法示例。


在下文中一共展示了Domoticz.Error方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sendMessage

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def sendMessage(self, data, method, url):
        conn = http.client.HTTPConnection(Parameters["Address"] + ":1400")
        headers = {"Content-Type": 'text/xml; charset="utf-8"', "SOAPACTION": method}
        conn.request("POST", url, data, headers)
        response = conn.getresponse()
        conn.close()
    
        if response.status == 200:
            data = response.read().decode("utf-8")
            LogMessage(str(data))
            self.parseMessage(data)
        else:
            Domoticz.Error("Unexpected response status received in function sendMessage (" + str(response.status) + ", " + str(response.reason) + "). \
                            The following command is sent: " + str(method) + ", " + str(url))
        return
    
    # Process message from Sonos 
開發者ID:gerard33,項目名稱:sonos,代碼行數:19,代碼來源:plugin.py

示例2: onStart

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def onStart():
    global switch

    if Parameters["Mode6"] == "Debug":
        Domoticz.Debugging(1)
    if (len(Devices) == 0):
        Domoticz.Device(Name="Switch 1", Unit=1, TypeName="Switch").Create()
        Domoticz.Log("Device created.")
    Domoticz.Heartbeat(30)
    
    switch.ip = Parameters["Address"]
    switch.port = Parameters["Port"]

    try:
        status = switch.status()
    except Exception as e:
        Domoticz.Error('Except onStart: ' + str(e))
        return

    updStatus(status)

    DumpConfigToLog() 
開發者ID:milanvo,項目名稱:domoticz-plugins,代碼行數:24,代碼來源:plugin.py

示例3: updStatus

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def updStatus(status):
    if not status:
        Domoticz.Error('False updStatus: ' + str(status))
        return

    try:
        istatus = int(status)
    except ValueError:
        Domoticz.Error('Except updStatus: ' + str(status))
        return

    Domoticz.Debug('Status: ' + str(status))

    if istatus == 1:
        if (1 in Devices):
            if Devices[1].nValue == 0:
                Devices[1].Update(1,"100")
                Domoticz.Debug('Updated to: ' + str(istatus))
    elif istatus == 0:
        if (1 in Devices):
            if Devices[1].nValue == 1:
                Devices[1].Update(0,"0")
                Domoticz.Debug('Updated to: ' + str(istatus))

# Generic helper functions 
開發者ID:milanvo,項目名稱:domoticz-plugins,代碼行數:27,代碼來源:plugin.py

示例4: hwConnect

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def hwConnect(self, command):
        conn = http.client.HTTPConnection(Parameters["Address"] + ":" + Parameters["Port"], timeout=2)
        Domoticz.Debug("Sending command: "+str(command))
            
        try:
            if ( command == "handshake" ):
                conn.request("GET", "/" + command)
            else:
                conn.request("GET", "/" + Parameters["Password"] + "/" + command)
            response = conn.getresponse()
            conn.close()
    
            if response.status == 200:            
                self.onMessage(response.read(), "200", "")
        except:
            Domoticz.Error("Failed to communicate to system at ip " + Parameters["Address"] + " and port " + Parameters["Port"] + ". Command " + command )
            return False 
開發者ID:rvdvoorde,項目名稱:domoticz-homewizard,代碼行數:19,代碼來源:plugin.py

示例5: getStation

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def getStation(stationID, latitude, longitude):
    stations = PrevAirAPI("http://www2.prevair.org/ineris-web-services.php?url=stations&date=")
    mindistance = 99999  # km
    stationcode = False
    stationINSEE = False
    stationname = "Station Location Error"
    if stationID:
        for station in stations:
            if station[0] == stationID:
                mindistance = 0
                stationcode = stationID
                stationINSEE = station[3]
                stationname = station[4] + " - " + station[1]
                break
    else:
        for station in stations:
            #print(station[0], station[1], station[5], station[6])
            if station[0] != "Code station":  # skip first line of labels
                distance = getDistance(latitude, longitude, float(station[5]), float(station[6]))
                if mindistance > distance:
                    mindistance = distance
                    stationcode = station[0]
                    stationINSEE = station[3]
                    stationname = station[4] + " - " + station[1]
    return stationcode, stationINSEE, stationname, mindistance 
開發者ID:999LV,項目名稱:PrevAir,代碼行數:27,代碼來源:plugin.py

示例6: onHeartbeat

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def onHeartbeat(self):
    self.LogMessage("onHeartbeat called, open messages: " + str(self.outstandingMessages), 9)
    
    try:
      if self.checkConnection(): # checks if connect if not retry
        if self.outstandingMessages > self.maxOutstandingMessages:
          self.sendNullValues()
          self.connection.Disconnect()
        else:
          if len(self.inverterId) > 4: # Only send message if inverter id is known
            self.outstandingMessages = self.outstandingMessages + 1
            if self.outstandingMessages == 1:
              self.connection.Send(self.inverterId)
    except Exception as e:
      self.LogError("OnHeartbeat Error: "+ str(e) )
    
    return

####################### Specific helper functions for plugin ####################### 
開發者ID:ericstaal,項目名稱:domoticz,代碼行數:21,代碼來源:plugin.py

示例7: GetValue

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def GetValue(self, bytes, start, length, divider):
    returnValue = 0.0
    try:
      value = int.from_bytes(bytes[start:(start+length)], byteorder='big')
      if value == 0:
        returnValue = 0
      elif divider != 1:
        returnValue = value / divider
      else:
        returnValue = value
        
      self.DumpVariable(bytes[start:(start+length)], "Start: "+str(start)+" length: "+str(length)+" val: "+str(returnValue)+"("+str(value)+") bytes", Level = 9)
    except Exception as e:
      self.DumpVariable(bytes, "Could get value at idx: "+str(start)+" length: "+str(length)+" Error: "+ str(e)+" from", Level = -1)
    
    return returnValue
  
####################### Generic helper member functions for plugin ####################### 
開發者ID:ericstaal,項目名稱:domoticz,代碼行數:20,代碼來源:plugin.py

示例8: pollnodes

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def pollnodes(self):
        self.BatteryNodes = []
        # poll the openzwave file
        if not self.error:
            try:
                zwavexml = xml.parse(self.zwaveinfofilepath)
                zwave = zwavexml.getroot()
            except:
                Domoticz.Error("Error reading openzwave file {}".format(self.zwaveinfofilepath))
            else:
                for node in zwave:
                    for commandclass in node[1]:  # node[1] is the list of CommandClasses
                        if commandclass.attrib["id"] == "128":  # CommandClass id=128 is BATTERY_LEVEL
                            self.BatteryNodes.append(zwnode(int(node.attrib["id"]), node.attrib["name"],
                                                            int(commandclass[1].attrib["value"])))
                            break

        for node in self.BatteryNodes:
            Domoticz.Debug("Node {} {} has battery level of {}%".format(node.nodeid, node.name, node.level))
            # if device does not yet exist, then create it
            if not (node.nodeid in Devices):
                Domoticz.Device(Name=node.name, Unit=node.nodeid, TypeName="Custom",
                                Options={"Custom": "1;%"}).Create()
            self.UpdateDevice(node.nodeid, str(node.level)) 
開發者ID:999LV,項目名稱:BatteryLevel,代碼行數:26,代碼來源:plugin.py

示例9: UpdateDevice

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def UpdateDevice(self, Unit, Percent):
        # Make sure that the Domoticz device still exists (they can be deleted) before updating it
        if Unit in Devices:
            levelBatt = int(Percent)
            if levelBatt >= 75:
                icon = "batterylevelfull"
            elif levelBatt >= 50:
                icon = "batterylevelok"
            elif levelBatt >= 25:
                icon = "batterylevellow"
            else:
                icon = "batterylevelempty"
            try:
                Devices[Unit].Update(nValue=0, sValue=Percent, Image=Images[icon].ID)
            except:
                Domoticz.Error("Failed to update device unit " + str(Unit))
        return 
開發者ID:999LV,項目名稱:BatteryLevel,代碼行數:19,代碼來源:plugin.py

示例10: onHeartbeat

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def onHeartbeat(self):
        # Check if Sonos is on and available
        try:
            self.sonos_GetTransportInfo()
        except Exception as err:
            Domoticz.Error("Sonos not available (" +  str(err) + ")")
            return
        # Don't update mediainfo if player is stopped
        if self.playerState == 1:
            self.sonos_GetPositionInfo()
        self.sonos_GetVolume()
        self.sonos_GetMute()
        if self.playerState == 1:
            if self.radioState == 1:
                LogMessage("Sonos is playing radio")
                self.sonos_GetMediaInfo()
                ###Dit zorgt ervoor dat de switch aangaat als de radio aan is, maar zorgt ook voor dat switch altijd op svalue 0 wordt voor update met SyncRadioStation
                #UpdateDevice(4, 1, str(self.sonosRadio))
                self.SyncRadioStation()
            else:
                self.sonosRadio = 0
                UpdateDevice(4, 1, str(self.sonosRadio))
        elif self.playerState == 0:
            self.sonosRadio = 0             #set radio selector to off when no radio is played
            ###Naar SyncDevices, maar daar juist uitgezet?
            UpdateDevice(4, 0, str(self.sonosRadio))
        self.SyncDevices()
        return

    # Sends message to Sonos 
開發者ID:gerard33,項目名稱:sonos,代碼行數:32,代碼來源:plugin.py

示例11: extractTagValue

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def extractTagValue(tagName, XML):
    startPos = XML.find(tagName)
    endPos = XML.find(tagName, startPos+1)
    if startPos == -1 or endPos == -1: Domoticz.Error("'" + tagName + "' not found in supplied XML")
    return XML[startPos+len(tagName)+1:endPos-2]

# Check if value is a number 
開發者ID:gerard33,項目名稱:sonos,代碼行數:9,代碼來源:plugin.py

示例12: _extract

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def _extract(self, XML, tagName):
        #print('XML:', XML)
        #print('tagName:', tagName)
        startTag = '<%s>' % (tagName)
        endTag = '</%s>' % (tagName)
        startPos = XML.find(startTag)
        endPos = XML.find(endTag, startPos+1)
        #print('start end:', startPos, endPos)
        if ((startPos == -1) or (endPos == -1)):
            print("'"+tagName+"' not found in supplied XML")
            raise Exception("_extract" + "'"+tagName+"' not found in supplied XML")
            return False
        #if ((startPos == -1) or (endPos == -1)): Domoticz.Error("'"+tagName+"' not found in supplied XML")
        #print('vystup:', XML[startPos+len(startTag):endPos])
        return XML[startPos+len(startTag):endPos] 
開發者ID:milanvo,項目名稱:domoticz-plugins,代碼行數:17,代碼來源:plugin.py

示例13: onCommand

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def onCommand(Unit, Command, Level, Hue):
    global switch

    try:
        if (Command.upper() == 'ON'):
            status = switch.on()
        else:
            status = switch.off()
    except Exception as e:
        Domoticz.Error('Except onCommand: ' + str(e))
        return
    
    updStatus(status) 
開發者ID:milanvo,項目名稱:domoticz-plugins,代碼行數:15,代碼來源:plugin.py

示例14: onHeartbeat

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def onHeartbeat():
    global switch

    try:
        status = switch.status()
    except Exception as e:
        Domoticz.Error('Except onHeartbeat: ' + str(e))
        return

    updStatus(status) 
開發者ID:milanvo,項目名稱:domoticz-plugins,代碼行數:12,代碼來源:plugin.py

示例15: setData

# 需要導入模塊: import Domoticz [as 別名]
# 或者: from Domoticz import Error [as 別名]
def setData(self, device, data):
        addr = 0x6b
        if device in self.regDict:
            reg = self.regDict[device]
            try:
                self.i2c.write_byte_data(addr, reg, data)
                return True
            except Exception as e:
                Domoticz.Error('Except class PicoPlugin setData(): ' + str(e))
        else:
            Domoticz.Error('Error class PicoPlugin setData(): Unknown device' + device)

        return False 
開發者ID:milanvo,項目名稱:domoticz-plugins,代碼行數:15,代碼來源:plugin.py


注:本文中的Domoticz.Error方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。