本文整理汇总了Python中Domoticz.Heartbeat方法的典型用法代码示例。如果您正苦于以下问题:Python Domoticz.Heartbeat方法的具体用法?Python Domoticz.Heartbeat怎么用?Python Domoticz.Heartbeat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domoticz
的用法示例。
在下文中一共展示了Domoticz.Heartbeat方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [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: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [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
示例3: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [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: onHeartbeat
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [as 别名]
def onHeartbeat(self):
if (self.blDebug == True):
Domoticz.Log("onHeartbeat called")
if (self.blDiscoverySocketCreated==False): # If the UDP socket has not yet been created, do it now
self.createUDPSocket()
if (self.blDiscoveryRequestSend == True and self.blDiscoverySucces == False):
self.procesDiscoveryData()
if (self.blDiscoverySucces == False):
self.blDiscoveryRequestSend = False # Resend Discovery frame
if (self.blDiscoveryRequestSend == False and self.blDiscoverySocketCreated == True): # If the discovery UDP packet has not been send, send it now
self.sendDiscoveryRequest()
if (self.blConnectInitiated == False and self.blDiscoverySucces == True):
self.connect()
if (self.blConnected==True and self.XMLProcessed==False):
self.workAround()
if (self.XMLProcessed==True and self.blCheckedDevices == False):
self.checkDevices()
if (self.blCheckedDevices == True and self.blCheckedStates == False):
self.getInitialStates()
self.blInitDone = True
Domoticz.Heartbeat(20)
示例5: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [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()
示例6: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [as 别名]
def onStart(self):
if Parameters["Mode6"] == "Debug":
Domoticz.Debugging(1)
Domoticz.Debug("onStart called")
if 1 not in Devices:
Domoticz.Debug("Create Status Device")
Domoticz.Device(Name="Status", Unit=1, Type=17, Switchtype=17, Used=1).Create()
if 2 not in Devices:
Domoticz.Debug("Create Volume Device")
Domoticz.Device(Name="Volume", Unit=2, Type=244, Subtype=73, Switchtype=7, Image=8, Used=1).Create()
if 3 not in Devices:
Domoticz.Debug("Create HDMI Device")
Options = { "LevelActions" : "|||||||",
"LevelNames" : "Off|HDMI1|HDMI2|HDMI3|HDMI4|HDMI5|HDMI6|HDMI7",
"LevelOffHidden" : "true",
"SelectorStyle" : "0"
}
Domoticz.Device(Name="Source", Unit=3, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create()
if 4 not in Devices:
Domoticz.Debug("Create AV Device")
Options = { "LevelActions" : "||||||",
"LevelNames" : "Off|AV1|AV2|AV3|AV4|AV5|AV6",
"LevelOffHidden" : "true",
"SelectorStyle" : "0"
}
Domoticz.Device(Name="AV Source", Unit=4, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create()
self.connection = Domoticz.Connection(Name="Yamaha connection", Transport="TCP/IP", Protocol="Line", Address=Parameters["Address"], Port=Parameters["Port"])
self.connection.Connect()
Domoticz.Heartbeat(20)
示例7: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [as 别名]
def onStart(self):
if Parameters["Mode6"] == "Debug":
self.blDebug = True
Domoticz.Debugging(1)
if (self.blDebug == True):
Domoticz.Log("Onkyo: onStart called")
Domoticz.Heartbeat(2) # Lower hartbeat interval, to speed up the initialization.
示例8: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [as 别名]
def onStart(self):
# Domoticz.Log("onStart called")
if Parameters["Mode6"] == "Debug":
Domoticz.Debugging(1)
Domoticz.Heartbeat(2)
if len(Devices) > 0:
# Some devices are already defined
for aUnit in Devices:
self.lights[Devices[aUnit].DeviceID] = {"DeviceID": Devices[aUnit].DeviceID, "Unit": aUnit}
self.connectToAdaptor()
示例9: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [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)
else:
Domoticz.Heartbeat(20)
try:
self.priority = int(Parameters["Mode1"])
if self.priority<0:
self.LogError("Priority is smaller than 0 ("+Parameters["Mode1"]+") this is not allowed, using 1 as priority")
self.priority = 1
except:
self.LogError("Priority '"+Parameters["Mode1"]+"' is not an integer, using 1 as priority")
self.LogMessage("onStart called", 9)
self.connection = Domoticz.Connection(Name="Hyperion", Transport="TCP/IP", Protocol="None", Address=Parameters["Address"], Port=Parameters["Port"])
# ICONS
if ("HyperionLedRed" not in Images): Domoticz.Image('HyperionLedRed.zip').Create()
if ("HyperionLedBlue" not in Images): Domoticz.Image('HyperionLedBlue.zip').Create()
if ("HyperionLedGreen" not in Images): Domoticz.Image('HyperionLedGreen.zip').Create()
if (1 not in Devices):
Domoticz.Device(Name="Red", Unit=1, Type=244, Subtype=73, Switchtype=7, Image=Images["HyperionLedRed"].ID).Create()
if (2 not in Devices):
Domoticz.Device(Name="Green", Unit=2, Type=244, Subtype=73, Switchtype=7, Image=Images["HyperionLedGreen"].ID).Create()
if (3 not in Devices):
Domoticz.Device(Name="Blue", Unit=3, Type=244, Subtype=73, Switchtype=7, Image=Images["HyperionLedBlue"].ID).Create()
# Devices for color picking do no work since it will not return RGB / HSV values....
#Domoticz.Device(Name="RGB Light", Unit=7, Type=241, Subtype=2, Switchtype=7).Create()
#Domoticz.Device(Name="Saturatie", Unit=8, Type=244, Subtype=73, Switchtype=7).Create()
# set default values:
for i in range(1,4):
try:
self.dimmerValues[i-1] = int(Devices[i].sValue.strip('\''))
except:
pass
self.currentColor[i-1] = self.uiToRGB(self.dimmerValues[i-1])
self.LogMessage("Started current status: " + str(self.currentColor) + " dimmer values: " + str(self.dimmerValues), 2 )
self.DumpConfigToLog()
return
示例10: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [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)
else:
Domoticz.Heartbeat(20)
self.LogMessage("onStart called", 9)
self.connection = Domoticz.Connection(Name="LedenetBinair", Transport="TCP/IP", Protocol="None", Address=Parameters["Address"], Port=Parameters["Port"])
# ICONS
if ("LedenetAutoLight" not in Images): Domoticz.Image('LedenetAutoLight.zip').Create()
if ("LedenetLedRed" not in Images): Domoticz.Image('LedenetLedRed.zip').Create()
if ("LedenetLedBlue" not in Images): Domoticz.Image('LedenetLedBlue.zip').Create()
if ("LedenetLedGreen" not in Images): Domoticz.Image('LedenetLedGreen.zip').Create()
if ("LedenetLedYellow" not in Images): Domoticz.Image('LedenetLedYellow.zip').Create()
# 241 = limitless, subtype 2= RGB/ 1= RGBW, switchtype 7 = philip
# Devices for color picking do no work since it will not return RGB / HSV values....
#Domoticz.Device(Name="RGB Light", Unit=7, Type=241, Subtype=2, Switchtype=7).Create()
#Domoticz.Device(Name="Saturatie", Unit=8, Type=244, Subtype=73, Switchtype=7).Create()
if (1 not in Devices):
Domoticz.Device(Name="Red", Unit=1, Type=244, Subtype=73, Switchtype=7, Image=Images["LedenetLedRed"].ID).Create()
if (2 not in Devices):
Domoticz.Device(Name="Green", Unit=2, Type=244, Subtype=73, Switchtype=7, Image=Images["LedenetLedGreen"].ID).Create()
if (3 not in Devices):
Domoticz.Device(Name="Blue", Unit=3, Type=244, Subtype=73, Switchtype=7, Image=Images["LedenetLedBlue"].ID).Create()
if (4 not in Devices):
Domoticz.Device(Name="White", Unit=4, Type=244, Subtype=73, Switchtype=7, Image=Images["LedenetLedYellow"].ID).Create()
if (5 not in Devices):
Domoticz.Device(Name="Autolight", Unit=5, TypeName="Switch", Image=Images["LedenetAutoLight"].ID).Create()
if (6 not in Devices):
Domoticz.Device(Name="Power", Unit=6, TypeName="Switch").Create()
# autolight is not saves in the devices itself
self.autolight = Devices[5].nValue != 0
if self.autolight:
now = datetime.now()
sunset = self.volgendeZonondergang()
if sunset > now:
self.LogMessage("Autolight enabled, while no sunset yet ("+str(sunset)+"). Disable LED after connected", 1 )
self.mustForceOff = True
# set default values:
self.currentStatus[0] = False
for i in range(1,5):
try:
self.dimmerValues[i] = int(Devices[i].sValue.strip('\''))
except:
pass
self.currentStatus[i] = self.uiToRGB(self.dimmerValues[i])
self.LogMessage("Started current status: " + str(self.currentStatus) + " dimmer values: " + str(self.dimmerValues), 2 )
self.DumpConfigToLog()
return
示例11: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [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)
# self.connection = ...
if (self.regexMac.match(Parameters["Mode1"] )):
self.mac = Parameters["Mode1"]
# replace separators
if len(self.mac) == 12 + 5:
sep = self.mac[2]
self.mac = self.mac.replace(sep, '')
if (self.regexIp.match(Parameters["Address"] )):
self.ip = Parameters["Address"]
else:
self.LogError("'"+Parameters["Address"]+"' is not a valid IP adress." )
self.arping = (Parameters["Mode5"] == "arping")
self.tempFile = Parameters["Mode4"] + "ping_"+Parameters["Address"]
self.LogMessage( "Temp file: " + self.tempFile, 1)
try:
self.wolport = int(Parameters["Port"])
except Exception as e:
self.LogError("Port is not a number: "+ Parameters["Port"])
try:
self.maxOutstandingMessages = int(Parameters["Mode3"])
except Exception as e:
self.LogError("Max missed is not a number: "+ Parameters["Mode3"])
try:
Domoticz.Heartbeat(int(Parameters["Mode2"]))
except:
pass
# initial cleanup
if (os.path.isfile(self.tempFile)):
subprocess.call('sudo chmod +wr '+ self.tempFile , shell=True)
os.remove(self.tempFile)
# create a switch
if (len(Devices) == 0):
Domoticz.Device(Name="Device", Unit=1, TypeName="Switch").Create()
self.lastState = Devices[1].nValue != 0
self.DumpConfigToLog()
return
示例12: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [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)
self.connection = Domoticz.Connection(Name="Hosola_OmnikBinair", Transport="TCP/IP", Protocol="None", Address=Parameters["Address"], Port=Parameters["Port"])
maxOutstandingMessages = int(Parameters["Mode2"])
Domoticz.Heartbeat(int(Parameters["Mode3"]))
self.createInverterId()
# add temperature if not exists
if (1 not in Devices):
Domoticz.Device(Name="Temperature", Unit=1, Type=80, Subtype=5, Switchtype=0, Image=0).Create()
# get total energy
if (4 in Devices):
self.totalEnergy = self.GetTotalEnergy(Devices[4].sValue)
elif (7 in Devices):
self.totalEnergy = self.GetTotalEnergy(Devices[7].sValue)
elif (10 in Devices):
self.totalEnergy = self.GetTotalEnergy(Devices[10].sValue)
self.LogMessage("Current total energy: "+str(self.totalEnergy), 1)
# id 1= temp
# id 2= VAC phase 1
# id 3= VDC phase 1
# id 4= Power phase 1
# id 5= VAC phase 2
# id 6= VDC phase 2
# id 7= Power phase 2
# id 8= VAC phase 3
# id 9= VDC phase 3
# id 10= Power phase 3
#self.checkConnection()
self.DumpConfigToLog()
return
示例13: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Heartbeat [as 别名]
def onStart(self):
if Parameters['Mode4'] == 'Debug':
Domoticz.Debugging(1)
DumpConfigToLog()
self.heartBeatCnt = 0
self.subHost, self.subPort = Parameters['Mode6'].split(':')
self.tcpConn = Domoticz.Connection(Name='MIIOServer', Transport='TCP/IP', Protocol='None',
Address=self.subHost, Port=self.subPort)
if self.iconName not in Images: Domoticz.Image('icons.zip').Create()
iconID = Images[self.iconName].ID
if self.statusUnit not in Devices:
Domoticz.Device(Name='Status', Unit=self.statusUnit, Type=17, Switchtype=17, Image=iconID).Create()
if self.controlUnit not in Devices:
Domoticz.Device(Name='Control', Unit=self.controlUnit, TypeName='Selector Switch',
Image=iconID, Options=self.controlOptions).Create()
if self.fanDimmerUnit not in Devices and Parameters['Mode5'] == 'dimmer':
Domoticz.Device(Name='Fan Level', Unit=self.fanDimmerUnit, Type=244, Subtype=73, Switchtype=7,
Image=iconID).Create()
elif self.fanSelectorUnit not in Devices and Parameters['Mode5'] == 'selector':
Domoticz.Device(Name='Fan Level', Unit=self.fanSelectorUnit, TypeName='Selector Switch',
Image=iconID, Options=self.fanOptions).Create()
if self.batteryUnit not in Devices:
Domoticz.Device(Name='Battery', Unit=self.batteryUnit, TypeName='Custom', Image=iconID,
Options=self.customSensorOptions).Create()
if self.cMainBrushUnit not in Devices:
Domoticz.Device(Name='Care Main Brush', Unit=self.cMainBrushUnit, TypeName='Custom', Image=iconID,
Options=self.customSensorOptions).Create()
if self.cSideBrushUnit not in Devices:
Domoticz.Device(Name='Care Side Brush', Unit=self.cSideBrushUnit, TypeName='Custom', Image=iconID,
Options=self.customSensorOptions).Create()
if self.cSensorsUnit not in Devices:
Domoticz.Device(Name='Care Sensors ', Unit=self.cSensorsUnit, TypeName='Custom', Image=iconID,
Options=self.customSensorOptions).Create()
if self.cFilterUnit not in Devices:
Domoticz.Device(Name='Care Filter', Unit=self.cFilterUnit, TypeName='Custom', Image=iconID,
Options=self.customSensorOptions).Create()
if self.cResetControlUnit not in Devices:
Domoticz.Device(Name='Care Reset Control', Unit=self.cResetControlUnit, TypeName='Selector Switch', Image=iconID,
Options=self.careOptions).Create()
Domoticz.Heartbeat(int(Parameters['Mode2']))