本文整理汇总了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
示例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()
示例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
示例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
示例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
示例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 #######################
示例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 #######################
示例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))
示例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
示例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
示例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
示例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]
示例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)
示例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)
示例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