Beispiel #1
0
    def onStart(self):
        if Parameters["Mode6"] != "0":
            Domoticz.Debugging(int(Parameters["Mode6"]))
            DumpConfigToLog()
            
        if 'Mode2' in Parameters:
            updateInterval = Parameters['Mode2']
            if updateInterval != '':
                if not updateInterval.isdigit():
                    Domoticz.Error("Update interval parameter must be an integer - ignored '%s'" % updateInterval)
                else:
                    updateInterval = int(updateInterval)
                    if updateInterval < 10:
                        Domoticz.Error("Minimum update interval is 10 seconds")
                        updateInterval = 10
                    self.UpdateInterval = updateInterval

        for d in Devices:
            self.Units[Devices[d].DeviceID] = d
            
        self.httpConn = Domoticz.Connection(Name="Wiser", Transport="TCP/IP", Protocol="HTTP", Address=Parameters["Address"], Port="80")
        self.httpCmdConn = Domoticz.Connection(Name="WiserCmd", Transport="TCP/IP", Protocol="HTTP", Address=Parameters["Address"], Port="80")
        self.httpConn.Connect()

        Domoticz.Debug("onStart called")
Beispiel #2
0
 def onStart(self):
     Domoticz.Log('Starting')
     if Parameters["Mode6"] != "0":
         Domoticz.Debugging(int(Parameters["Mode6"]))
     self.multiplier = int(Parameters['Mode1'])
     self.deviceUpdate = Buffer(10)  # Buffer up to 10 commands
     if int(self.getDomoticzRevision()) < 9030:
         Domoticz.Log(
             "SNI connections are only available in Revision >= 9030.  This plugin will not work"
         )
     else:
         self.httpConn = Domoticz.Connection(Name="Hive Session",
                                             Transport="TCP/IP",
                                             Protocol="HTTPS",
                                             Address=self.sessionHost,
                                             Port="443")
         self.httpConn.Connect()  # Get a SessionId
         self.deviceConn = Domoticz.Connection(Name="Hive Devices",
                                               Transport="TCP/IP",
                                               Protocol="HTTPS",
                                               Address=self.deviceHost,
                                               Port="443")
         self.deviceUpdateConn = Domoticz.Connection(
             Name="Hive Device Update",
             Transport="TCP/IP",
             Protocol="HTTPS",
             Address=self.deviceHost,
             Port="443")
Beispiel #3
0
 def apiConnection(self):
     if Parameters["Port"] == "443":
         return Domoticz.Connection(Name="SEMS Portal API", Transport="TCP/IP", Protocol="HTTPS",
                                    Address=Parameters["Address"], Port=Parameters["Port"])
     else:
         return Domoticz.Connection(Name="SEMS Portal API", Transport="TCP/IP", Protocol="HTTP",
                                    Address=Parameters["Address"], Port=Parameters["Port"])
    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()
Beispiel #5
0
    def onStart(self):
        if Parameters["Mode1"] == "True":
            self.fv2_17_x = True

        if Parameters["Mode4"] == "Debug":
            self.dtr_debug = 1

        if Parameters["Mode3"] == "Yes":
            self.parity_mutex = True

        self.print_log(1, "onStart called")

        self.password = int(Parameters["Password"])

        self.channel_count = int(Parameters["Mode2"]) + 1
        offset = 1
        if (0 == len(Devices)):
            for i in range(1, self.channel_count):
                Domoticz.Device(Name="RELAY" + str(i),
                                Unit=offset,
                                TypeName="Switch",
                                Image=0).Create()
                offset = offset + 1
            if True == self.fv2_17_x:
                for i in range(1, self.channel_count):
                    Domoticz.Device(Name="INPUT" + str(i),
                                    Unit=offset,
                                    TypeName="Switch",
                                    Image=0).Create()
                    offset = offset + 1
        else:
            for i in range(1, self.channel_count):
                self.relay[i] = Devices[offset].nValue
                offset = offset + 1
            if True == self.fv2_17_x:
                for i in range(1, self.channel_count):
                    self.rinput[i] = Devices[offset].nValue
                    offset = offset + 1

        self.ip_addr = Parameters["Address"]
        port = int(Parameters["Port"])
        self.print_log(
            1, "onStart Connection to " + self.ip_addr + ":" + str(port))
        self.BeaconConn = Domoticz.Connection(Name="RELAYUDPR",
                                              Transport="UDP/IP",
                                              Address=self.ip_addr,
                                              Port=str(port))
        self.BeaconConn.Listen()
        port = port - 1
        self.print_log(
            1, "onStart Connection to " + self.ip_addr + ":" + str(port))
        self.BeaconConnS = Domoticz.Connection(Name="RELAYUDPS",
                                               Transport="UDP/IP",
                                               Address=self.ip_addr,
                                               Port=str(port))
        self.print_log(
            1, "onStart Listen from " + self.ip_addr + ":" + str(port) +
            " channel_count=" + str(self.channel_count))
Beispiel #6
0
	def onStart(self):
		Domoticz.Status("onStart called - Zigate plugin V 3.0.5")

		if Parameters["Mode6"] != "0":
			Domoticz.Debugging(int(Parameters["Mode6"]))
			DumpConfigToLog()
		if Parameters["Mode1"] == "USB":
			z_var.transport = "USB"
			z_var.ZigateConn = Domoticz.Connection(Name="ZiGate", Transport="Serial", Protocol="None", Address=Parameters["SerialPort"], Baud=115200)
			z_var.ZigateConn.Connect()
		if Parameters["Mode1"] == "Wifi":
			z_var.transport = "Wifi"
			z_var.ZigateConn = Domoticz.Connection(Name="Zigate", Transport="TCP/IP", Protocol="None ", Address=Parameters["Address"], Port=Parameters["Port"])
			z_var.ZigateConn.Connect()
		
		# CLD CLD
		# Import PluginConf.txt
		tmpPluginConf=""
		with open(Parameters["HomeFolder"]+"PluginConf.txt", 'r') as myPluginConfFile:
			tmpPluginConf+=myPluginConfFile.read().replace('\n', '')
		myPluginConfFile.close()
		Domoticz.Debug("PluginConf.txt = " + str(tmpPluginConf))
		self.PluginConf=eval(tmpPluginConf)
		z_var.CrcCheck = 1
		if  self.PluginConf['CrcCheck'] == "False" or self.PluginConf['CrcCheck'] == "Off" :
			z_var.CrcCheck = 0
		
		z_var.ReqRcv=bytearray()

		for x in Devices : # initialise listeofdevices avec les devices en bases domoticz
			ID = Devices[x].DeviceID
			self.ListOfDevices[ID]={}
			try:
				self.ListOfDevices[ID]=eval(Devices[x].Options['Zigate'])
			except: 
				Domoticz.Error("Error loading Device " +str(Devices[x]) + " not loaded int Zigate Plugin!" )
			else :
				Domoticz.Log("Device : [" + str(x) + "] ID = " + ID + " Options['Zigate'] = " + Devices[x].Options['Zigate'] + " loaded into self.ListOfDevices")

		#Import DeviceConf.txt
		tmpread=""
		with open(Parameters["HomeFolder"]+"DeviceConf.txt", 'r') as myfile:
			tmpread+=myfile.read().replace('\n', '')
		myfile.close()
		Domoticz.Debug("DeviceConf.txt = " + str(tmpread))
		self.DeviceConf=eval(tmpread)
		#Import DeviceList.txt
		with open(Parameters["HomeFolder"]+"DeviceList.txt", 'r') as myfile2:
			Domoticz.Debug("DeviceList.txt open ")
			for line in myfile2:
				(key, val) = line.split(":",1)
				key = key.replace(" ","")
				key = key.replace("'","")
				z_tools.CheckDeviceList(self, key, val)
		return
Beispiel #7
0
def open_connection(self):

    if self._transp in ["USB", "DIN", "PI", "V2-USB", "V2-DIN", "V2-PI"]:
        if self._serialPort.find("/dev/") == -1 and self._serialPort.find(
                "COM") == -1:
            self.logging_transport(
                self, "Error",
                "Connection Name: Zigate, Transport: Serial, Address: %s" %
                (self._serialPort))
            return
        self.logging_transport(
            self, "Status",
            "Connection Name: Zigate, Transport: Serial, Address: %s" %
            (self._serialPort))
        if self.pluginconf.pluginConf[
                "byPassDzConnection"] and not self.force_dz_communication:
            result = open_zigate_and_start_reader(self, "serial")
        else:
            self._connection = Domoticz.Connection(Name="ZiGate",
                                                   Transport="Serial",
                                                   Protocol="None",
                                                   Address=self._serialPort,
                                                   Baud=115200)
            result = self._connection
        if result:
            start_writer_thread(self)
            start_forwarder_thread(self)

    elif self._transp in ("Wifi", "V2-Wifi"):
        self.logging_transport(
            self, "Status",
            "Connection Name: Zigate, Transport: TCP/IP, Address: %s:%s" %
            (self._serialPort, self._wifiPort))
        if self.pluginconf.pluginConf[
                "byPassDzConnection"] and not self.force_dz_communication:
            result = open_zigate_and_start_reader(self, "tcpip")
        else:
            self._connection = Domoticz.Connection(Name="Zigate",
                                                   Transport="TCP/IP",
                                                   Protocol="None ",
                                                   Address=self._wifiAddress,
                                                   Port=self._wifiPort)
            result = self._connection
        if result:
            start_writer_thread(self)
            start_forwarder_thread(self)

    else:
        self.logging_transport(self, "Error",
                               "Unknown Transport Mode: %s" % self._transp)
Beispiel #8
0
    def onStart(self):
        if Parameters[
                "Mode3"] == "2":  # for some reason a contact is inverted vs a switch, go figure....
            self.switchType = 2
            self.deviceOn = 0
            self.deviceOff = 1

        if 1 == 1:  #(Parameters["Mode4"] == "True"):
            if len(Devices) == 0:
                Domoticz.Device("Shelly",
                                Unit=1,
                                Type=244,
                                Subtype=62,
                                Switchtype=self.switchType).Create()
                Domoticz.Log("Created device: ")
        if Parameters["Mode2"] != "0":  # Create temperature devices
            if len(Devices) != int(Parameters["Mode2"]) + 1:
                for x in range(2, int(Parameters["Mode2"]) + 2):
                    Domoticz.Device("Shelly", Unit=x, Type=80,
                                    Subtype=5).Create()
                    Domoticz.Log("Created device: ")

        self.httpConn = Domoticz.Connection(Name=self.sProtocol + " Test",
                                            Transport="TCP/IP",
                                            Protocol=self.sProtocol,
                                            Address=Parameters["Address"],
                                            Port="80")
        self.httpConn.Connect()
 def onStart(self):
     if Parameters["Mode6"] == "Debug":
         Domoticz.Debugging(1)
     else:
         Domoticz.Debugging(0)
     Domoticz.Debug("onStart")
     # Devices
     for unit in self.__UNITS:
         if unit[0] not in Devices:
             Domoticz.Device(
                 Unit=unit[0],
                 Name=unit[1],
                 Type=unit[2],
                 Subtype=unit[3],
                 Options=unit[4],
                 Used=unit[5],
             ).Create()
     # Connections
     self.httpServerConn = Domoticz.Connection(
         Name="Server",
         Transport="TCP/IP",
         Protocol="HTTP",
         Port=Parameters["Address"],
     )
     self.httpServerConn.Listen()
     Domoticz.Debug("Listening to port: {}".format(Parameters["Address"]))
Beispiel #10
0
def onStart():
    global SerialConn
    if Parameters["Mode6"] != "Normal":
        Domoticz.Debugging(1)
    if Parameters["Mode6"] == "Debug":
        f = open(Parameters["HomeFolder"] + "plugin.log", "w")
        f.write("Plugin started.")
        f.close()
    if (len(Devices) == 0):
        Domoticz.Device(Name="Usage",
                        Unit=1,
                        Type=243,
                        Subtype=29,
                        Switchtype=0,
                        Image=0,
                        Options="").Create()
        Domoticz.Device("Total", 2, 113).Create()
        Domoticz.Log("Devices created.")
    Domoticz.Log("Plugin has " + str(len(Devices)) +
                 " devices associated with it.")
    DumpConfigToLog()
    for Device in Devices:
        Devices[Device].Update(nValue=Devices[Device].nValue,
                               sValue=Devices[Device].sValue,
                               TimedOut=1)
    SerialConn = Domoticz.Connection(Name="RAVEn",
                                     Transport="Serial",
                                     Protocol="XML",
                                     Address=Parameters["SerialPort"],
                                     Baud=115200)
    SerialConn.Connect()
    return
Beispiel #11
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
Beispiel #12
0
def getWLEDStatus():
    getWLEDStatusConn = Domoticz.Connection(Name="getWLEDStatusConn",
                                            Transport="TCP/IP",
                                            Protocol="HTTP",
                                            Address=ipaddress,
                                            Port="80")
    getWLEDStatusConn.Connect()
Beispiel #13
0
 def onStart(self):
     if Parameters["Mode6"] != "0":
         Domoticz.Debugging(int(Parameters["Mode6"]))
         DumpConfigToLog()
     if (Parameters["Mode1"] == "443"): self.sProtocol = "HTTPS"
     self.httpConn = Domoticz.Connection(Name=self.sProtocol+" Test", Transport="TCP/IP", Protocol=self.sProtocol, Address=Parameters["Address"], Port=Parameters["Mode1"])
     self.httpConn.Connect()
 def TurnOff(self):
     if (Parameters["Mode2"] == "Ignore"):
         Domoticz.Log("'Off' command ignored as configured.")
     elif (Parameters["Mode2"] == "Hibernate"):
         if (self.canHibernate == True):
             self.KodiConn.Send('{"jsonrpc":"2.0","method":"System.Hibernate","id":1008}')
         else:
             Domoticz.Error("Configured Shutdown option: 'Hibernate' not support by attached Kodi.")
     elif (Parameters["Mode2"] == "Suspend"):
         if (self.canSuspend == True):
             self.KodiConn.Send('{"jsonrpc":"2.0","method":"System.Suspend","id":1008}')
         else:
             Domoticz.Error("Configured Shutdown option: 'Suspend' not support by attached Kodi.")
     elif (Parameters["Mode2"] == "Shutdown"):
         if (self.canShutdown == True):
             self.KodiConn.Send('{"jsonrpc":"2.0","method":"System.Shutdown","id":1008}')
         else:
             Domoticz.Error("Configured Shutdown option: 'Shutdown' not support by attached Kodi.")
     elif (Parameters["Mode2"] == "Sleep"):
         # There is no JSON command to turn on screensaver so use UDP, setting window to Screensaver is not the same
         import xmbcclient3
         packet = xmbcclient3.PacketACTION(actionmessage="ActivateScreensaver")
         udpBcastConn = Domoticz.Connection(Name="UDP Broadcast Connection", Transport="UDP/IP", Protocol="None", Address=Parameters["Address"], Port=str(9777))
         for a in range ( 0, packet.num_packets() ):
             try:
                 udpBcastConn.Send(packet.get_udp_message(a+1))
             except:
                 return
     else:
         Domoticz.Error("Unknown Shutdown option, ID:"+str(Parameters["Mode2"])+".")
     return
Beispiel #15
0
 def onHeartbeat(self):
     global runDevice
     Domoticz.Debug("onHeartbeat called")
     if (self.httpConn != None
             and (self.httpConn.Connecting() or self.httpConn.Connected())):
         Domoticz.Debug("onHeartbeat called, Connection is alive.")
     else:
         self.runAgain = self.runAgain - 1
         if self.runAgain <= 0:
             if (self.httpConn == None):
                 self.httpConn = Domoticz.Connection(
                     Name="SonOff EWELink connection",
                     Transport="TCP/IP",
                     Protocol=self.sProtocol,
                     Address=Parameters["Address"],
                     Port=Parameters["Port"])
             self.sendData = { 'Verb' : 'GET',
                          'URL'  : '/list',
                          'Headers' : { 'Content-Type': 'application/json; charset=utf-8', \
                                        'Connection': 'keep-alive', \
                                        'Accept': 'Content-Type: application/json; charset=UTF-8', \
                                        'Host': Parameters["Address"]+":"+Parameters["Port"], \
                                        'User-Agent':'Domoticz/1.0' }
                        }
             self.httpConn.Connect()
             self.runAgain = 6
         else:
             Domoticz.Debug("onHeartbeat called, run again in " +
                            str(self.runAgain) + " heartbeats.")
     onStatus(runDevice)
Beispiel #16
0
 def onStatus(self, Unit):
     global runDevice
     if (self.httpConn != None
             and (self.httpConn.Connecting() or self.httpConn.Connected())):
         Domoticz.Debug("onStatus connected")
     else:
         Domoticz.Debug("onStatus called for Unit " + str(Unit) +
                        " con ID " + Devices[Unit].DeviceID)
         if (runDevice == Unit):
             self.sendData = { 'Verb' : 'GET',
                 'URL'  : '/status?id=' + Devices[Unit].DeviceID,
                 'Headers' : { 'Content-Type': 'application/json; charset=utf-8', \
                     'Connection': 'keep-alive', \
                     'Accept': 'Content-Type: application/json; charset=UTF-8', \
                     'Host': Parameters["Address"]+":"+Parameters["Port"], \
                     'User-Agent':'Domoticz/1.0' }
                 }
             self.httpConn = Domoticz.Connection(
                 Name="SonOff EWELink connection",
                 Transport="TCP/IP",
                 Protocol=self.sProtocol,
                 Address=Parameters["Address"],
                 Port=Parameters["Port"])
             self.httpConn.Connect()
         runDevice += 1
         if (len(Devices) < runDevice):
             runDevice = 1
 def Open(self):
     Domoticz.Debug("MqttClient::Open")
     if (self.mqttConn != None):
         self.Close()
     self.isConnected = False
     self.mqttConn = Domoticz.Connection(Name=self.Address, Transport="TCP/IP", Protocol="MQTT", Address=self.Address, Port=self.Port)
     self.mqttConn.Connect()
Beispiel #18
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)
Beispiel #19
0
 def onStart(self):
     self.nb_relay, self.nb_input = (int(x) for x in Parameters["Mode1"].split())
     Domoticz.Debugging(int(Parameters["Mode4"]))
     self.input_ignore_interval = int(Parameters["Mode3"])
     # DumpConfigToLog()
     self.KCConn = Domoticz.Connection(Name="Kincony", Transport="TCP/IP", Address=Parameters["Address"], Port=Parameters["Port"])
     self.KCConn.Connect()
    def onStart(self):

        # Debug mode
        if (Parameters["Mode6"] == "Debug"):
            Domoticz.Debugging(1)
            Domoticz.Debug("onStart called")
        else:
            Domoticz.Debugging(0)

        #get parameters
        self.__address = Parameters["Address"]
        self.__devID = Parameters["Mode1"]
        self.__localKey = Parameters["Mode2"]

        #initialize the defined device in Domoticz
        if (len(Devices) == 0):
            Domoticz.Device(Name="Tuya SmartBulb",
                            Unit=1,
                            Type=241,
                            Subtype=2,
                            Switchtype=7).Create()
            Domoticz.Log("Tuya SmartBulb Device created.")

        #create the pytuya object
        self.__device = pytuya.BulbDevice(self.__devID, self.__address,
                                          self.__localKey)

        #start the connection
        self.__last_payload = 'status'
        self.__connection = Domoticz.Connection(Name="Tuya",
                                                Transport="TCP/IP",
                                                Address=self.__address,
                                                Port="6668")
        self.__connection.Connect()
Beispiel #21
0
 def connectToAdaptor(self):
     self.CoapAdapter = Domoticz.Connection(Name="Main",
                                            Transport="TCP/IP",
                                            Protocol="JSON",
                                            Address="127.0.0.1",
                                            Port="1234")
     self.CoapAdapter.Connect()
Beispiel #22
0
    def Request(self,url,data=None):
        _port = '443'
        _proto = 'HTTPS'
        _address = URL

        #if it's not a request to the box
        if url.startswith('http'):
            if not url.startswith('https'):
                _port = '80'
                _proto = 'HTTP'
            t = url.split('/')
            _address = t[2]
            url = '/' + '/'.join(t[3:])

            if ':' in _address:
                t = _address.split(':')
                _address = t[0]
                _port = t[1]

        if NO_DOMOTICZ_LIB:

            Domoticz.Debug("Making request " + _proto.lower() + "://" + _address + url)

            h = {
                'User-Agent':'Domoticz',\
                'Accept':'*/*' ,\
                'Host':URL,\
                'Connection':'keep-alive'\
                 }

            if self.cookie:
                h['Cookie'] = self.cookie

            try:
                if data:
                     result = requests.post( _proto.lower() + "://" + _address + url , headers=h, data = data, timeout = 5, verify=False)
                else:
                     result = requests.get( _proto.lower() + "://" + _address + url , headers=h, timeout = 5, verify=False)

                data2 = {}
                data2["Status"] = result.status_code
                data2["Data"] = result.content

                self.ManageAnswer(data2)

            except:
                Domoticz.Error("Connection error : Box non joignable")

        else:
            if not self.httpConn:
                self.UpdateSucced = False

                Domoticz.Debug("Making request " + _proto.lower() + "://" + _address + url)
                self.url = url
                self.data = data
                self.httpConn = Domoticz.Connection(Name="BBox", Transport="TCP/IP", Protocol=_proto, Address=_address, Port=_port)
                self.httpConn.Connect()

            else:
                Domoticz.Debug("Connection already active")
 def onHeartbeat(self):
     global beats, minutes
     beats += 1
     if beats >= 3:
         minutes += 1
         beats = 0
     VerBose('Heartbeat: ' + str(beats) + ", Minutes: " + str(minutes))
     if (self.httpConn != None
             and (self.httpConn.Connecting() or self.httpConn.Connected())):
         VerBose("onHeartbeat called, Connection is alive.")
     else:
         if minutes >= 10:
             if (self.httpConn == None):
                 self.httpConn = Domoticz.Connection(
                     Name=self.sProtocol + " Test",
                     Transport="TCP/IP",
                     Protocol="HTTPS",
                     Address=Parameters["Address"],
                     Port="443")
             self.httpConn.Connect()
             minutes = 0
         else:
             Domoticz.Debug("onHeartbeat called, run again in " +
                            str(self.runAgain) + " heartbeats.")
     if minutes >= 10:  #failsafe
         minutes = 0
 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_template" not in Images:
     #     Domoticz.Image("xfr_template.zip").Create()
     # try:
     #     image = Images["xfr_template"].ID
     # except:
     #     image = 0
     # Domoticz.Debug("Image created. ID: "+str(image))
     # Validate parameters
     # Create devices
     if len(Devices) == 0:
         Domoticz.Device(Unit=self.__UNIT_TEXT,
                         Name="Last",
                         TypeName="Text",
                         Used=1).Create()
     # Log config
     DumpConfigToLog()
     # Connection
     self.__rssConn = Domoticz.Connection(Name="KNMI",
                                          Transport="TCP/IP",
                                          Protocol="HTTP",
                                          Address=self.__API_ADDRESS,
                                          Port=self.__API_PORT)
     self.__rssConn.Connect()
Beispiel #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)
    def onStart(self):
        global andinoSerialConn
        Domoticz.Log("onStart called")

        andinoSerialConn = Domoticz.Connection(
            Name="Serial Connection",
            Transport="Serial",
            Protocol="Line",
            Address=Parameters["SerialPort"],
            Baud=38400)
        andinoSerialConn.Connect()

        if (len(Devices) == 0):
            Domoticz.Device(Name="Input 1", Unit=1, TypeName="Switch").Create()
            Domoticz.Device(Name="Input 2", Unit=2, TypeName="Switch").Create()

            Domoticz.Device(Name="Relay 1", Unit=11,
                            TypeName="Switch").Create()
            Domoticz.Device(Name="Relay 2", Unit=12,
                            TypeName="Switch").Create()

            Domoticz.Device(Name="Relay 1 Pulse", Unit=21,
                            TypeName="Switch").Create()
            Domoticz.Device(Name="Relay 2 Pulse", Unit=22,
                            TypeName="Switch").Create()
            #todo read configuration of X1
            # now assuming HARD=0
            Domoticz.Log("Devices created.")

        return
Beispiel #27
0
    def checkConnection(self, checkonly=False):
        # Check connection and connect none
        isConnected = False
        try:
            if not self.connection is None:
                if self.connection.Connected():
                    isConnected = True
                else:
                    if (not self.connection.Connecting()) and (not checkonly):
                        self.outstandingMessages = 0
                        self.connection.Connect()
            else:
                self.outstandingMessages = 0
                self.connection = Domoticz.Connection(
                    Name="Hosola_OmnikBinair",
                    Transport="TCP/IP",
                    Protocol="None",
                    Address=Parameters["Address"],
                    Port=Parameters["Port"])
                self.connection.Connect()
        except:
            self.connection = None
            self.Log("CheckConnection error, try to reset", 1, 3)

        return isConnected
    def onStart(self):
        Domoticz.Status("onStart")
        self._joinedNetwork = False
        self._scanningNetwork = False
        self._scannedNetwork = False
    
        # loggingPlugin( self, 'Debug', "ListOfDevices : " )
        # for e in self.ListOfDevices.items(): 
            # loggingPlugin( self, 'Debug', " "+str(e))
        id = 255
        if id not in Devices:
            Domoticz.Device(Name = "Switch all off",  Unit = id, TypeName = "Push Off").Create()
            Domoticz.Status("Device Switch all created.")
            
        self._serialPort=Parameters["SerialPort"]
        
        
        if self._connection is not None:
            del self._connection
            self._connection = None


        if self._serialPort.find('/dev/') != -1 or self._serialPort.find('COM') != -1:
            Domoticz.Status("Connection...")
            BAUDS = 19200
            self._connection = Domoticz.Connection(Name="MyHome", Transport="Serial", Protocol="None",
                                                   Address=self._serialPort, Baud=BAUDS)
                                                   
        if self._connection:
            self._connection.Connect()
        else:
            Domoticz.Error("openConn _connection note set!")
Beispiel #29
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)
    def onStart(self):
        global SerialConn
        Domoticz.Log("onStart called")
        if Parameters["Mode6"] != "Normal":
            Domoticz.Debugging(1)
        if Parameters["Mode6"] == "Debug":
            Domoticz.Debug("debug mode enable")

        if (len(Devices) == 0):
            Domoticz.Device(Name="PAPP", Unit=1, TypeName="Usage").Create()
            Domoticz.Log("Devices created.")
#       add new Devices one by one hier and restart ...
#       Example
#          if (len(Devices) == 1):
#          Domoticz.Device(Name="Teleinfo EDF", Unit=2, Type=250, Subtype=1, Switchtype=0).Create()

        Domoticz.Log("Plugin has " + str(len(Devices)) +
                     " devices associated with it.")

        for Device in Devices:
            Devices[Device].Update(nValue=Devices[Device].nValue,
                                   sValue=Devices[Device].sValue,
                                   TimedOut=1)
        SerialConn = Domoticz.Connection(Name="Jeelink",
                                         Transport="Serial",
                                         Protocol="Line",
                                         Address=Parameters["SerialPort"],
                                         Baud=57600)
        SerialConn.Connect()
        DumpConfigToLog()