Esempio n. 1
0
 def setHeartbeat(self, callback):
     if self.interval > 30:
         Domoticz.Heartbeat(self.heartbeatRate)
     else:
         Domoticz.Heartbeat(self.interval)
     Domoticz.Log("Heartbeat interval is %s seconds" % (str(self.interval)))
     self.callback = callback
    def onStart(self):
        Domoticz.Log("onStart called")

        if Parameters["Mode6"] == "Debug": 
            self.debug = True
            Domoticz.Debugging(1)
        
        if (len(Devices) == 0):
            Domoticz.Device(Name="Battery", Unit=1, TypeName="Percentage", Used=1).Create()
            Domoticz.Device(Name="Plug Status", Unit=2, TypeName="Text", Used=1).Create()
            Domoticz.Device(Name="Charge Status", Unit=3, TypeName="Text", Used=1).Create()

            Domoticz.Log("Devices created")

        self.updateInterval = int(Parameters["Mode5"])
        self.apiInterval = int(Parameters["Mode4"])
        self.lastApiUpdateTime = datetime.datetime.min # force recheck on start

        if self.updateInterval < 600:
            if self.updateInterval < 30: 
                self.updateInterval == 30
            Domoticz.Log("Update interval set to " + str(self.updateInterval) + " (minimum is 30 seconds)")
            Domoticz.Heartbeat(self.updateInterval)
        else:
            self.updateInterval = 600
            Domoticz.Heartbeat(self.updateInterval)
        
        if self.debug == True:
            DumpConfigToLog()
    def onStart(self):
        #Domoticz.Log("onStart called")
        #global SwitchState
        if (len(Devices) == 0):
            Domoticz.Device(Name="Bluetooth", Unit=1, Type=17,
                            Switchtype=0).Create()
            Domoticz.Log("Devices created.")
        #else:
        #if (1 in Devices): SwitchState = Devices[1].nValue
        #for i in Devices:

        if Parameters["Mode6"] == "Debug":
            self.debug = True
            Domoticz.Debugging(1)
            DumpConfigToLog()

        updateInterval = int(Parameters["Mode5"])

        if updateInterval < 60:
            if updateInterval < 10: updateInterval == 10
            Domoticz.Log("Update interval set to " + str(updateInterval) +
                         " (minimum is 10 seconds)")
            Domoticz.Heartbeat(updateInterval)
        else:
            Domoticz.Heartbeat(60)
Esempio n. 4
0
	def setpollinterval(self, target, delayrun=False):
		if target > 30:
			self.skipbeats=target/30
			if delayrun:
				self.beats=1
			else:
				self.beats=self.skipbeats
			Domoticz.Heartbeat(30)
		else:
			self.skipbeats=0
			self.beats=1
			Domoticz.Heartbeat(target)
    def onStart(self):
        global _tv
        
        if Parameters["Mode6"] == "Debug": 
            Domoticz.Debugging(1)
            self.debug = True

        #TODO: get number of inputs and apps to build list
        
        self.SourceOptions3 =   {   "LevelActions"  : "||||||", 
                                    "LevelNames"    : "Off|TV|HDMI1|HDMI2|HDMI3|Hulu|Netflix|Amazon|Youtube|iPlayer|Unknown",
                                    "LevelOffHidden": "true",
                                    "SelectorStyle" : "0"
                                }
                                    
        if (len(Devices) == 0):
            Domoticz.Device(Name="Status", Unit=1, Type=17, Image=2, Switchtype=17).Create()
            if Parameters["Mode3"] == "Volume": Domoticz.Device(Name="Volume", Unit=2, Type=244, Subtype=73, Switchtype=7, Image=8).Create()
            Domoticz.Device(Name="Source", Unit=3, TypeName="Selector Switch", Switchtype=18, Image=2, Options=self.SourceOptions3).Create()
            Domoticz.Log("Devices created")
        elif (Parameters["Mode3"] == "Volume" and 2 not in Devices):
            Domoticz.Device(Name="Volume", Unit=2, Type=244, Subtype=73, Switchtype=7, Image=8).Create()
            Domoticz.Log("Volume device created")
        elif (Parameters["Mode3"] != "Volume" and 2 in Devices):
            Devices[2].Delete()
            Domoticz.Log("Volume device deleted")
        elif 1 not in Devices:
            Domoticz.Device(Name="Status", Unit=1, Type=17, Image=2, Switchtype=17).Create()
            Domoticz.Log("TV device created")
        elif 3 not in Devices:
            Domoticz.Device(Name="Source", Unit=3, TypeName="Selector Switch", Switchtype=18, Image=2, Options=self.SourceOptions3).Create()
            Domoticz.Log("Source device created")
        else:
            if (1 in Devices): self.tvState = Devices[1].nValue    #--> of sValue
            if (2 in Devices): self.tvVolume = Devices[2].nValue   #--> of sValue
            if (3 in Devices): self.tvSource = Devices[3].sValue
        
        # Set update interval, values below 10 seconds are not allowed due to timeout of 5 seconds in bravia.py script
        updateInterval = int(Parameters["Mode5"])
        if updateInterval < 30:
            if updateInterval < 10: updateInterval == 10
            Domoticz.Log("Update interval set to " + str(updateInterval) + " (minimum is 10 seconds)")
            Domoticz.Heartbeat(updateInterval)
        else:
            Domoticz.Heartbeat(30)
        if self.debug == True:
            DumpConfigToLog()
        if Parameters["Mode4"] != "":
            Domoticz.Notifier(Parameters["Mode4"])
        else:
            Domoticz.Log("Notifications are off, add a Notifier Name to enable.")
        return #--> return True
Esempio n. 6
0
    def onStart(self):
        self.uid = Parameters["Mode3"]
        # If poll interval between 10 and 60 sec.
        if 10 <= int(Parameters["Mode4"]) <= 60:
            Domoticz.Log("Update interval set to " + Parameters["Mode4"])
            Domoticz.Heartbeat(int(Parameters["Mode4"]))
        else:
            # If not, set to 20 sec.
            Domoticz.Heartbeat(30)
        # setup the appropriate logging level
        try:
            debuglevel = int(Parameters["Mode6"])
        except ValueError:
            debuglevel = 0
            self.loglevel = Parameters["Mode6"]
        if debuglevel != 0:
            self.debug = True
            Domoticz.Debugging(debuglevel)
            DumpConfigToLog()
            self.loglevel = "Verbose"
        else:
            self.debug = False
            Domoticz.Debugging(0)

        # check if the host domoticz version supports the Domoticz.Status() python framework function
        try:
            Domoticz.Status(
                "This version of domoticz allows status logging by the plugin (in verbose mode)"
            )
        except Exception:
            self.statussupported = False
        # create the child devices if these do not exist yet

        devicecreated = []
        if 1 not in Devices:
            Domoticz.Device(Name="Heater Temperature",
                            Unit=1,
                            TypeName="Temperature").Create()
            devicecreated.append(deviceparam(1, 0,
                                             "50"))  # default is 50 degrees
        if 2 not in Devices:
            Domoticz.Device(Name="CWU Temperature",
                            Unit=2,
                            TypeName="Temperature").Create()
            devicecreated.append(deviceparam(2, 0,
                                             "50"))  # default is 50 degrees

        for device in devicecreated:
            Devices[device.unit].Update(nValue=device.nvalue,
                                        sValue=device.svalue)
Esempio n. 7
0
    def onStart(self):
        Domoticz.Log("onStart called")

        if Parameters["Mode6"] == "Debug":
            Domoticz.Debugging(1)
        if (len(Devices) == 0):
            Domoticz.Device(Name="Status", Unit=1, Type=17, Image=2, Switchtype=17).Create()
            Domoticz.Log("Devices created.")

        DumpConfigToLog()
        Domoticz.Heartbeat(20)

        self.config = {
            "description":  "Domoticz"              ,
            "host"       :  Parameters["Address"]   ,
            "port"       :  int(Parameters["Port"])
        }

        Domoticz.Log("Connecting to: " + Parameters["Address"] + ":" + Parameters["Port"])

        try:
            self.r = roku.Roku(self.config['host'])
            self.isConnected = True
            Devices[1].Update(nValue=1, sValue='Roku')
        except Exception as e:
            if (self.isConnected == True):
                if Parameters["Mode6"] == "Debug":
                    Domoticz.Log("Devices are connected - Initialisation")
            else:
                Domoticz.Error("Failed to connect: " + e)
Esempio n. 8
0
    def onStart(self):
        Domoticz.Debug("onStart called")
        # setup the appropriate logging level
        try:
            debuglevel = int(Parameters["Mode1"])
        except ValueError:
            debuglevel = 0
            self.loglevel = Parameters["Mode1"]
        if debuglevel != 0:
            self.debug = True
            Domoticz.Debugging(debuglevel)
            DumpConfigToLog(DevId='')
            self.loglevel = "Verbose"
        else:
            self.debug = False
            Domoticz.Debugging(0)

        if Parameters["Mode2"] == 'Yes':
            Domoticz.Debug("RFXrcv-E create all devices seen.")

        self.tcpConn = Domoticz.Connection(Name="RFXrcv-EConn",
                                           Transport="TCP/IP",
                                           Protocol="None",
                                           Address=Parameters["Address"],
                                           Port=Parameters["Port"])
        self.tcpConn.Connect()
        Domoticz.Heartbeat(25)

        self.streamData = bytearray()
        return
Esempio n. 9
0
def onStart():
    global gdeviceSuffix
    global gdeviceTypeName
    global glastSNMPValue
    global interval

    gdeviceSuffix = "(SNMP)"
    interval = int(Parameters["Mode4"])

    createDevices()
    glastSNMPValue = list(range(1, len(Devices) + 1))
    for i in range(0, len(Devices)):
        glastSNMPValue[i] = None

    if Parameters["Mode6"] == "Debug":
        DumpConfigToDebug()

    ServerIP = str(Parameters["Address"])
    snmpOID = str(Parameters["Mode1"])
    snmpCommunity = Parameters["Mode2"]
    #try:
    #   snmpDataValue = str(getSNMPvalue(ServerIP,snmpOID,snmpCommunity))
    #except:
    #  snmpDataValue= None
    onHeartbeat()

    Domoticz.Heartbeat(interval)
    Domoticz.Log("started with " + str(len(Devices)) + " devices")

    return True
Esempio n. 10
0
    def onStart(self):
        if Parameters["Mode6"] == "Debug":
            Domoticz.Debugging(1)

        for var in ['Mode1', 'Mode2', 'Mode3']:
            if Parameters[var] == "":
                Domoticz.Error(
                    'No client_id, client_secret and/or code is set in hardware parameters'
                )
                self.blError = True
                return None

        if not self.getUserVar():
            self.blError = True
            return None

        for key, value in self.spotifyToken.items():
            if value == '':
                Domoticz.Log(
                    "Not all spotify token variables are available, let's get it"
                )
                if not self.spotAuthoriseCode():
                    self.blError = True
                    return None
                break

        self.checkDevices()

        Domoticz.Heartbeat(30)
Esempio n. 11
0
    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
Esempio n. 12
0
 def onStart(self):
     global errmsg
     if errmsg == "":
         try:
             Domoticz.Heartbeat(10)
             self.debugging = Parameters["Mode6"]
             if self.debugging == "Verbose":
                 Domoticz.Debugging(2 + 4 + 8 + 16 + 64)
             if self.debugging == "Debug":
                 Domoticz.Debugging(2)
             self.base_topic = "shellies"  # hardwired
             self.mqttserveraddress = Parameters["Address"].strip()
             self.mqttserverport = Parameters["Port"].strip()
             self.mqttClient = MqttClientSH2(self.mqttserveraddress,
                                             self.mqttserverport, "",
                                             self.onMQTTConnected,
                                             self.onMQTTDisconnected,
                                             self.onMQTTPublish,
                                             self.onMQTTSubscribed)
         except Exception as e:
             Domoticz.Error("MQTT client start error: " + str(e))
             self.mqttClient = None
     else:
         Domoticz.Error(
             "Your Domoticz Python environment is not functional! " +
             errmsg)
         self.mqttClient = None
Esempio n. 13
0
    def onStart(self):

        # Parse options
        self.debugging = Parameters["Mode6"]
        DumpConfigToLog()
        if self.debugging == "Verbose+":
            Domoticz.Debugging(2 + 4 + 8 + 16 + 64)
        if self.debugging == "Verbose":
            Domoticz.Debugging(2 + 4 + 8 + 16 + 64)
        if self.debugging == "Debug":
            Domoticz.Debugging(2 + 4 + 8)
        self.mqttserveraddress = Parameters["Address"].replace(" ", "")
        self.mqttserverport = Parameters["Port"].replace(" ", "")
        self.commands_topic_format = Parameters["Mode2"]
        self.states_topic_format = Parameters["Mode3"]
        self.updates_topic_format = Parameters["Mode4"]

        options = ""
        try:
            options = json.loads(Parameters["Mode5"])
        except ValueError:
            options = ""

        if type(options) == dict:
            self.options.add(options)
        Domoticz.Log("Plugin options: " + str(self.options))

        # Enable heartbeat
        Domoticz.Heartbeat(10)

        # Connect to MQTT server
        self.mqttClient = MqttClient(self.mqttserveraddress,
                                     self.mqttserverport, self.onMQTTConnected,
                                     self.onMQTTDisconnected,
                                     self.onMQTTPublish, self.onMQTTSubscribed)
    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():
    global numberDev, nbUpdate

    if Parameters["Mode6"] == "Debug":
        Domoticz.Debugging(1)
    if (len(Devices) == 0):
        if Parameters["Address"] == '127.0.0.1' and Parameters["Mode1"] == '000000000000':
            Domoticz.Device(Name="Discover",  Unit=1, Type=17, Image=2, Switchtype=17, Used=1).Create()
       
    if ( 1 not in Devices):
        Options =   {   "LevelActions"  :"||||" , 
                        "LevelNames"    :"Off|Learn|Test|Save|Reset" ,
                        "LevelOffHidden":"true",
                        "SelectorStyle" :"0"
                     }    
        Domoticz.Device(Name="Command",  Unit=1, TypeName="Selector Switch", Switchtype=18, Image=12, Options=Options, Used=1).Create()

    if ( 2 not in Devices and Parameters["Mode3"] == 'yes'):
        Domoticz.Device(Name="Temp",  Unit=2, TypeName="Temperature", Used=1).Create()

    DumpConfigToLog()
    Domoticz.Heartbeat(30)
    numberDev = len(Devices)

    Domoticz.Log("Connecting to: "+Parameters["Address"]+":"+Parameters["Mode1"])
    broadlinkConnect()
    UpdateDevice(1, 0, 'Off')    

    return True
Esempio n. 16
0
    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)
Esempio n. 17
0
    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
Esempio n. 18
0
    def onStart(self):
        Domoticz.Debug("Xiaomi LYWSD03MMC - devices made so far (max 255): " +
                       str(len(Devices)))

        if Parameters["Mode6"] != "0":
            Domoticz.Debugging(int(Parameters["Mode6"]))
            DumpConfigToLog()

        # create master toggle switch
        if 1 not in Devices:
            Domoticz.Log(
                "Creating the master Xiaomi LYWSD03MMC poll switch. Flip it to poll the sensors."
            )
            # default SwitchType, not enabled by default
            Domoticz.Device(Name="scanner",
                            Unit=1,
                            Type=244,
                            Subtype=62,
                            Image=9,
                            Used=1).Create()

        # get the mac addresses of the sensors
        if Parameters["Mode1"] == 'auto':
            Domoticz.Log("Automatic mode is selected")
            self.macs = self.load_macs_from_database()
        else:
            Domoticz.Log("Manual mode is selected")
            self.macs = self.parse_csv(Parameters["Mode2"])
            self.create_sensors()

        self.message_thread.start()
        self.ble_thread.start()
        Domoticz.Heartbeat(5)
Esempio n. 19
0
    def onStart(self):
        Domoticz.Debug("onStart called")
        self.username = Parameters["Mode1"]
        self.password = Parameters["Mode2"]
        self.nb_days = Parameters["Mode3"]
        self.pce = Parameters["Mode4"]

        try:
            self.iDebugLevel = int(Parameters["Mode6"])
        except ValueError:
            self.iDebugLevel = 0

        if self.iDebugLevel > 1:
            Domoticz.Debugging(1)

        # most init
        self.__init__()

        if self.createDevice():
            self.nextConnection = datetime.now()
        else:
            self.setNextConnection()

        # Now we can enabling the plugin
        self.isStarted = True
        Domoticz.Heartbeat(20)
Esempio n. 20
0
 def onStart(self):
     if errmsg == "":
         try:
             Domoticz.Heartbeat(10)
             self.debugging = Parameters["Mode6"]
             if self.debugging == "Verbose":
                 Domoticz.Debugging(2+4+8+16+64)
             if self.debugging == "Debug":
                 Domoticz.Debugging(2)
             
             global pluginDebug
             pluginDebug = False
             setTasmotaDebug(True)
             setMqttDebug(False)
             
             Debug("Plugin::onStart: Parameters: {}".format(repr(Parameters)))
             self.mqttserveraddress = Parameters["Address"].strip()
             self.mqttserverport = Parameters["Port"].strip()
             self.mqttClient = MqttClient(self.mqttserveraddress, self.mqttserverport, "",
                                          self.onMQTTConnected, self.onMQTTDisconnected, self.onMQTTPublish, self.onMQTTSubscribed)
             self.mqttClient.debug(False)
             self.tasmotaHandler = Handler(Parameters["Mode4"].strip().split('|'), Parameters["Mode1"].strip(
                 ), Parameters["Mode2"].strip(), Parameters["Mode3"].strip(), self.mqttClient, Devices)
             self.tasmotaHandler.debug(True)
         except Exception as e:
             Domoticz.Error("Plugin::onStart: {}".format(str(e)))
             self.mqttClient = None
     else:
         Domoticz.Error(
             "Plugin::onStart: Domoticz Python env error {}".format(errmsg))
         self.mqttClient = None
Esempio n. 21
0
def onStart():
    Domoticz.Log("Domoticz SMA Inverter Modbus plugin start")

    if 1 not in Devices:
        Domoticz.Device(Name="Solar Yield", Unit=1, TypeName="kWh",
                        Used=0).Create()
    if 2 not in Devices:
        Domoticz.Device(Name="DC Power A", Unit=2, TypeName="Usage",
                        Used=0).Create()
    if 3 not in Devices:
        Domoticz.Device(Name="DC Power B", Unit=3, TypeName="Usage",
                        Used=0).Create()
    if 4 not in Devices:
        Domoticz.Device(Name="AC Power", Unit=4, TypeName="Usage",
                        Used=0).Create()
    if 5 not in Devices:
        Domoticz.Device(Name="Temperature",
                        Unit=5,
                        TypeName="Temperature",
                        Used=0).Create()

    global client
    client = ModbusClient(host=Parameters["Address"],
                          port=Parameters["Port"],
                          unit_id=Parameters["Mode1"])
    client.open()

    Domoticz.Heartbeat(int(Parameters["Mode2"]))
Esempio n. 22
0
    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)
Esempio n. 23
0
    def onStart(self):

        Domoticz.Debug("onStart called")
        self.pollinterval = int(Parameters["Mode1"])  #Time in seconds between two polls

        if Parameters["Mode6"] == 'Debug':
            self.debug = True
            Domoticz.Debugging(1)
            DumpConfigToLog()
        else:
            Domoticz.Debugging(0)


        #if 'wanipaddress' not in Images: Domoticz.Image('wanipaddress.zip').Create()

        #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="WAN IP Alert", Unit=1, TypeName="Alert", Used=1).Create()
             #Domoticz.Device(Name="WAN IP 1", Unit=1, TypeName="Text", Used=1).Create()
            Domoticz.Log("Device created.")

        Domoticz.Heartbeat(int(Parameters["Mode1"]))
    def onStart(self):
        # Debug
        self.debug = 0
        if (Parameters["Mode1"] != "none"):
            Domoticz.Debugging(1)
            self.debug = 1
        
        if (Parameters["Mode1"] == 'ptvsd'):
            Domoticz.Log("Debugger ptvsd started, use 0.0.0.0:5678 to attach")
            import ptvsd             
            # signal error on raspberry
            ptvsd.enable_attach()
            ptvsd.wait_for_attach()
        elif (Parameters["Mode1"] == 'rpdb'):
            Domoticz.Log("Debugger rpdb started, use 'telnet 127.0.0.1 4444' on host to connect")
            import rpdb
            rpdb.set_trace()
            # signal error on raspberry
            # rpdb.handle_trap("0.0.0.0", 4444)

        # 
        Domoticz.Heartbeat(self.heartBeatFreq)
        self.repeatTime = int(Parameters["Mode2"])
        self.remoteIP = Parameters["Address"]
        self.remotePort = Parameters["Port"]
        
        # Server Connection
        self.serverConn = Domoticz.Connection(Name="Data Connection", Transport="TCP/IP", Protocol="None", Port="9000")
        self.serverConn.Listen()

        # Client Connection 
        if self.remoteIP:
            self.proxyConn = Domoticz.Connection(Name="Proxy Connection", Transport="TCP/IP", Protocol="None", Address=self.remoteIP, Port=self.remotePort)
            self.proxyConn.Connect()
Esempio n. 25
0
    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)
Esempio n. 26
0
    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)
Esempio n. 27
0
    def onStart(self):
        if Parameters["Mode6"] == "Debug":
            Domoticz.Debugging(1)

        try:
            self.delay = int(Parameters["Mode2"])
        except ValueError:
            self.delay = 1
        if (self.delay < 1): self.delay = 1

        if (len(Devices) == 0):
            Domoticz.Device(Name="SP2", Unit=1, Type=17, Switchtype=0,
                            Image=1).Create()
            Domoticz.Log("Devices SP2 created.")

        self.mySP2 = broadlink.sp2(host=(Parameters["Address"],
                                         int(Parameters["Port"])),
                                   mac=bytearray.fromhex(Parameters["Mode1"]))
        try:
            self.isFound = self.mySP2.auth()
            self.isConnected = True
        except socket.timeout:
            self.isConnected = False
            self.isFound = False

        if (self.isConnected):
            UpdateDevice(1, self.mySP2.check_power(), "")
        else:
            Domoticz.Error("Devices SP2 at " + Parameters["Address"] +
                           " not found")
        Domoticz.Heartbeat(60)
        Domoticz.Debug("onStart called. isConnected: " +
                       str(self.isConnected) + " isFound: " +
                       str(self.isFound))
        Domoticz.Debug("Delay is set " + str(self.delay) + " minutes")
Esempio n. 28
0
    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.statusUnit not in Devices:
            Domoticz.Device(Name='Status', Unit=self.statusUnit, Type=17, Switchtype=17).Create()

        if self.angleControlUnit not in Devices:
            Domoticz.Device(Name='Oscillation Angle', Unit=self.angleControlUnit, TypeName='Selector Switch', Options=self.angleOptions).Create()

        if self.fanDimmerUnit not in Devices:
            Domoticz.Device(Name='Fan Level', Unit=self.fanDimmerUnit, Type=244, Subtype=73, Switchtype=7).Create()

        if self.modeControlUnit not in Devices:
            Domoticz.Device(Name='Mode Control', Unit=self.modeControlUnit, TypeName='Selector Switch',  Options=self.modeOptions).Create()

#        if self.batteryUnit not in Devices:
#            Domoticz.Device(Name='Battery', Unit=self.batteryUnit, TypeName='Custom', Image=iconID, Options=self.customSensorOptions).Create()

        Domoticz.Heartbeat(int(Parameters['Mode2']))
Esempio n. 29
0
 def onStart(self):
     global data
     data = httplib2.Http('.cache')
     Domoticz.Debugging(1)
     Domoticz.Log("onStart called")
     Domoticz.Heartbeat(int(Parameters['Mode1']))
     verisureLogin()
Esempio n. 30
0
    def onStart(self):
        Domoticz.Heartbeat(5)

        if Parameters["Mode2"] == "Debug":
            Domoticz.Debugging(1)
        else:
            Domoticz.Debugging(0)

        # 从Domoticz重新加载硬件和设备信息
        self.reloadFromDomoticz()

        debug = False
        if Parameters["Mode2"] == "Debug":
            debug = True
        if self.client and self.client.is_open():
            self.client.close()
        self.client = ModbusClient(host=Parameters["Address"],
                                   port=Parameters["Port"],
                                   auto_open=True,
                                   auto_close=False,
                                   timeout=1)
        self.messageThread.start()
        self.client.mode(2)

        self.messageQueue.put({
            "Type": "Log",
            "Text": "Heartbeat test message"
        })