def getIdsClient(self, idToCheck):
     """Get IRTrans client key ids."""
     retval =[]
     findId = ""
     self._xplPlugin.log.debug (u"getIdsClient check for device : {0}".format(idToCheck))
     if isinstance(idToCheck,  IRTransClient) :
         for id in self.irTransClients.keys() :
             if self.irTransClients[id] == idToCheck :
                 retval = [id]
                 break
     else :
         self._xplPlugin.log.debug (u"getIdsClient,  no IRTransClient instance...")
         if isinstance(idToCheck,  str) :  
             findId = idToCheck
             self._xplPlugin.log.debug (u"str instance...")
         else :
             if isinstance(idToCheck,  dict) :
                 if idToCheck.has_key('device') : findId = idToCheck['device']
                 else :
                     if idToCheck.has_key('name') and idToCheck.has_key('id'): 
                         findId = getIRTransId(idToCheck)
         if self.irTransClients.has_key(findId) : 
             retval = [findId]
             self._xplPlugin.log.debug (u"key id type find")
         else :
             self._xplPlugin.log.debug (u"No key id type, search {0} in devices {1}".format(findId, self.irTransClients.keys()))
             for id in self.irTransClients.keys() :
                 self._xplPlugin.log.debug(u"Search in list by device key : {0}".format(self.irTransClients[id].domogikDevice))
                 if self.irTransClients[id].domogikDevice == findId : 
                     self._xplPlugin.log.debug('find IRTransClient :)')
                     retval.append(id)
     self._xplPlugin.log.debug(u"getIdsClient result : {0}".format(retval))
     return retval
Example #2
0
    def addClient(self, device):
        """Add a IRTrans from domogik device"""
        name = getIRTransId(device)
        if self.irTransClients.has_key(name):
            self._xplPlugin.log.debug(
                u"IRtransceiver Clients Manager : IRtransceiver {0} already exist, not added."
                .format(name))
            return False
        else:
            if checkIfConfigured(device["device_type_id"], device):
                if device["device_type_id"] == "irtrans.irtrans_lan":
                    self.irTransClients[name] = IRTransClient(
                        self, device, self._xplPlugin.log)
                elif device["device_type_id"] == "irtrans.irwsserver":
                    self.irTransClients[name] = IRWSClient(
                        self, device, self._xplPlugin.log)
                else:
                    self._xplPlugin.log.error(
                        u"IRtransceiver Clients Manager : IRtransceiver type {0} not exist, not added."
                        .format(name))
                    return False
                self._xplPlugin.log.info(
                    u"IRtransciever Clients Manager : created new client {0}.".
                    format(name))
            else:
                self._xplPlugin.log.info(
                    u"IRtransciever Clients Manager : device not configured can't add new client {0}."
                    .format(name))
                return False


#            pprint.pprint(device)
            return True
 def refreshClientDevice(self,  client):
     """Request a refresh domogik device data for a IRTrans Client."""
     cli = MQSyncReq(zmq.Context())
     msg = MQMessage()
     msg.set_action('device.get')
     msg.add_data('type', 'plugin')
     msg.add_data('name', self._xplPlugin.get_plugin_name())
     msg.add_data('host', get_sanitized_hostname())
     devices = cli.request('dbmgr', msg.get(), timeout=10).get()
     for a_device in devices:
         if a_device['device_type_id'] == client._device['device_type_id']  and a_device['id'] == client._device['id'] :
             if a_device['name'] != client.device['name'] : # rename and change key client id
                 old_id = getIRTransId(client._device)
                 self.irTransClients[getIRTransId(a_device)] = self.irTransClients.pop(old_id)
                 self._xplPlugin.log.info(u"IRTransciever Client {0} is rename {1}".format(old_id,  getIRTransId(a_device)))
             client.updateDevice(a_device)
             break
Example #4
0
 def refreshClientDevice(self, client):
     """Request a refresh domogik device data for a IRTrans Client."""
     cli = MQSyncReq(zmq.Context())
     msg = MQMessage()
     msg.set_action('device.get')
     msg.add_data('type', 'plugin')
     msg.add_data('name', self._xplPlugin.get_plugin_name())
     msg.add_data('host', get_sanitized_hostname())
     devices = cli.request('dbmgr', msg.get(), timeout=10).get()
     for a_device in devices:
         if a_device['device_type_id'] == client._device[
                 'device_type_id'] and a_device['id'] == client._device[
                     'id']:
             if a_device['name'] != client.device[
                     'name']:  # rename and change key client id
                 old_id = getIRTransId(client._device)
                 self.irTransClients[getIRTransId(
                     a_device)] = self.irTransClients.pop(old_id)
                 self._xplPlugin.log.info(
                     u"IRTransciever Client {0} is rename {1}".format(
                         old_id, getIRTransId(a_device)))
             client.updateDevice(a_device)
             break
Example #5
0
 def getIdsClient(self, idToCheck):
     """Get IRTrans client key ids."""
     retval = []
     findId = ""
     self._xplPlugin.log.debug(
         u"getIdsClient check for device : {0}".format(idToCheck))
     if isinstance(idToCheck, IRTransClient):
         for id in self.irTransClients.keys():
             if self.irTransClients[id] == idToCheck:
                 retval = [id]
                 break
     else:
         self._xplPlugin.log.debug(
             u"getIdsClient,  no IRTransClient instance...")
         if isinstance(idToCheck, str):
             findId = idToCheck
             self._xplPlugin.log.debug(u"str instance...")
         else:
             if isinstance(idToCheck, dict):
                 if idToCheck.has_key('device'):
                     findId = idToCheck['device']
                 else:
                     if idToCheck.has_key('name') and idToCheck.has_key(
                             'id'):
                         findId = getIRTransId(idToCheck)
         if self.irTransClients.has_key(findId):
             retval = [findId]
             self._xplPlugin.log.debug(u"key id type find")
         else:
             self._xplPlugin.log.debug(
                 u"No key id type, search {0} in devices {1}".format(
                     findId, self.irTransClients.keys()))
             for id in self.irTransClients.keys():
                 self._xplPlugin.log.debug(
                     u"Search in list by device key : {0}".format(
                         self.irTransClients[id].domogikDevice))
                 if self.irTransClients[id].domogikDevice == findId:
                     self._xplPlugin.log.debug('find IRTransClient :)')
                     retval.append(id)
     self._xplPlugin.log.debug(u"getIdsClient result : {0}".format(retval))
     return retval
    def addClient(self, device):
        """Add a IRTrans from domogik device"""
        name = getIRTransId(device)
        if self.irTransClients.has_key(name) :
            self._xplPlugin.log.debug(u"IRtransceiver Clients Manager : IRtransceiver {0} already exist, not added.".format(name))
            return False
        else:
            if checkIfConfigured(device["device_type_id"],  device ) :
                if device["device_type_id"] == "irtrans.irtrans_lan" :
                    self.irTransClients[name] = IRTransClient(self,  device,  self._xplPlugin.log)
                elif  device["device_type_id"] == "irtrans.irwsserver" :
                    self.irTransClients[name] = IRWSClient(self,  device,  self._xplPlugin.log)
                else :
                    self._xplPlugin.log.error(u"IRtransceiver Clients Manager : IRtransceiver type {0} not exist, not added.".format(name))
                    return False                
                self._xplPlugin.log.info(u"IRtransciever Clients Manager : created new client {0}.".format(name))
            else : 
                self._xplPlugin.log.info(u"IRtransciever Clients Manager : device not configured can't add new client {0}.".format(name))
                return False
#            pprint.pprint(device)
            return True