本文整理汇总了Python中Domoticz.Debug方法的典型用法代码示例。如果您正苦于以下问题:Python Domoticz.Debug方法的具体用法?Python Domoticz.Debug怎么用?Python Domoticz.Debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domoticz
的用法示例。
在下文中一共展示了Domoticz.Debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [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()
示例2: updStatus
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [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
示例3: UpdateDevice
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def UpdateDevice(Unit, nValue, sValue, updEvery=False):
# Make sure that the Domoticz device still exists (they can be deleted) before updating it
if (Unit in Devices):
if (Devices[Unit].nValue != nValue) or (Devices[Unit].sValue != sValue):
Devices[Unit].Update(nValue, str(sValue))
#Domoticz.Debug("Update "+str(nValue)+":'"+str(sValue)+"' ("+Devices[Unit].Name+")")
elif updEvery:
# Update device even not changed every X minutes - for Temp and Volt values
updMinutes = 15
Domoticz.Debug("LastUpdate: '" + Devices[Unit].LastUpdate + "' ("+Devices[Unit].Name+")")
#devUpdate = datetime.strptime("2017-06-22 18:24:21", "%Y-%m-%d %H:%M:%S")
#devUpdate = datetime.strptime(Devices[Unit].LastUpdate, "%Y-%m-%d %H:%M:%S")
devUpdate = datetime(*(time.strptime(Devices[Unit].LastUpdate, "%Y-%m-%d %H:%M:%S")[0:6]))
devBefore = datetime.now() - devUpdate
if (devBefore > timedelta(minutes=updMinutes)):
Domoticz.Debug("Updated before: " + str(devBefore) + " ("+Devices[Unit].Name+")")
Devices[Unit].Update(nValue, str(sValue))
return
# Generic helper functions
示例4: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def onStart(self):
if Parameters["Mode6"] == "Debug":
Domoticz.Debugging(1)
DumpConfigToLog()
self.FullUpdate = int(Parameters["Mode2"])
# If poll interval between 10 and 60 sec.
if 10 <= int(Parameters["Mode1"]) <= 60:
Domoticz.Log("Update interval set to " + Parameters["Mode1"])
Domoticz.Heartbeat(int(Parameters["Mode1"]))
else:
# If not, set to 20 sec.
Domoticz.Heartbeat(20)
Domoticz.Log("Full update after " + Parameters["Mode2"] + " polls")
# Start the Homewizard connection
self.hwConnect("get-sensors")
return True
示例5: hwConnect
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [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
示例6: onCommand
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def onCommand(self, Unit, Command, Level, Hue):
Domoticz.Debug("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
if (self.isConnected == False):
self.connection.Connect()
return
if (Unit == 1):
if (Command == "Off"):
self.connection.Send("@MAIN:PWR=Standby\r\n")
elif (Command == "On"):
self.connection.Send("@MAIN:PWR=On\r\n")
elif (Unit == 2):
if (Command == "Set Level"):
volume = int(Level)*4/5 - 80
volumeToSend = round(2*volume)/2
self.connection.Send("@MAIN:VOL="+str(volumeToSend)+"\r\n")
elif (Command == "Off"):
self.connection.Send("@MAIN:MUTE=On\r\n")
elif (Command == "On"):
self.connection.Send("@MAIN:MUTE=Off\r\n")
elif (Unit == 3):
input = str(int(int(Level)/10))
self.connection.Send("@MAIN:INP=HDMI" + input + "\r\n")
elif (Unit == 4):
input = str(int(int(Level)/10))
self.connection.Send("@MAIN:INP=AV" + input + "\r\n")
示例7: onHeartbeat
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def onHeartbeat(self):
Domoticz.Debug("onHeartbeat called. Connected: " + str(self.isConnected))
if (self.isConnected == True):
if (self.outstandingPings > 6):
Domoticz.Debug("Missed more than 6 pings - disconnect")
self.connection.Disconnect() # obsolete
self.nextConnect = 0
else:
self.outstandingPings = self.outstandingPings + len(self.commandArray)
for command in self.commandArray:
self.connection.Send(command + "\r\n")
else:
self.outstandingPings = 0
self.nextConnect = self.nextConnect - 1
if (self.nextConnect <= 0):
self.nextConnect = 3
self.connection.Connect() # obsolete
示例8: pollnodes
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [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: onMessage
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def onMessage(self, Connection, Data, Status, Extra):
#Domoticz.Debug("Received: " + str(Data))
command = json.loads(Data.decode("utf-8"))
#Domoticz.Log("Command: " + command['action'])
if command['status'] == "Ok":
action = command['action']
if action == "setConfig":
# Config set
Connection.Send(Message=json.dumps({"action":"getLights"}).encode(encoding='utf_8'), Delay=1)
if action == "getLights":
self.registerDevices(command['result'])
if action == "deviceUpdate":
self.updateDeviceState(command['result'])
if command['status'] == "Failed":
Domoticz.Log("Command {0} failed with error: {1}.".format(command['action'],command['error']))
Domoticz.Log(str(command))
示例10: DumpConfigToLog
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def DumpConfigToLog():
for x in Parameters:
if Parameters[x] != "":
Domoticz.Debug( "'" + x + "':'" + str(Parameters[x]) + "'")
Domoticz.Debug("Device count: " + str(len(Devices)))
for x in Devices:
Domoticz.Debug("Device: " + str(x) + " - " + str(Devices[x]))
Domoticz.Debug("Device ID: '" + str(Devices[x].ID) + "'")
Domoticz.Debug("Device Name: '" + Devices[x].Name + "'")
Domoticz.Debug("Device nValue: " + str(Devices[x].nValue))
Domoticz.Debug("Device sValue: '" + Devices[x].sValue + "'")
Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
return
示例11: LogMessage
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def LogMessage(Message):
if Parameters["Mode6"] == "File":
f = open(Parameters["HomeFolder"] + "plugin.log", "a")
f.write(Message + "\r\n")
f.close()
Domoticz.Debug(Message)
示例12: onConnect
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def onConnect(self, Connection, Status, Description):
global isConnected
if (Status == 0):
isConnected = True
Domoticz.Log("Connected successfully to: "+Parameters["SerialPort"])
# Run RFPlayer configuration
RFpConf()
else:
Domoticz.Log("Failed to connect ("+str(Status)+") to: "+Parameters["SerialPort"])
Domoticz.Debug("Failed to connect ("+str(Status)+") to: "+Parameters["SerialPort"]+" with error: "+Description)
return True
# present de base
示例13: onMessage
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def onMessage(self, Connection, Data):
global Tmprcv
global ReqRcv
###########################################
Tmprcv=Data.decode(errors='ignore')
################## check if more than 1 sec between two message, if yes clear ReqRcv
lastHeartbeatDelta = (datetime.datetime.now()-self.lastHeartbeat).total_seconds()
if (lastHeartbeatDelta > 1):
ReqRcv=''
Domoticz.Debug("Last Message was "+str(lastHeartbeatDelta)+" seconds ago, Message clear")
#Wait not end of data '\r'
if Tmprcv.endswith('\r',0,len(Tmprcv))==False :
ReqRcv+=Tmprcv
else : # while end of data is receive
ReqRcv+=Tmprcv
########## TODO : verifier si une trame ZIA n est pas en milieu de message (2messages collés ou perturbation+ message accoller)
if ReqRcv.startswith("ZIA--{"):
Domoticz.Debug(ReqRcv)
ReadConf(ReqRcv)
if ReqRcv.startswith("ZIA33"):
Domoticz.Debug(ReqRcv)
ReadData(ReqRcv)
ReqRcv=''
self.lastHeartbeat = datetime.datetime.now()
return
# present de base action executer qd une commande est passé a Domoticz
示例14: DumpConfigToLog
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def DumpConfigToLog():
for x in Parameters:
if Parameters[x] != "":
Domoticz.Debug( "'" + x + "':'" + str(Parameters[x]) + "'")
Domoticz.Debug("Device count: " + str(len(Devices)))
for x in Devices:
Domoticz.Debug("Device: " + str(x) + " - " + str(Devices[x]))
Domoticz.Debug("Device ID: '" + str(Devices[x].ID) + "'")
Domoticz.Debug("Device Name: '" + Devices[x].Name + "'")
Domoticz.Debug("Device nValue: " + str(Devices[x].nValue))
Domoticz.Debug("Device sValue: '" + Devices[x].sValue + "'")
Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
Domoticz.Debug("Options: '" + str(Devices[x].Options) + "'")
return
示例15: DecodeInfoType0
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Debug [as 别名]
def DecodeInfoType0(DecData, infoType):
try :
IsCreated=False
x=0
# New device will start at 1 or at last + 1
nbrdevices=0
protocol = DecData['frame']['header']['protocol']
SubType = DecData['frame']['infos']['subType']
id = DecData['frame']['infos']['id']
Domoticz.Debug("id : " + str(id))
Options = {"infoType":infoType, "id": str(id), "protocol": str(protocol)}
Domoticz.Debug("Options to find or set : " + str(Options))
#########check if devices exist ####################
for x in Devices:
#JJE - start
DOptions = Devices[x].Options
# if Devices[x].Options == Options :
if DOptions["protocol"] == Options["protocol"] :
if DOptions["infoType"] == Options["infoType"] :
if DOptions["id"] == Options["id"] :
#JJE - end
IsCreated = True
Domoticz.Log("Devices already exist. Unit=" + str(x))
Domoticz.Debug("Options found in DB: " + str(Devices[x].Options) + " for devices unit " + str(x))
break
if IsCreated == False :
Domoticz.Debug("isCreated = false")
nbrdevices=x
########### create device if not find ###############
if IsCreated == False and Parameters["Mode4"] == "True" :
nbrdevices += 1
Domoticz.Device(Name=protocol + " - " + id, Unit=nbrdevices, Type=16, Switchtype=0).Create()
Devices[nbrdevices].Update(nValue =int(SubType),sValue = str(SubType),Options = Options)
elif IsCreated == True :
############ update device if found###################
Devices[nbrdevices].Update(nValue =int(SubType),sValue = str(SubType))
except:
Domoticz.Log("Error while decoding Infotype0 frame")
return