本文整理汇总了Python中Domoticz.Device方法的典型用法代码示例。如果您正苦于以下问题:Python Domoticz.Device方法的具体用法?Python Domoticz.Device怎么用?Python Domoticz.Device使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domoticz
的用法示例。
在下文中一共展示了Domoticz.Device方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [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: Sensors
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def Sensors(self, strData):
Domoticz.Log("No. of sensors found: " + str(len(self.GetValue(strData["response"], "kakusensors",{}))))
for Sensor in self.GetValue(strData["response"], "kakusensors",{}):
sens_id = Sensor["id"] + self.sensor_id
sens_type = self.GetValue(Sensor, "type", "Unknown").lower()
sens_name = self.GetValue(Sensor, "name", "Unknown")
self.hw_types.update({str(sens_id): str(sens_type)})
if ( sens_id not in Devices ):
if ( sens_type == "doorbell" ):
Domoticz.Device(Name=sens_name, Unit=sens_id, Type=17, Switchtype=1).Create()
elif ( sens_type == "motion" ):
Domoticz.Device(Name=sens_name, Unit=sens_id, Type=17, Switchtype=8).Create()
elif ( sens_type == "contact" ):
Domoticz.Device(Name=sens_name, Unit=sens_id, Type=17, Switchtype=2).Create()
elif ( sens_type == "smoke" ) or ( sens_type == "smoke868" ):
Domoticz.Device(Name=sens_name, Unit=sens_id, Type=32, Subtype=3).Create()
return
# TODO: Verify it works...
示例3: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def onStart(self):
try:
self.logLevel = int(Parameters["Mode6"])
except:
self.LogError("Debuglevel '"+Parameters["Mode6"]+"' is not an integer")
if self.logLevel == 10:
Domoticz.Debugging(1)
self.LogMessage("onStart called", 9)
Domoticz.Heartbeat(int(Parameters["Mode2"]))
if (len(Devices) == 0):
Domoticz.Device(Name="Free space", Unit=1, TypeName="Custom", Image=3, Options={"Custom": ("1;" + Parameters["Mode1"])}).Create()
Domoticz.Device(Name="Temperature", Unit=2, Type=80, Subtype=5, Switchtype=0, Image=0).Create()
elif 1 in Devices:
Devices[1].Update(0, "0", Options={"Custom": ("1;" + Parameters["Mode1"])})
self.DumpConfigToLog()
return
示例4: pollnodes
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [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))
示例5: addListeningMode
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def addListeningMode(strCode):
nValue = Devices[MAINLISTENINGMODE].nValue
sValue = Devices[MAINLISTENINGMODE].sValue
dictOptions = Devices[MAINLISTENINGMODE].Options
Domoticz.Log(dictOptions["LevelActions"])
Domoticz.Log(dictOptions["LevelNames"])
dictOptions["LevelNames"] = dictOptions["LevelNames"]+'|['+strCode+']'+' New'
dictOptions["LevelActions"] = dictOptions["LevelActions"]+'|'
Domoticz.Log(dictOptions["LevelActions"])
Domoticz.Log(dictOptions["LevelNames"])
Devices[MAINLISTENINGMODE].Update(nValue = nValue, sValue = sValue, Options = dictOptions)
# Domoticz.Device(Name=(self.XMLRoot.find('device')).find('model').text + \
# ' ' + zone.get('name') + " Mode", Unit=MAINLISTENINGMODE, \
# TypeName="Selector Switch", Switchtype=18, Image=5, \
# Options = dictOptions).Create()
示例6: DumpConfigToLog
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [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
示例7: onHeartbeat
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def onHeartbeat():
_plugin.onHeartbeat()
# Update Device into database
示例8: UpdateImage
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def UpdateImage(Unit):
if Unit in Devices and Parameters["Mode2"] in Images:
LogMessage("Device Image update: '" + Parameters["Mode2"] + "', Currently " + str(Devices[Unit].Image) + ", should be " + str(Images[Parameters["Mode2"]].ID))
if Devices[Unit].Image != Images[Parameters["Mode2"]].ID:
Devices[Unit].Update(nValue=Devices[Unit].nValue, sValue=str(Devices[Unit].sValue), Image=Images[Parameters["Mode2"]].ID)
return
# xml built in parser threw import error on expat so just do it manually
示例9: DumpConfigToLog
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def DumpConfigToLog():
for x in Parameters:
if Parameters[x] != "":
LogMessage( "'" + x + "':'" + str(Parameters[x]) + "'")
LogMessage("Device count: " + str(len(Devices)))
for x in Devices:
LogMessage("Device: " + str(x) + " - " + str(Devices[x]))
LogMessage("Internal ID: '" + str(Devices[x].ID) + "'")
LogMessage("External ID: '" + str(Devices[x].DeviceID) + "'")
LogMessage("Device Name: '" + Devices[x].Name + "'")
LogMessage("Device nValue: " + str(Devices[x].nValue))
LogMessage("Device sValue: '" + Devices[x].sValue + "'")
LogMessage("Device LastLevel: " + str(Devices[x].LastLevel))
return
示例10: DumpConfigToLog
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [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
示例11: DecodeInfoType0
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [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
示例12: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def onStart():
global _pico
if Parameters["Mode6"] == "Debug":
Domoticz.Debugging(1)
Domoticz.Heartbeat(20)
for dev, cfg in deviceDict.items():
if not dev in Devices:
Domoticz.Device(Name=cfg["Name"], Unit=cfg["Unit"], TypeName=cfg["TypeName"]).Create()
Domoticz.Log("Device created: " + cfg["Name"])
result = _pico.getData()
#Domoticz.Log("reg 0x69 0-0x26:" + str(data) + "\nlength:" + str(len(data)))
Domoticz.Log("PCB version: " + _pico.picoData["verPCB"])
Domoticz.Log("Bootloader version: " + _pico.picoData["verBoot"])
Domoticz.Log("FW version: " + str(_pico.picoData["verFW"]))
Domoticz.Log("Bat Powering running time (min): " + str(_pico.picoData["pwrRunTime"]))
Domoticz.Debug("-" * 20)
Domoticz.Debug("BAT Voltage: " + str(_pico.picoData["voltBat"]))
Domoticz.Debug("RPi Voltage: " + str(_pico.picoData["voltRpi"]))
Domoticz.Debug("NTC1 Temperature: " + str(_pico.picoData["tempNtc1"]))
Domoticz.Debug("Powering Mode: " + _pico.picoData["pwrMode"])
Domoticz.Debug("User LED Orange: " + str(_pico.picoData["ledOrange"]))
Domoticz.Debug("User LED Green: " + str(_pico.picoData["ledGreen"]))
Domoticz.Debug("User LED Blue: " + str(_pico.picoData["ledBlue"]))
Domoticz.Debug("Enable LEDs: " + str(_pico.picoData["ledEnable"]))
if result:
UpdateDevice(1, 0, str(_pico.picoData["voltBat"]), updEvery=True)
UpdateDevice(2, 0, str(_pico.picoData["voltRpi"]), updEvery=True)
UpdateDevice(3, 0, str(_pico.picoData["tempNtc1"]), updEvery=True)
UpdateDevice(4, 0, _pico.picoData["pwrMode"])
UpdateDevice(5, _pico.picoData["ledOrange"], "0")
UpdateDevice(6, _pico.picoData["ledGreen"], "0")
UpdateDevice(7, _pico.picoData["ledBlue"], "0")
UpdateDevice(8, _pico.picoData["ledEnable"], "0")
#DumpConfigToLog()
示例13: EnergyMeters
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def EnergyMeters(self, strData):
i = 0
for Energymeter in self.GetValue(strData["response"], "energymeters", {}):
if ( self.en_id+i not in Devices ):
Domoticz.Device(Name="Energymeter", Unit=self.en_id+i, TypeName="kWh").Create()
en_0 = self.GetValue(Energymeter, "po", "0")
en_1 = self.GetValue(Energymeter, "dayTotal", "0")
UpdateDevice(self.en_id+i, 0, str(en_0)+";"+str(en_1 * 1000))
i = i + 1
return
示例14: Switches
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def Switches(self, strData):
Domoticz.Log("No. of switches found: " + str(len(strData["response"]["switches"])))
for Switch in self.GetValue(strData["response"], "switches", {}):
sw_id = Switch["id"] + 1
sw_status = self.GetValue(Switch, "status", "off").lower()
sw_type = self.GetValue(Switch, "type", "switch").lower()
sw_name = self.GetValue(Switch, "name", "switch").lower()
self.hw_types.update({str(sw_id): sw_type})
if ( sw_id not in Devices ):
if ( sw_type == "switch" ) or ( sw_type == "virtual" ):
Domoticz.Device(Name=sw_name, Unit=sw_id, TypeName="Switch").Create()
elif ( sw_type == "dimmer" ):
Domoticz.Device(Name=sw_name, Unit=sw_id, Type=244, Subtype=73, Switchtype=7).Create()
elif ( sw_type == "somfy" ) or ( sw_type == "asun" ):
Domoticz.Device(Name=sw_name, Unit=sw_id, Type=244, Subtype=73, Switchtype=15).Create()
if ( str(sw_status).lower() == "on" ):
if ( sw_type == "dimmer" ):
sw_status = "2"
else:
sw_status = "1"
else:
sw_status = "0"
# Update the switch status
try:
if ( sw_type == "switch" ) or ( sw_type == "virtual" ):
UpdateDevice(sw_id, int(sw_status), "")
elif ( sw_type == "dimmer" ):
UpdateDevice(sw_id, int(sw_status), str(Switch["dimlevel"]))
elif ( sw_type == "somfy" ):
UpdateDevice(sw_id, int(Switch["mode"]), "")
except:
Domoticz.Error("Error at setting device status! Device: "+sw_name)
return
示例15: Thermometers
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Device [as 别名]
def Thermometers(self, strData):
Domoticz.Log("No. of thermometers found: " + str(len(self.GetValue(strData["response"], "thermometers",{}))))
i = 0
for Thermometer in self.GetValue(strData["response"], "thermometers", {}):
if ( self.term_id+i not in Devices ):
Domoticz.Device(Name=Thermometer["name"], Unit=self.term_id+i, TypeName="Temp+Hum").Create()
te_0 = self.GetValue(Thermometer, "te", 0)
hu_0 = self.GetValue(Thermometer, "hu", 0)
UpdateDevice(self.term_id+i, 0, str(te_0)+";"+str(hu_0)+";"+str(self.HumStat(hu_0)))
i = i + 1
return