def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='daikcode')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        if not self.check_configured():
            return

        # get the devices list
        self.devices = self.get_device_list(quit_if_no_device = False)
        # get the config values
        self.remoteManager = RemoteManager(self, self.send_xpl)
        for a_device in self.devices :
            try :
                if a_device['device_type_id'] != 'daikcode.remotearc' :
                #if device_name == None  or irtransmitter == None or options == None :
                    self.log.error(u"No daikcode.remotearc device type")
                    break
                else :
                    self.remoteManager.addRemote(a_device)
                    self.log.debug("Ready to work with device {0}".format(getRemoteId(a_device)))
            except:
                self.log.error(traceback.format_exc())
                # we don't quit plugin if an error occured
                #self.force_leave()
                #return
         # Create the xpl listeners
        Listener(self.handle_xpl_cmd, self.myxpl,{'schema': 'daikin.basic',
                                                                        'xpltype': 'xpl-cmnd'})
        Listener(self.handle_xpl_trig, self.myxpl,{'schema': 'ir.basic',
                                                                        'xpltype': 'xpl-trig'})
        print "Plugin ready :)"
        self.log.info("Plugin ready :)")
        self.ready()
Example #2
0
    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='daikcode')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        if not self.check_configured():
            return

        # get the devices list
        self.devices = self.get_device_list(quit_if_no_device=False)
        # get the config values
        self.remoteManager = RemoteManager(self, self.send_xpl)
        for a_device in self.devices:
            try:
                if a_device['device_type_id'] != 'daikcode.remotearc':
                    #if device_name == None  or irtransmitter == None or options == None :
                    self.log.error(u"No daikcode.remotearc device type")
                    break
                else:
                    self.remoteManager.addRemote(a_device)
                    self.log.debug("Ready to work with device {0}".format(
                        getRemoteId(a_device)))
            except:
                self.log.error(traceback.format_exc())
                # we don't quit plugin if an error occured
                #self.force_leave()
                #return
        # Create the xpl listeners
        Listener(self.handle_xpl_cmd, self.myxpl, {
            'schema': 'daikin.basic',
            'xpltype': 'xpl-cmnd'
        })
        Listener(self.handle_xpl_trig, self.myxpl, {
            'schema': 'ir.basic',
            'xpltype': 'xpl-trig'
        })
        print "Plugin ready :)"
        self.log.info("Plugin ready :)")
        self.ready()
Example #3
0
class DaikinManager(XplPlugin):
    """ Envois et recois des codes xPL IR DAIKIN
    """
    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='daikcode')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        if not self.check_configured():
            return

        # get the devices list
        self.devices = self.get_device_list(quit_if_no_device=False)
        # get the config values
        self.remoteManager = RemoteManager(self, self.send_xpl)
        for a_device in self.devices:
            try:
                if a_device['device_type_id'] != 'daikcode.remotearc':
                    #if device_name == None  or irtransmitter == None or options == None :
                    self.log.error(u"No daikcode.remotearc device type")
                    break
                else:
                    self.remoteManager.addRemote(a_device)
                    self.log.debug("Ready to work with device {0}".format(
                        getRemoteId(a_device)))
            except:
                self.log.error(traceback.format_exc())
                # we don't quit plugin if an error occured
                #self.force_leave()
                #return
        # Create the xpl listeners
        Listener(self.handle_xpl_cmd, self.myxpl, {
            'schema': 'daikin.basic',
            'xpltype': 'xpl-cmnd'
        })
        Listener(self.handle_xpl_trig, self.myxpl, {
            'schema': 'ir.basic',
            'xpltype': 'xpl-trig'
        })
        print "Plugin ready :)"
        self.log.info("Plugin ready :)")
        self.ready()

    def send_xplStat(self, data):
        """ Send xPL cmd message on network
        """
        msg = XplMessage()
        msg.set_type("xpl-stat")
        msg.set_schema("sensor.basic")
        msg.add_data(data)
        self.myxpl.send(msg)

    def send_xpl(self, type, schema, data):
        """ Send xPL message on network
        """
        self.log.debug("{0} for {1}".format(type, data))
        msg = XplMessage()
        msg.set_type(type)
        msg.set_schema(schema)
        msg.add_data(data)
        self.myxpl.send(msg)

    def handle_xpl_trig(self, message):
        """ Process xpl schema ir.basic
        """
        self.log.debug(
            "xpl-trig listener received message:{0}".format(message))
        device_name = message.data['device']
        self.log.debug("device :" + device_name)
        idsRemote = self.remoteManager.getIdsRemote(device_name)
        find = False
        if idsRemote != []:
            for id in idsRemote:
                remote = self.remoteManager.getRemote(id)
                if remote:
                    self.log.debug("Handle xpl-trig for remote :{0}".format(
                        message.data['device']))
                    find = True
                    remote.handle_xpl_trig(message.data)
        if not find:
            self.log.debug("xpl-trig received for unknowns remote :{0}".format(
                message.data['device']))

    def handle_xpl_cmd(self, message):
        """ Process xpl schema daikin.basic
        """
        self.log.debug(
            "xpl-cmds listener received message:{0}".format(message))
        device_name = message.data['device']
        self.log.debug("device :" + device_name)
        idsRemote = self.remoteManager.getIdsRemote(device_name)
        find = False
        if idsRemote != []:
            for id in idsRemote:
                remote = self.remoteManager.getRemote(id)
                if remote:
                    self.log.debug("Handle xpl-cmds for remote :{0}".format(
                        message.data['device']))
                    find = True
                    remote.handle_xpl_cmd(message.data)
        if not find:
            self.log.debug("xpl-cmds received for unknowns remote :{0}".format(
                message.data['device']))
class DaikinManager(XplPlugin):
    """ Envois et recois des codes xPL IR DAIKIN
    """

    def __init__(self):
        """ Init plugin
        """
        XplPlugin.__init__(self, name='daikcode')

        # check if the plugin is configured. If not, this will stop the plugin and log an error
        if not self.check_configured():
            return

        # get the devices list
        self.devices = self.get_device_list(quit_if_no_device = False)
        # get the config values
        self.remoteManager = RemoteManager(self, self.send_xpl)
        for a_device in self.devices :
            try :
                if a_device['device_type_id'] != 'daikcode.remotearc' :
                #if device_name == None  or irtransmitter == None or options == None :
                    self.log.error(u"No daikcode.remotearc device type")
                    break
                else :
                    self.remoteManager.addRemote(a_device)
                    self.log.debug("Ready to work with device {0}".format(getRemoteId(a_device)))
            except:
                self.log.error(traceback.format_exc())
                # we don't quit plugin if an error occured
                #self.force_leave()
                #return
         # Create the xpl listeners
        Listener(self.handle_xpl_cmd, self.myxpl,{'schema': 'daikin.basic',
                                                                        'xpltype': 'xpl-cmnd'})
        Listener(self.handle_xpl_trig, self.myxpl,{'schema': 'ir.basic',
                                                                        'xpltype': 'xpl-trig'})
        print "Plugin ready :)"
        self.log.info("Plugin ready :)")
        self.ready()

    def send_xplStat(self, data):
        """ Send xPL cmd message on network
        """
        msg = XplMessage()
        msg.set_type("xpl-stat")
        msg.set_schema("sensor.basic")
        msg.add_data(data)
        self.myxpl.send(msg)

    def send_xpl(self, type, schema, data):
        """ Send xPL message on network
        """
        self.log.debug("{0} for {1}".format(type, data))
        msg = XplMessage()
        msg.set_type(type)
        msg.set_schema(schema)
        msg.add_data(data)
        self.myxpl.send(msg)
        
    def handle_xpl_trig(self, message):
        """ Process xpl schema ir.basic
        """
        self.log.debug("xpl-trig listener received message:{0}".format(message))
        device_name = message.data['device']
        self.log.debug("device :" + device_name)
        idsRemote = self.remoteManager.getIdsRemote(device_name)
        find = False
        if idsRemote != [] :
            for id in idsRemote :       
                remote = self.remoteManager.getRemote(id)
                if remote :
                    self.log.debug("Handle xpl-trig for remote :{0}".format(message.data['device']))
                    find = True
                    remote.handle_xpl_trig(message.data)
        if not find : self.log.debug("xpl-trig received for unknowns remote :{0}".format(message.data['device']))
    
    def handle_xpl_cmd(self,  message):
        """ Process xpl schema daikin.basic
        """
        self.log.debug("xpl-cmds listener received message:{0}".format(message))
        device_name = message.data['device']
        self.log.debug("device :" + device_name)
        idsRemote = self.remoteManager.getIdsRemote(device_name)
        find = False
        if idsRemote != [] :
            for id in idsRemote :       
                remote = self.remoteManager.getRemote(id)
                if remote :
                    self.log.debug("Handle xpl-cmds for remote :{0}".format(message.data['device']))
                    find = True
                    remote.handle_xpl_cmd(message.data)
        if not find : self.log.debug("xpl-cmds received for unknowns remote :{0}".format(message.data['device']))