Пример #1
0
   def connect(self):
       '''
       Connect / check connection
       '''
       
       connect = rm3ping.ping(self.api_config["IPAddress"])
       if not connect:
         self.status = self.not_connected + " ... PING"
         self.logging.warning(self.status)       
         return self.status

       self.status               = "Connected"
       self.count_error          = 0
       self.count_success        = 0

       try:
          self.api       = Kodi(self.api_url)

       except Exception as e:
          self.status = self.not_connected + " ... CONNECT " + str(e)
          self.logging.warn(self.status)

       try:
          self.api.jc    = APIaddOn(self.api)
          self.logging.debug(str(self.api.JSONRPC.Ping()))
          
          self.api.jc.status        = self.status
          self.api.jc.not_connected = self.not_connected

       except Exception as e:
          self.status = self.not_connected + " ... CONNECT " + str(e)
          self.logging.warn(self.status)
Пример #2
0
   def connect(self):
       '''
       Connect / check connection
       '''
              
       connect = rm3ping.ping(self.api_config["IPAddress"])
       if not connect:
         self.status = self.not_connected + " ... PING"
         self.logging.warning(self.status)       
         return self.status

       self.status               = "Connected"
       self.count_error          = 0
       self.count_success        = 0

       try:
          self.api    = eiscp.eISCP(self.api_ip)
          #self.api    = eiscp.Receiver(self.api_ip)
          #self.api.on_message = callback_method
               
       except Exception as e:
          self.status = "Error connecting to ONKYO device: " + str(e)
          self.api.command("system-power query") # send a command to check if connected
          self.logging.warning(self.status)

       try:
          self.api.jc               = APIaddOn(self.api)
          self.api.jc.status        = self.status
          self.api.jc.not_connected = self.not_connected
          
       except Exception as e:
          self.status               = self.not_connected + " ... CONNECT " + str(e)
          self.api.jc.status        = self.status
          self.logging.warning(self.status)
Пример #3
0
 def check_connection(self):
     '''
     check IP connection and try reconnect if IP connection exists and status is not "Connected" 
     '''
     
     self.logging.info("..................... CHECK CONNECTION .....................")
     
     # check API status
     for key in self.api:
       if "IPAddress" in self.api[key].api_config:
         connect = rm3ping.ping(self.api[key].api_config["IPAddress"])
         self.logging.info(key+": ip - "+self.api[key].api_config["IPAddress"]+" / connect -"+str(connect))
         
         if not connect:
           connect = rm3ping.ping(self.api[key].api_config["IPAddress"])
           if not connect:
             self.api[key].status = self.api[key].not_connected + " ... PING"
             self.logging.info(self.api[key].status)
             
         if connect:
           self.reconnect(key)
Пример #4
0
    def connect(self):
        '''
       Connect / check connection
       '''

        connect = rm3ping.ping(self.api_config["IPAddress"])
        if not connect:
            self.status = self.not_connected + " ... PING"
            self.logging.warning(self.status)
            return self.status

        self.status = "Connected"
        self.count_error = 0
        self.count_success = 0

        api_ip = self.api_config["IPAddress"]
        api_device_type = self.api_config["DeviceType"]

        try:
            self.api = device.MagicHomeApi(api_ip, api_device_type)

        except Exception as e:
            self.status = self.not_connected + " ... CONNECT " + str(e)
            return self.status

#       if self.api.connected == False:
#          self.status = self.not_connected + " ... API-CONNECT " + self.api.connection_status

        try:
            self.api.jc = APIaddOn(self.api, self.logging)
            self.api.jc.status = self.status
            self.api.jc.not_connected = self.not_connected

        except Exception as e:
            self.status = self.not_connected + " ... CONNECT " + str(e)
            self.api.jc.status = self.status
            return self.status

        return self.status
Пример #5
0
    def connect(self):
        '''
       Connect / check connection
       '''

        connect = rm3ping.ping(self.api_config["IPAddress"])
        if not connect:
            self.status = self.not_connected + " ... PING"
            self.logging.warning(self.status)
            return self.status

        self.status = "Connected"
        self.count_error = 0
        self.count_success = 0

        api_ip = self.api_config["IPAddress"]
        api_user = self.api_config["TapoUser"]
        api_pwd = self.api_config["TapoPwd"]

        try:
            self.api = device.P100(api_ip, api_user, api_pwd)
            self.api.handshake()
            self.api.login()
        except Exception as e:
            self.status = self.not_connected + " ... CONNECT " + str(e)
            return self.status

        try:
            self.api.jc = APIaddOn(self.api, self.logging)
            self.api.jc.status = self.status
            self.api.jc.not_connected = self.not_connected

        except Exception as e:
            self.status = self.not_connected + " ... CONNECT " + str(e)
            self.api.jc.status = self.status
            return self.status

        return self.status
Пример #6
0
    def connect(self):
        '''
       Connect / check connection
       '''

        connect = rm3ping.ping(self.api_config["IPAddress"])
        if not connect:
            self.status = self.not_connected + " ... PING"
            self.logging.warning(self.status)
            return self.status

        self.count_error = 0
        self.count_success = 0

        try:
            self.api = broadlink.rm(
                (self.api_config["IPAddress"], self.api_config["Port"]),
                self.api_config["MACAddress"])
            if self.api.auth(): self.status = "Connected"
            else:
                self.status = self.not_connected + " ... CONNECT not found or no access"

        except e as Exception:
            self.status = self.not_connected + " ... CONNECT " + str(e)
            self.logging.error(self.status)

        if check_on_startup:
            try:
                for command in check_on_startup_commands:
                    self.send("broadlink_test", command)
                    time.sleep(0.5)
            except e as Exception:
                self.status = "ERROR IR Device: " + str(e)
                self.logging.error(self.status)

        return self.status