def onStart(self): # Set debug level according to user setting self.debug = _DEBUG_ON if Parameters["Mode6"] == "Debug" else _DEBUG_OFF Domoticz.Debugging(self.debug) # Show plugin configuration in log if self.debug == _DEBUG_ON: DumpConfigToLog() # Create images if necessary if _IMAGE_NEST_AWAY not in Images: Domoticz.Image("Nest Away.zip").Create() if _IMAGE_NEST_ECO not in Images: Domoticz.Image("Nest Eco.zip").Create() if _IMAGE_NEST_HEATING not in Images: Domoticz.Image("Nest Heating.zip").Create() if _IMAGE_NEST_HEATING_OFF not in Images: Domoticz.Image("Nest Heating Off.zip").Create() if _IMAGE_NEST_PROTECT not in Images: Domoticz.Image("Nest Protect.zip").Create() Domoticz.Debug("> Images created") # Set all devices as timed out TimeoutDevice(All=True) # Create Nest instance self.myNest = nest.Nest(Parameters["Mode1"], Parameters["Mode2"]) Domoticz.Debug("> Plugin started")
def onStart(self): if Parameters["Mode6"] != "Normal": Domoticz.Debugging(1) logDebugMessage(str(Devices)) if (len(Devices) == 0): Domoticz.Device(Name=self.name, Unit=1, TypeName="Custom", Options={ "Custom": "1;%" }, Used=1).Create() logDebugMessage("Device " + self.name + " created.") Domoticz.Heartbeat(self.heartbeat) self.intervalCounter = 0 if ('RoombaOn' not in Images): Domoticz.Image('roombaVacuum.zip').Create() if ('RoombaOff' not in Images): Domoticz.Image('roombaVacuum.zip').Create() try: Devices[1].Update(0, sValue=str(Devices[1].sValue), Image=Images["RoombaOff"].ID) except: logDebugMessage("Error @ device create or exists allraedy.") return True
def onStart(self): if Parameters["Mode6"] != "Normal": Domoticz.Debugging(1) if (len(Devices) == 0): Domoticz.Device(Name="Current power", Unit=1, TypeName="Custom", Options={ "Custom": "1;Watt" }, Used=1).Create() Domoticz.Device(Name="Total power", Unit=2, TypeName="kWh", Used=1).Create() logDebugMessage("Devices created.") Domoticz.Heartbeat(self.heartbeat) self.intervalCounter = 0 if ('FroniusInverter' not in Images): Domoticz.Image('Fronius Inverter Icons.zip').Create() if ('FroniusInverterOff' not in Images): Domoticz.Image('Fronius Inverter Off Icons.zip').Create() Devices[1].Update(0, sValue=str(Devices[1].sValue), Image=Images["FroniusInverter"].ID) Devices[2].Update(0, sValue=str(Devices[2].sValue), Image=Images["FroniusInverter"].ID) return True
def onStart(self): if Parameters["Mode6"] == "Debug": Domoticz.Debugging(1) DumpConfigToLog() if ('Kodi' not in Images): Domoticz.Image('Kodi Icons.zip').Create() if ('KodiBlack' not in Images): Domoticz.Image('KodiBlack Icons.zip').Create() if ('KodiRound' not in Images): Domoticz.Image('KodiRound Icons.zip').Create() if (len(Devices) == 0): Domoticz.Device(Name="Status", Unit=1, Type=17, Switchtype=17).Create() Options = {"LevelActions": "||||", "LevelNames": "Off|Video|Music|TV Shows|Live TV", "LevelOffHidden": "false", "SelectorStyle": "1"} Domoticz.Device(Name="Source", Unit=2, TypeName="Selector Switch", Switchtype=18, Image=12, Options=Options).Create() Domoticz.Device(Name="Volume", Unit=3, Type=244, Subtype=73, Switchtype=7, Image=8).Create() Domoticz.Device(Name="Playing", Unit=4, Type=244, Subtype=73, Switchtype=7, Image=12).Create() Domoticz.Log("Devices created.") if (1 in Devices): UpdateImage(1) self.playerState = Devices[1].nValue if (2 in Devices): UpdateImage(2) self.mediaLevel = Devices[2].nValue if (4 in Devices): UpdateImage(4) self.mediaLevel = Devices[2].nValue self.KodiConn = Domoticz.Connection(Name="KodiConn", Transport="TCP/IP", Protocol="JSON", Address=Parameters["Address"], Port=Parameters["Port"]) self.KodiConn.Connect() if (Parameters["Mode3"] == "True"): Domoticz.Notifier(Parameters["Mode4"]) Domoticz.Heartbeat(10) return True
def onStart(self): if Parameters["Mode6"] == "Debug": Domoticz.Debugging(1) self.heartBeatCnt = 0 self.subHost, self.subPort = Parameters['Mode1'].split(':') self.tcpConn = Domoticz.Connection(Name='LGACServer', Transport='TCP/IP', Protocol='None', Address=self.subHost, Port=self.subPort) #Domoticz.Device(Unit= 1, Name="kWh", TypeName="kWh").Create() Domoticz.Log("onStart called:" +Parameters['Mode3']) #if self.iconName not in Images: Domoticz.Image('CondStatus.zip').Create() #if ("CondStatus" not in Images): # Domoticz.Image('CondStatus.zip').Create() #iconCondID = Images["CondStatus"].ID Images[self.iconName].ID if self.iconCondName not in Images: Domoticz.Image('CondStatus.zip').Create() #iconCondID = Images[self.iconCondName].ID #Domoticz.Debug("Image created. ID: "+str(iconCondID)) #if ("IonStatus" not in Images): # Domoticz.Image('IonStatus.zip').Create() #iconIonID = Images["IonStatus"].ID if self.iconIonName not in Images: Domoticz.Image('IonStatus.zip').Create() #iconIonID = Images[self.iconIonName].ID #Domoticz.Debug("Image created. ID: "+str(iconIonID)) #Domoticz.Device(Name='Status', Unit=2, Type=17, Switchtype=17, Image=iconID).Create() #Domoticz.Device(Name='Setpoint', Unit=3, Type=242, Subtype=1, Image=iconID).Create() if (len(Devices) == 0): Domoticz.Device(Name="Power", Unit=1, Image=19, TypeName="Switch", Used=1).Create() Domoticz.Device(Name="Ambient Temp", Unit=2, TypeName="Temperature", Used=1).Create() Options = {"LevelActions" : "||||", "LevelNames" : "|Heat|Cool|Dry|Fan|Auto", "LevelOffHidden" : "true", "SelectorStyle" : "0"} Domoticz.Device(Name="Mode", Unit=4, TypeName="Selector Switch", Image=16, Options=Options, Used=1).Create() Options = {"LevelActions" : "||||||", "LevelNames" : "|Auto|F1|F2|F3|F4|F5", "LevelOffHidden" : "true", "SelectorStyle" : "0"} Domoticz.Device(Name="Fan Rate", Unit=5, TypeName="Selector Switch", Image=7, Options=Options, Used=1).Create() Domoticz.Device(Name="Setpoint Temp", Unit=6, Type=242, Subtype=1, Image=15, Used=1).Create() if Parameters["Mode5"] == "true": Domoticz.Device(Name="Ionizer", Unit=7, Image=20, TypeName="Switch", Used=1).Create() Domoticz.Device(Name="Care Filter", Unit=8, TypeName='Custom', Image=19, Options=self.customSensorOptions, Used=1).Create() Domoticz.Heartbeat(int(Parameters['Mode3'])) Domoticz.Log("On Start") DumpConfigToLog()
def onStart(self): if Parameters["Mode6"] != "Normal": Domoticz.Debugging(1) if (len(Devices) == 0): Domoticz.Device(Name="House consumption", Unit=1, TypeName="Custom", Options={ "Custom": "1;Watt" }, Used=1).Create() Domoticz.Device(Name="Solar production", Unit=2, TypeName="Custom", Options={ "Custom": "1;Watt" }, Used=1).Create() Domoticz.Device(Name="Energy bought", Unit=3, TypeName="Custom", Options={ "Custom": "1;Watt" }, Used=1).Create() Domoticz.Device(Name="Autonomy rate", Unit=4, TypeName="Percentage", Used=1).Create() logDebugMessage("Devices created.") Domoticz.Heartbeat(self.heartbeat) self.intervalCounter = 0 if ('froniusInverterWithRate' not in Images): Domoticz.Image('Fronius Inverter Icons.zip').Create() if ('froniusInverterWithRateOff' not in Images): Domoticz.Image('Fronius Inverter Off Icons.zip').Create() Devices[1].Update(0, sValue=Devices[1].sValue, Image=Images["froniusInverterWithRate"].ID) Devices[2].Update(0, sValue=Devices[2].sValue, Image=Images["froniusInverterWithRate"].ID) Devices[3].Update(0, sValue=Devices[3].sValue, Image=Images["froniusInverterWithRate"].ID) Devices[4].Update(0, sValue=Devices[4].sValue, Image=Images["froniusInverterWithRate"].ID) return True
def onStart(self): Domoticz.Debug("onStart called") if Parameters['Mode2'] == 'Debug': Domoticz.Debugging(1) if Parameters['Mode1'] == '0': self.discover() return self.nextTimeSync = 0 self.loadConfig() self.CreateDevices() if not self.connect(): return temperature = ir.check_temperature() if temperature > 0: Domoticz.Debug('Temperature is {} degrees.'.format(temperature)) self.temperatureUnit = 1 if (self.iconName not in Images): Domoticz.Image(Filename='Broadlink-icons.zip').Create() iconID = Images[self.iconName].ID else: if (self.iconNameMini not in Images): Domoticz.Image(Filename='Broadlink-mini-icons.zip').Create() iconID = Images[self.iconNameMini].ID if self.commandUnit not in Devices: Domoticz.Device(Name="Command", Unit=self.commandUnit, TypeName="Selector Switch", Switchtype=18, Image=iconID, Options=self.commandOptions, Used=1).Create() if (self.temperatureUnit == 1) and (self.commandUnit + self.temperatureUnit not in Devices): Domoticz.Device(Name="Temperature", Unit=2, TypeName="Temperature", Used=1).Create() if (temperature > 0) and (self.temperatureUnit == 1): Devices[2].Update(nValue=0, sValue=str(temperature), TimedOut=False) DumpConfigToLog() Domoticz.Heartbeat(20)
def onStart(self): # Set debug level according to user setting self.debug = DEBUG_ON if Parameters['Mode6'] == 'Debug' else DEBUG_OFF Domoticz.Debugging(self.debug) if self.debug == DEBUG_ON: DumpConfigToLog(Parameters, Devices) # Read technical parameters try: config = None with open('./plugins/GoogleNest/GoogleNest.json') as json_file: config = json.load(json_file) self.round_temperature = config['RoundTemperature'] except: pass # Create images if necessary if _IMAGE_NEST_AWAY not in Images: Domoticz.Image('Nest Away.zip').Create() if _IMAGE_NEST_ECO not in Images: Domoticz.Image('Nest Eco.zip').Create() if _IMAGE_NEST_HEATING not in Images: Domoticz.Image('Nest Heating.zip').Create() if _IMAGE_NEST_HEATING_OFF not in Images: Domoticz.Image('Nest Heating Off.zip').Create() if _IMAGE_NEST_PROTECT not in Images: Domoticz.Image('Nest Protect.zip').Create() Domoticz.Debug('> Images created') # Set all devices as timed out TimeoutDevice(Devices, All=True) # Create Nest instance if not Parameters['Mode1'].startswith('https://accounts.google.com'): Domoticz.Error( 'Hardware setting issue_token must start with https://accounts.google.com.' ) elif not Parameters['Mode1'].endswith('nest.com'): Domoticz.Error( 'Hardware setting issue_token must end with nest.com.') else: self.myNest = nest.Nest( Parameters['Mode1'], Parameters['Mode2'], float(Parameters['Mode5'].replace(',', '.'))) self.tasksThread.start() self.tasksQueue.put({'Action': 'StatusUpdate'}) self.tasksQueue.put({'Action': 'OutsideWeather'}) Domoticz.Debug('> Plugin started')
def ImportImages(): # # Import ImagesToImport if not already loaded # import glob global ImageDictionary ImageDictionary=GetImageDictionary(LocalHostInfo) if ImageDictionary == {}: Domoticz.Log("ERROR I can not access the image library. Please modify the hardware setup to have the right username and password.") else: for zipfile in glob.glob(HomeFolder+"CustomIcons/*.zip"): importfile=zipfile.replace(HomeFolder,'') try: Domoticz.Image(importfile).Create() Domoticz.Debug("Imported/Updated icons from " + importfile) except: Domoticz.Log("ERROR can not import icons from " + importfile) ImageDictionary=GetImageDictionary(LocalHostInfo) Domoticz.Debug('ImportImages: '+str(ImageDictionary))
def onStart(self): if Parameters["Mode6"] == "Debug": Domoticz.Debugging(1) Domoticz.Debug("onStart called") iconName = 'Yamaha' if iconName not in Images: Domoticz.Image('icons.zip').Create() iconID = Images[iconName].ID self.zones = [] for x in range(1, int(Parameters["Mode1"]) + 1): self.zones.append(Zone(x)) if (int(Parameters["Mode1"]) > 1): self.zones.append(PartyMode()) for zone in self.zones: zone.checkDevices() self.connection = Domoticz.Connection(Name="Yamaha connection", Transport="TCP/IP", Protocol="Line", Address=Parameters["Address"], Port=Parameters["Port"]) self.connection.Connect() Domoticz.Heartbeat(20)
def onStart(self): Domoticz.Debug("onStart called") if Parameters["Mode6"] == "Debug": Domoticz.Debugging(1) else: Domoticz.Debugging(0) # Images # Check if images are in database if "xfr_ziggomediaboxxl" not in Images: Domoticz.Image("xfr_ziggomediaboxxl.zip").Create() try: image = Images["xfr_ziggomediaboxxl"].ID except: image = 0 Domoticz.Debug("Image created. ID: " + str(image)) # Validate parameters # Create devices if (len(Devices) == 0): Domoticz.Device(Unit=self.__UNIT_STATUS, Name="Status", Type=17, Switchtype=17, Image=image, Used=1).Create() # Log config DumpConfigToLog() # Connection self._box = ZiggoMediaboxXL(Parameters["Address"])
def onStart(self): Domoticz.Debug("onStart called") if Parameters["Mode6"] == "Debug": Domoticz.Debugging(1) else: Domoticz.Debugging(0) # Validate parameters # Images # Check if images are in database if "xfrpimonitor" not in Images: Domoticz.Image("xfrpimonitor.zip").Create() image = Images["xfrpimonitor"].ID Domoticz.Debug("Image created. ID: " + str(image)) # Create devices if len(Devices) == 0: for unit in self.__UNITS: Domoticz.Device(Unit=unit[0], Name=unit[1], Type=unit[2], Subtype=unit[3], Options=unit[4], Used=unit[5], Image=image).Create() # Log config DumpAllToLog()
def onStart(self): Domoticz.Heartbeat(60) if Parameters["Mode6"] != "Normal": Domoticz.Debugging(1) subprocess.run(["adb", "connect", Parameters["Mode1"] + ":5555"]) if ('AndroidTVPlugin' not in Images): Domoticz.Image('AndroidTVPlugin Icons.zip').Create() if (len(Devices) == 0): Domoticz.Device(Name="Running App", Unit=1, TypeName="Text", Image=8).Create() Domoticz.Device(Name="Running App Channel", Unit=2, TypeName="Text", Image=8).Create() Domoticz.Device(Name="Running App Program", Unit=3, TypeName="Text", Image=8).Create() Domoticz.Device(Name="Running package", Unit=4, TypeName="Text", Image=8).Create() logDebugMessage("Devices created.") return True
def onStart(self): Domoticz.Log("onStart called") # setting Heartbeat to 20 seconds. Domoticz.Heartbeat(20) # check if icons are installed if ("Dexcom" not in Images): Domoticz.Image('Dexcom.zip').Create() if (len(Devices) == 0): Domoticz.Log("Creating devices in domoticz") # Create first device if (Parameters["Mode2"] == "mg_dl"): Domoticz.Log("Measurement unit mg/dL") Domoticz.Device(Name="Glucose Level", Unit=1, TypeName="Custom", Options={"Custom": "1;mg/dL"}, Image=Images['Dexcom'].ID).Create() elif (Parameters["Mode2"] == "mmol_l"): Domoticz.Log("Measurement unit mmol/L") Domoticz.Device(Name="Glucose Level", Unit=1, TypeName="Custom", Options={"Custom": "1;mmol/L"}, Image=Images['Dexcom'].ID).Create() Domoticz.Device(Name="Glucose Trend", Unit=2, Type=243, Subtype=19, Image=Images['Dexcom'].ID).Create() # get current values self.GetCurrentValues()
def onStart(self): if Parameters['Mode6'] == 'Debug': Domoticz.Debugging(1) DumpConfigToLog() if self.iconName not in Images: Domoticz.Image('icons.zip').Create() iconID = Images[self.iconName].ID if self.bwUpUnit not in Devices: Domoticz.Device(Name='Bandwidth UP', Unit=self.bwUpUnit, TypeName='Custom', Options=self.bwOptions, Image=iconID).Create() if self.bwDownUnit not in Devices: Domoticz.Device(Name='Bandwidth Down', Unit=self.bwDownUnit, TypeName='Custom', Options=self.bwOptions, Image=iconID).Create() if self.statusUnit not in Devices: Domoticz.Device(Name='Status', Unit=self.statusUnit, TypeName='Selector Switch', Image=iconID, Options=self.statusOptions).Create() self.miktConn = Domoticz.Connection(Name='Mikrotik', Transport='TCP/IP', Protocol='None', Address=Parameters['Address'], Port=Parameters['Port']) self.miktConn.Connect() Domoticz.Heartbeat(int(Parameters['Mode1']))
def onStart(self): # Debugging On/Off self.debug = _DEBUG_ON if Parameters["Mode6"] == "Debug" else _DEBUG_OFF Domoticz.Debugging(self.debug) # Create images if necessary if _IMAGE_ROOMBA not in Images: Domoticz.Image("Roomba.zip").Create() # Create devices (USED BY DEFAULT) CreateDevicesUsed() TimeoutDevice(All=True) # Create devices (NOT USED BY DEFAULT) CreateDevicesNotUsed() # Global settings DumpConfigToLog() # Start MQTT try: self.mqttClient = MqttClient('localhost', '1883', self.onMQTTConnected, self.onMQTTDisconnected, self.onMQTTPublish, self.onMQTTSubscribed) except Exception as e: Domoticz.Error("MQTT client start error: " + str(e)) self.mqttClient = None
def onStart(self): import os sourcepath = Parameters["HomeFolder"] if not os.path.isdir(sourcepath): Domoticz.Error(sourcepath + " not found") else: Domoticz.Status("Will import all zipfiles from " + sourcepath + ". Make sure they are all icon files!") allfiles = os.listdir(sourcepath) for thisfile in allfiles: if thisfile.endswith('.zip'): Domoticz.Status("Found " + thisfile) thisname = thisfile[:-4] if thisname in Images: Domoticz.Error("Iconset " + thisname + " already exists") else: fullpath = thisfile Domoticz.Status("Adding iconset " + thisname + " from " + fullpath) newimage = Domoticz.Image(Filename=fullpath) Domoticz.Status("Newimage data=" + str(newimage)) newimage.Create() if thisname in Images: Domoticz.Status("iconset " + thisname + " created") else: Domoticz.Error("iconset " + thisname + " was NOT created!") else: Domoticz.Status(thisfile + " is not a (zip) icon-file") Domoticz.Status("Done importing icons.. disable this plugin!!")
def onStart(self): if Parameters['Mode4'] == 'Debug': Domoticz.Debugging(1) DumpConfigToLog() 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.batteryOptions).Create() # todo remove it in future releases UpdateIcon(self.statusUnit, iconID) UpdateIcon(self.controlUnit, iconID) UpdateIcon(self.fanDimmerUnit, iconID) UpdateIcon(self.batteryUnit, iconID) # ./ Domoticz.Heartbeat(int(Parameters['Mode2']))
def onStart(self): global sockserv Domoticz.Debug("onStart called") if Parameters["Mode6"] == "Debug": Domoticz.Debugging(1) else: Domoticz.Debugging(0) # Validate parameters # Images # Check if images are in database if "xfrpimonitor" not in Images: Domoticz.Image("xfrpimonitor.zip").Create() image = Images["xfrpimonitor"].ID Domoticz.Debug("Image created. ID: " + str(image)) #connect to server host = Parameters["Address"] port = Parameters["Port"] sockserv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) Domoticz.Debug("connect to " + host + " " + str(int(port))) sockserv.connect((host, int(port))) # Create devices if len(Devices) == 0: for unit in self.__UNITS: Domoticz.Device(Unit=unit[0], Name=unit[1], Type=unit[2], Subtype=unit[3], Options=unit[4], Used=unit[5], Image=image).Create() # Log config DumpAllToLog()
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") script_file=os.path.realpath(__file__) Domoticz.Debug ("This script is at {}".format(str(script_file))) script_dir=os.path.dirname(script_file) Domoticz.Debug ("This script lives in {}".format(str(script_dir))) config_path=os.path.join(script_dir,"../../","Config") Domoticz.Debug ("We should look for zwave cfg in {}".format(str(config_path))) config_path_clean=os.path.abspath(config_path) Domoticz.Debug ("Clean config path = {}".format(str(config_path_clean))) Domoticz.Log("Looking for for zwave cfg in {}".format(str(config_path_clean))) controllers = glob.glob(os.path.join(config_path_clean,"./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 !")
def onStart(self): Domoticz.Heartbeat(300) if Parameters["Mode6"] != "Normal": Domoticz.Debugging(1) if ('ICal' not in Images): Domoticz.Image('ICal Icons.zip').Create() if (len(Devices) == 0): Domoticz.Device(Name="Will it rain ?", Unit=1, TypeName="Alert", Used=1).Create() Domoticz.Device(Name="at_work", Unit=2, TypeName="Switch", Used=1).Create() Domoticz.Device(Name="Todo Today", Unit=3, TypeName="Text", Used=1).Create() Domoticz.Device(Name="Next event to come", Unit=4, TypeName="Text", Used=1).Create() logDebugMessage("Devices created.") return True
def createDevices(): # Images # Check if images are in database if "Growatt" not in Images: Domoticz.Image("Growatt.zip").Create() image = Images["Growatt"].ID # Get id from database Domoticz.Log("Image created. ID: " + str(image)) # Are there any devices? ###if len(Devices) != 0: # Could be the user deleted some devices, so do nothing ###return # Give the devices a unique unit number. This makes updating them more easy. # UpdateDevice() checks if the device exists before trying to update it. if (len(Devices) == 0): Domoticz.Device(Name="Inverter (kWh)", Unit=1, TypeName="kWh", Used=1).Create() Domoticz.Log("Inverter Device kWh created.") Domoticz.Device(Name="Inverter (W)", Unit=2, TypeName="Usage", Used=1).Create() Domoticz.Log("Inverter Device (W) created.") Domoticz.Device(Name="Inverter Status", Unit=3, TypeName="Switch", Used=1, Image=image).Create() Domoticz.Log("Inverter Device (Switch) created.")
def onStart(self): if Parameters['Mode6'] == 'Debug': Domoticz.Debugging(1) DumpConfigToLog() self.config = loadConfig(Parameters['Mode1']) if not self.config: return if self.iconName not in Images: Domoticz.Image('icons.zip').Create() iconID = Images[self.iconName].ID for tagMac, tagSettings in self.config.items(): if tagSettings['unit'] not in Devices: Domoticz.Device(Name='Tag %s' % tagMac, Unit=tagSettings['unit'], TypeName='Switch', Image=iconID).Create() host, port = Parameters['Mode2'].split(':') self.udpConn = Domoticz.Connection(Name='UDP', Transport='UDP/IP', Protocol='None', Address=host, Port=port) self.udpConn.Listen() Domoticz.Heartbeat(2)
def onStart(self): Domoticz.Debug("onStart called") if Parameters['Mode2'] == 'Debug': Domoticz.Debugging(1) self.loadConfig() self.CreateDevices() if not self.miio_connect(): return if self.iconName not in Images: Domoticz.Image('Chuangmi-icons.zip').Create() iconID = Images[self.iconName].ID if self.commandUnit not in Devices: Domoticz.Device(Name="Command", Unit=self.commandUnit, TypeName="Selector Switch", Switchtype=18, Image=iconID, Options=self.commandOptions, Used=1).Create() DumpConfigToLog() Domoticz.Heartbeat(20)
def onStart(self): if Parameters["Mode6"] == "Debug": self.debug = True Domoticz.Debugging(1) else: Domoticz.Debugging(0) # load custom battery images Domoticz.Debug('icons=%s,Images=%s' % (icons, Images)) for key, value in icons.items(): if key not in Images: Domoticz.Image(Filename=value).Create() Domoticz.Debug("Added icon: " + key + " from file " + value) Domoticz.Debug('Images=%s' % Images.keys()) 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))) if (len(Devices) == 0): Domoticz.Device(Name="PM2.5 Count", Unit=1, TypeName="Custom").Create() Domoticz.Device(Name="PM2.5 Density", Unit=2, TypeName="Custom", Options={ "Custom": "1; ug/m3" }).Create() Domoticz.Device(Name="Battery Level", Unit=3, TypeName="Custom", Options={ "Custom": "1;%" }).Create() Domoticz.Log("Devices created.") DumpConfigToLog() Domoticz.Log("Plugin is started.")
def onStart(self): #Domoticz.Debugging(1) sys.path.append("/usr/local/lib/python3.4/dist-packages") sys.path.append("/usr/local/lib/python3.5/dist-packages") if bluepyError == 1: Domoticz.Error("Error loading Flora libraries") Domoticz.Debug("Mi Flora - devices made so far (max 255): " + str(len(Devices))) # create custom icons if "Mi-Flower-Mate" not in Images: Domoticz.Log("Creating custom icon for the master Mi Flower Mate poll switch") Domoticz.Image(Filename="Mi-Flower-Mate.zip").Create() if ("Mi-Flower-Mate-Light" not in Images): Domoticz.Log("Creating custom icon for the master Mi Flower Mate light switch") Domoticz.Image(Filename="Mi-Flower-Mate-Light.zip").Create() if ("Mi-Flower-Mate-Moist" not in Images): Domoticz.Log("Creating custom icon for the master Mi Flower Mate moisture switch") Domoticz.Image(Filename="Mi-Flower-Mate-Moist.zip").Create() if ("Mi-Flower-Mate-Temp" not in Images): Domoticz.Log("Creating custom icon for the master Mi Flower Mate temperature switch") Domoticz.Image(Filename="Mi-Flower-Mate-Temp.zip").Create() if ("Mi-Flower-Mate-NPK" not in Images): Domoticz.Log("Creating custom icon for the master Mi Flower Mate conductivity switch") Domoticz.Image(Filename="Mi-Flower-Mate-NPK.zip").Create() # create master toggle switch if 1 not in Devices: Domoticz.Device(Name="update Mi Flowermates", Unit=1, Type=17, Switchtype=9, Image=Images['Mi-Flower-Mate'].ID, Used=1).Create() # get the mac addresses of the sensors if Parameters["Mode1"] == 'auto': Domoticz.Log("Automatic mode is selected") self.floraScan() else: Domoticz.Log("Manual mode is selected") self.macs = parseCSV(Parameters["Mode2"]) self.createSensors()
def onStart(self): # List all robots associated with account botvacSession = PasswordSession(email=Parameters['Username'], password=Parameters['Password'], vendor=Neato()) botvacAccount = Account(botvacSession).robots botvacDevice = next((botvac for botvac in botvacAccount if botvac.name == Parameters["Mode3"]), None) if botvacDevice is None: Domoticz.Log("No robot found") else: self.DEVICE_NAME = botvacDevice.name self.DEVICE_SERIAL = botvacDevice.serial self.API_SECRET = botvacDevice.secret if Parameters["Mode4"] == "Debug": Domoticz.Debugging(1) DumpConfigToLog() #if (self.iconName not in Images): Domoticz.Image('icons.zip').Create() #iconID = Images[self.iconName].ID # Check if images are in database if self.iconName not in Images: Domoticz.Image("icons.zip").Create() try: iconID = Images[self.iconName].ID except: iconID = 0 Domoticz.Debug("Image created. ID: " + str(iconID)) if self.statusUnit not in Devices: Domoticz.Device(Name='Status', Unit=self.statusUnit, Type=17, Switchtype=17, Image=iconID, Used=1).Create() if self.controlUnit not in Devices: Domoticz.Device(Name='Control', Unit=self.controlUnit, TypeName='Selector Switch', Image=iconID, Options=self.controlOptions, Used=1).Create() if self.scheduleUnit not in Devices: Domoticz.Device(Name='Schedule', Unit=self.scheduleUnit, TypeName='Switch', Image=iconID, Used=1).Create() self.botvacGetValues() Domoticz.Heartbeat(self.heartbeatsInterval) Domoticz.Debug("onStart called")
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']))
def get_or_create_unit(friendly_name, unit=None, icon='idetect-unithome'): for d in Devices: if Devices[d].DeviceID == friendly_name: return d #this only runs when doesn't exist #Select or create icons for devices icon_file = {} icon_file['idetect-home'] = "ihome.zip" icon_file['idetect-unithome'] = "iunit.zip" icon_file['idetect-override'] = "ioverride.zip" if not icon in icon_file: Domoticz.Error("Unknown icon requested for " + friendly_name + ": " + icon) try: if icon not in Images: Domoticz.Debug("Getting icon requested for " + friendly_name + ": " + icon + " from file:" + icon_file[icon]) newimage = Domoticz.Image(Filename=icon_file[icon]) newimage.Create() Domoticz.Debug("New image: " + str(newimage)) if icon in Images: icon_id = Images[icon].ID else: icon_id = None except: Domoticz.Error("Could not find or use the required icon file (" + icon_file[icon] + ") for " + icon + ". Plugin installation seems incomplete.") icon_id = None if unit is None: new_unit = find_available_unit() if new_unit is None: Domoticz.Error( 'Could not find available Domticz UnitID to create ' + friendly_name) return None else: new_unit = unit try: Domoticz.Device(Name=friendly_name, Unit=new_unit, DeviceID=friendly_name, TypeName="Switch", Used=1, Image=icon_id).Create() Domoticz.Status("Created device for " + friendly_name + " with unit id " + str(new_unit)) except: Domoticz.Error("FAILED to create device for " + friendly_name + " with unit id " + str(new_unit)) new_unit = None return new_unit
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 MoonPhase 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) # create the mandatory child device if it does not yet exist if 1 not in Devices: Domoticz.Device(Name="Status", Unit=1, TypeName="Custom", Options={ "Custom": "1;Phase" }, Used=1).Create() # check polling interval parameter try: temp = int(Parameters["Mode4"]) except: Domoticz.Error("Invalid polling interval parameter") else: if temp < 60: temp = 60 # minimum polling interval Domoticz.Error( "Specified polling interval too short: changed to 60 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)))