本文整理汇总了Python中Domoticz.Image方法的典型用法代码示例。如果您正苦于以下问题:Python Domoticz.Image方法的具体用法?Python Domoticz.Image怎么用?Python Domoticz.Image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domoticz
的用法示例。
在下文中一共展示了Domoticz.Image方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: UpdateDevice
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [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
示例2: UpdateImage
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [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
示例3: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [as 别名]
def onStart(self):
Domoticz.Debug("onStart called")
if Parameters["Mode6"] == 'Debug':
self.debug = True
Domoticz.Debugging(1)
DumpConfigToLog()
else:
Domoticz.Debugging(0)
# load custom icons
for key, value in icons.items():
if key not in Images:
Domoticz.Image(value).Create()
Domoticz.Debug("Added icon: " + key + " from file " + value)
Domoticz.Debug("Number of icons loaded = " + str(len(Images)))
for image in Images:
Domoticz.Debug("Icon " + str(Images[image].ID) + " " + Images[image].Name)
# check polling interval parameter
try:
temp = int(Parameters["Mode2"])
except:
Domoticz.Error("Invalid polling interval parameter")
else:
if temp < 1:
temp = 1 # minimum polling interval
Domoticz.Error("Specified polling interval too short: changed to 1 hour")
elif temp > 24:
temp = 24 # maximum polling interval is 1 day
Domoticz.Error("Specified polling interval too long: changed to 24 hours")
self.updatefrequency = temp
Domoticz.Log("Using polling interval of {} hour(s)".format(str(self.updatefrequency)))
# get the Prevair station
if Parameters["Mode1"] == "":
station = False
else:
station = Parameters["Mode1"]
ListLL = Settings["Location"].split(";", 1)
Latitude = float(ListLL[0])
Longitude = float(ListLL[1])
self.stationcode, self.stationINSEE, self.stationname, self.stationdistance = getStation(
station, Latitude, Longitude)
Domoticz.Log("using station {}/{} {} at {}km".format(
self.stationcode, self.stationINSEE, self.stationname, self.stationdistance))
# create (if needed) the device to display the selected station details
if not (99 in Devices):
Domoticz.Device(Name="PrevAir Station", Unit=99, TypeName="Text",
Used=1).Create()
# update the device
try:
Devices[99].Update(nValue=0, sValue=self.stationname + " ({}/{}) at {}km".format(
self.stationcode, self.stationINSEE, self.stationdistance))
except:
Domoticz.Error("Failed to update device unit 99")
示例4: UpdateDevice
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [as 别名]
def UpdateDevice(self, Unit, Level, Green, Red):
# Make sure that the Domoticz device still exists (they can be deleted) before updating it
if Unit in Devices:
airlevel = int(Level)
if airlevel <= Green:
icon = "prevairgreen"
elif airlevel >= Red:
icon = "prevairred"
else:
icon = "prevairorange"
try:
Devices[Unit].Update(nValue=0, sValue=str(Level), Image=Images[icon].ID)
except:
Domoticz.Error("Failed to update device unit " + str(Unit))
return
示例5: DumpDeviceToLog
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [as 别名]
def DumpDeviceToLog(self,Unit):
self.LogMessage(str(Devices[Unit].ID)+":"+Devices[Unit].Name+", (n:"+str(Devices[Unit].nValue)+", s:"+Devices[Unit].sValue+", Sgl:"+str(Devices[Unit].SignalLevel)+", bl:"+str(Devices[Unit].BatteryLevel)+", img:"+ str(Devices[Unit].Image)+", typ:"+ str(Devices[Unit].Type)+", styp:"+ str(Devices[Unit].SubType)+")", 6)
return
示例6: UpdateIcon
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [as 别名]
def UpdateIcon(Unit, iconID):
if Unit not in Devices: return
d = Devices[Unit]
if d.Image != iconID: d.Update(d.nValue, d.sValue, Image=iconID)
示例7: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [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
示例8: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [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
示例9: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [as 别名]
def onStart(self):
global icons
Domoticz.Debug("onStart called")
if Parameters["Mode6"] == 'Debug':
self.debug = True
Domoticz.Debugging(1)
DumpConfigToLog()
else:
Domoticz.Debugging(0)
# load custom battery images
for key, value in icons.items():
if key not in Images:
Domoticz.Image(value).Create()
Domoticz.Debug("Added icon: " + key + " from file " + value)
Domoticz.Debug("Number of icons loaded = " + str(len(Images)))
for image in Images:
Domoticz.Debug("Icon " + str(Images[image].ID) + " " + Images[image].Name)
# check polling interval parameter
try:
temp = int(Parameters["Mode1"])
except:
Domoticz.Error("Invalid polling interval parameter")
else:
if temp < 30:
temp = 30 # minimum polling interval
Domoticz.Error("Specified polling interval too short: changed to 30 minutes")
elif temp > 1440:
temp = 1440 # maximum polling interval is 1 day
Domoticz.Error("Specified polling interval too long: changed to 1440 minutes (24 hours)")
self.pollinterval = temp
Domoticz.Log("Using polling interval of {} minutes".format(str(self.pollinterval)))
# find zwave controller(s)... only one active allowed !
self.error = True
controllers = glob.glob("./Config/zwcfg_0x????????.xml")
if not controllers:
# test if we are running on a synology (different file locations)
controllers = glob.glob("/volume1/@appstore/domoticz/var/zwcfg_0x????????.xml")
for controller in controllers:
lastmod = datetime.fromtimestamp(os.stat(controller).st_mtime)
if lastmod < datetime.now() - timedelta(hours=2):
Domoticz.Error("Ignoring controller {} since presumed dead (not updated for more than 2 hours)".format(controller))
else:
self.zwaveinfofilepath = controller
self.error = False
break
if self.error:
Domoticz.Error("Enable to find a zwave controller configuration file !")
示例10: onStart
# 需要导入模块: import Domoticz [as 别名]
# 或者: from Domoticz import Image [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']))