示例#1
0
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        if msg.get_action() == "client.cmd":
            data = msg.get_data()
            self.log.info(u"==> Received 0MQ messages data: %s" % format(data))
            # ==> Received 0MQ messages data: {u'command_id': 35, u'value': u'1', u'device_id': 112}
            # ==> Received 0MQ messages data: {u'command_id': 36, u'value': u'128', u'device_id': 113}
            # ==> Received 0MQ messages data: {u'command_id': 37, u'value': u'Bonjour', u'device_id': 114}

            # search for related device
            for a_device in self.devices:
                for a_cmd in a_device['commands']:
                    if data['command_id'] == a_device['commands'][a_cmd]['id']:
                        # As we will just execute a shell script, we can't really known if the command will be ok and how long it will take...
                        # so we respond first on MQ to say we got the request

                        self.log.info("Reply to command 0MQ")
                        reply_msg = MQMessage()
                        reply_msg.set_action('client.cmd.result')
                        reply_msg.add_data('status', True)
                        reply_msg.add_data('reason', '')
                        self.reply(reply_msg.get())

                        # Now, launch the speak action !
                        ip = self.get_parameter(a_device, "ip")
                        lang = 'fr-FR'
                        thr_speak = threading.Thread(None,
                                                     self.yi.speak,
                                                     "speak",
                                                     (ip, lang, data['text'], self.get_data_files_directory),
                                                     {})
                        thr_speak.start()
        self.register_thread(thr_speak)
示例#2
0
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        self.log.info(u"Received 0MQ messages: {0}".format(msg))
        action = msg.get_action().split(".")
        if action[0] == "client" and action[1] == "cmd" :
            # action on dmg device
            data = msg.get_data()
            reply_msg = MQMessage()
            reply_msg.set_action('client.cmd.result')
            idsClient = self.managerClients.getIdsClient(data)
            find = False
            if idsClient != [] :
                for id in idsClient :
                    client = self.managerClients.getClient(id)
                    if client :
                        self.log.debug(u"Handle requested action for Notify client {0} : {1}".format(id, data))
                        commands = client.getDmgCommands()
                        for cmd in commands :
                            if commands[cmd]['id'] == data['command_id'] :
                                find = True
                                client.handle_cmd(data)
                                reply_msg.add_data('status', True)
                                reply_msg.add_data('reason', None)
                                break

            if not find :
                self.log.warning(u"Requested action received for unknown Notify client : {0}".format(data))
                reply_msg.add_data('status', False)
                reply_msg.add_data('reason', u"Requested action received for unknown Notify client : {0}".format(data))
            self.log.debug(u"Reply to MQ: {0}".format(reply_msg.get()))
            self.reply(reply_msg.get())
示例#3
0
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        #self.log.debug(u"==> Received 0MQ messages: %s" % format(msg))
        if msg.get_action() == "client.cmd":
            data = msg.get_data()
            self.log.debug(u"==> Received 0MQ messages data: %s" %
                           format(data))
            # ==> Received 0MQ messages data: {u'command_id': 35, u'value': u'1', u'device_id': 112}
            # ==> Received 0MQ messages data: {u'command_id': 36, u'value': u'128', u'device_id': 113}
            # ==> Received 0MQ messages data: {u'command_id': 37, u'value': u'Bonjour', u'device_id': 114}

            sensor_id = self.get_related_sensor_id(data['device_id'],
                                                   data['command_id'])
            self.log.debug(u"Storing data for sensor_id = {0} : '{1}'".format(
                sensor_id, data["value"]))
            status, reason = self.send_data(sensor_id, data["value"])

            self.log.info("Reply to command 0MQ")
            reply_msg = MQMessage()
            reply_msg.set_action('client.cmd.result')
            reply_msg.add_data('status', status)
            reply_msg.add_data('reason', reason)
            self.reply(reply_msg.get())
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        self.log.info(u"==> Received 0MQ messages: %s" % format(msg))
        if msg.get_action() == "client.cmd":
            reason = None
            status = True
            data = msg.get_data()

            device_id = data["device_id"]
            command_id = data["command_id"]
            if device_id not in self.device_list:
                self.log.error(
                    u"### MQ REQ command, Device ID '%s' unknown, Have you restarted the plugin after device creation ?" % device_id)
                status = False
                reason = u"Plugin nestdevice: Unknown device ID %d" % device_id
                self.send_rep_ack(status, reason, command_id, "unknown");
                return

            device_name = self.device_list[device_id]["name"]
            self.log.info(u"==> Received for device '%s' MQ REQ command message: %s" % (device_name, format(data)))
            for a_device in self.devices:
                if a_device["id"] == device_id:
                    if a_device["device_type_id"] == "nest.home":
                        sensor_name = self.get_parameter(a_device, "name")
                        self.log.info(u"==> Received for nest name or serial '%s' MQ REQ command message: %s" % (
                        sensor_name, format(data)))
                        status, reason = self.NESTclass.writeState(sensor_name, "away", data["away"])
                    elif a_device["device_type_id"] == "nest.thermostat":
                        sensor_name = self.get_parameter(a_device, "serial")
                        self.log.info(u"==> Received for nest name or serial '%s' MQ REQ command message: %s" % (
                        sensor_name, format(data)))
                        if "temperature" in data:
			    status, reason = self.NESTclass.writeState(sensor_name, "temperature", data["temperature"])
			elif "mode" in data:
			    status, reason = self.NESTclass.writeState(sensor_name, "mode", data["mode"])
			elif "fan" in data:
			    status, reason = self.NESTclass.writeState(sensor_name, "fan", data["fan"])
			else:
                            self.log.error(u"==> Command not implemented yet")

                        # This should be eaisier but not available
                    #	    sensor_name = self.get_parameter(self.device_list[device_id], "name")
                    #


                    # TODO return status by calling back for good sensors
                    #            if status:
                    #                self.send_pub_data(device_id, format(data))
                    #                self.send_pub_data(device_id, data["away"])

            self.send_rep_ack(status, reason, command_id, device_name);
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        # self.log.info(u"==> Received 0MQ messages: %s" % format(msg))
        if msg.get_action() == "client.cmd":
            reason = None
            status = True
            data = msg.get_data()
            self.log.info(u"==> Received 0MQ messages data: %s" % format(data))

            self.log.info(u"Reply to command 0MQ")
            reply_msg = MQMessage()
            reply_msg.set_action('client.cmd.result')
            reply_msg.add_data('status', status)
            reply_msg.add_data('reason', reason)
            self.reply(reply_msg.get())
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        ### NON TESTE !

        Plugin.on_mdp_request(self, msg)
        #self.log.info(u"==> Received MQ message: %s" % format(msg))
        # => MQ Request received : <MQMessage(action=client.cmd, data='{u'state': u'1', u'command_id': 14, u'device_id': 39}')>

        if msg.get_action() == "client.cmd":
            data = msg.get_data()
            #self.log.debug(u"==> Received MQ REQ command message: %s" % format(data))
            # DEBUG ==> Received MQ REQ command message: {u'value': u'1', u'command_id': 50, u'device_id': 139}
            device_id = data["device_id"]
            command_id = data["command_id"]

            # {"44.0": {"name": "Bureau", "dmgid": "120", "vtype": "V_STATUS"}}
            for node in self.mysensorsmanager.nodes:
                if '255' not in node:
                    if nodes[node]['dmgid'] == device_id:
                        nodesensor_name = nodes[node]['name']  # "Relay #1"
                        nodesensor_vtype = nodes[node]['vtype']  # "V_STATUS"
                        break
            if nodesensor_vtype in [
                    "V_STATUS", "V_UP", "V_DOWN", "V_STOP", "V_PERCENTAGE",
                    "V_IR_SEND"
            ]:
                msg = node.replace(
                    ".",
                    ";") + '1;0;' + self.mysensorsmanager.setreqType.index(
                        nodesensor_vtype) + ";" + data["value"] + "\n"
                # msg = "42;0;1;0;2;1\n"      nodeid;childsensorid;set command;no ack;vtype;value\n
                # Command from the controller (1 = SET), Outgoing message to node 42 child sensor 0, Set V_STATUS (2) variable to 1 (turn on). No ack is requested from destination node.
                self.log.info(
                    u"==> Send SET message '%s' for device '%s/%s' (id:%s) to Gateway"
                    % (msg, nodesensor_name, nodesensor_vtype.lower(),
                       device_id))
                self.mysensorsmanager.msgSendQueue.put(msg)

                # Reply MQ REP (acq) to REQ command
                self.send_rep_ack(True, None, command_id, device_name)
            else:
                self.log.error(
                    u"### Node sensor vtype not found for device '%s' (id:%s)"
                    % (nodesensor_name, device_id))
示例#7
0
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        # self.log.info(u"==> Received 0MQ messages: %s" % format(msg))
        if msg.get_action() == "client.cmd":
            data = msg.get_data()
            self.log.info(u"==> Received 0MQ messages data: %s" % format(data))
            # ==> Received 0MQ messages data: {u'command_id': 35, u'value': u'1', u'device_id': 112}
            # ==> Received 0MQ messages data: {u'command_id': 36, u'value': u'128', u'device_id': 113}
            # ==> Received 0MQ messages data: {u'command_id': 37, u'value': u'Bonjour', u'device_id': 114}

            status, reason = self.send_data(data["device_id"], data["value"])

            self.log.info("Reply to command 0MQ")
            reply_msg = MQMessage()
            reply_msg.set_action('client.cmd.result')
            reply_msg.add_data('status', status)
            reply_msg.add_data('reason', reason)
            self.reply(reply_msg.get())
示例#8
0
    def on_mdp_request(self, msg):
        """ Routine call when a MQ message arrive
		"""
        Plugin.on_mdp_request(self, msg)
        command = ""
        self.log.info("Test: %s" % msg)
        if msg.get_action() == "client.cmd":
            data = msg.get_data()
            self.log.info(data)
            cmdadr = commands_list[data["command_id"]]
            reason = None
            status = True
            val = data['value']

            self.log.info(datapoint_list)
            command_id = data['device_id']
            datatype = datapoint_list[cmdadr]
            value = encodeKNX(datatype, val)
            data_type = value[0]
            valeur = value[1]

            if data_type == "s":
                command = "groupswrite ip:%s %s %s" % (self.knx_host, cmdadr,
                                                       valeur)
                if self.knx_host_type == "KNXTOOL":
                    command = "knxtool " + command

            if data_type == "l":
                command = "groupwrite ip:%s %s %s" % (self.knx_host, cmdadr,
                                                      valeur)
                if self.knx_host_type == "KNXTOOL":
                    command = "knxtool " + command
            if command != "":
                subp = subprocess.Popen(command, shell=True)
            else:
                self.log.info("erreur command non définir, type cmd= %s" %
                              type_cmd)
                reason = "Command not define"
                status = False

            self.send_rep_ack(status, reason, command_id)
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        if msg.get_action() == "client.cmd":
            data = msg.get_data()
            self.log.info(u"==> Received 0MQ message data: %s" % format(data))
            # INFO ==> Received 0MQ message data: {u'message': u'Bonjour', u'command_id': 49, u'position': u'center', u'device_id': 132}
            self.display.osdmsg = data['message'] + self.osdmsgtype[
                data['position']]
            self.log.info(u"==> Message = '%s'" % self.display.osdmsg)

            status = True
            reason = None

            self.log.info("Reply to command 0MQ")
            reply_msg = MQMessage()
            reply_msg.set_action('client.cmd.result')
            reply_msg.add_data('status', status)
            reply_msg.add_data('reason', reason)
            self.reply(reply_msg.get())
示例#10
0
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        # self.log.info(u"==> Received 0MQ messages: %s" % format(msg))
        if msg.get_action() == "client.cmd":
            reason = None
            status = True
            data = msg.get_data()

            device_id = data["device_id"]
            command_id = data["command_id"]
            if device_id not in self.mqttdevices_list:
                self.log.error(u"### MQ REQ command, Device ID '%s' unknown" %
                               device_id)
                status = False
                reason = u"Plugin mqtt: Unknown device ID %d" % device_id
                self.send_rep_ack(status, reason, command_id, "unknown")
                # Reply MQ REP (acq) to REQ command
                return

            device_name = self.mqttdevices_list[device_id]["name"]
            self.log.info(
                u"==> Received for device '%s' MQ REQ command message: %s" %
                (device_name, format(data))
            )  # {u'value': u'1', u'command_id': 80, u'device_id': 193}

            status, reason = self.mqttClient.pubcmd(
                self.mqttdevices_list[device_id]["topic"],
                self.mqttdevices_list[device_id]["qos"], data["value"],
                device_id)
            if status:
                self.send_pub_data(device_id,
                                   data["value"])  # Update sensor command.

            # Reply MQ REP (acq) to REQ command
            self.send_rep_ack(status, reason, command_id, device_name)
示例#11
0
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        # self.log.info(u"==> Received 0MQ messages: %s" % format(msg))
        if msg.get_action() == "client.cmd":
            reason = None
            status = True
            data = msg.get_data()

            device_id = data["device_id"]
            command_id = data["command_id"]
            if device_id not in self.device_list:
                self.log.error(
                    u"### MQ REQ command, Device ID '%s' unknown, Have you restarted the plugin after device creation ?"
                    % device_id)
                status = False
                reason = u"Plugin onewired: Unknown device ID %d" % device_id
                self.send_rep_ack(status, reason, command_id, "unknown")
                # Reply MQ REP (acq) to REQ command
                return

            device_name = self.device_list[device_id]["name"]
            self.log.info(
                u"==> Received for device '%s' MQ REQ command message: %s" %
                (device_name, format(data))
            )  # {u'command_id': 70, u'value': u'1', u'device_id': 169}

            status, reason = self.onewire.writeSensor(
                self.device_list[device_id]["address"],
                self.device_list[device_id]["properties"], data["value"])
            if status:
                self.send_pub_data(device_id,
                                   data["value"])  # Update sensor command.

            # Reply MQ REP (acq) to REQ command
            self.send_rep_ack(status, reason, command_id, device_name)
    def on_mdp_request(self, msg):
        """ Called when a MQ req/rep message is received
        """
        Plugin.on_mdp_request(self, msg)
        self.log.info(u"==> Received 0MQ messages: %s" % format(msg))
        if msg.get_action() == "client.cmd":
            reason = None
            status = True
            data = msg.get_data()

            device_id = data["device_id"]
            command_id = data["command_id"]
            if device_id not in self.device_list:
                self.log.error(
                    u"### MQ REQ command, Device ID '%s' unknown, Have you restarted the plugin after device creation ?"
                    % device_id)
                status = False
                reason = u"Plugin nestdevice: Unknown device ID %d" % device_id
                self.send_rep_ack(status, reason, command_id, "unknown")
                return

            device_name = self.device_list[device_id]["name"]
            self.log.info(
                u"==> Received for device '%s' MQ REQ command message: %s" %
                (device_name, format(data)))
            for a_device in self.devices:
                if a_device["id"] == device_id:
                    if a_device["device_type_id"] == "nest.home":
                        sensor_name = self.get_parameter(a_device, "name")
                        self.log.info(
                            u"==> Received for nest name or serial '%s' MQ REQ command message: %s"
                            % (sensor_name, format(data)))
                        status, reason = self.NESTclass.writeState(
                            sensor_name, "away", data["away"])
                    elif a_device["device_type_id"] == "nest.thermostat":
                        sensor_name = self.get_parameter(a_device, "serial")
                        self.log.info(
                            u"==> Received for nest name or serial '%s' MQ REQ command message: %s"
                            % (sensor_name, format(data)))
                        if "temperature" in data:
                            status, reason = self.NESTclass.writeState(
                                sensor_name, "temperature",
                                data["temperature"])
                        elif "mode" in data:
                            status, reason = self.NESTclass.writeState(
                                sensor_name, "mode", data["mode"])
                        elif "fan" in data:
                            status, reason = self.NESTclass.writeState(
                                sensor_name, "fan", data["fan"])
                        else:
                            self.log.error(u"==> Command not implemented yet")

                        # This should be eaisier but not available
                    #	    sensor_name = self.get_parameter(self.device_list[device_id], "name")
                    #

                    # TODO return status by calling back for good sensors
                    #            if status:
                    #                self.send_pub_data(device_id, format(data))
                    #                self.send_pub_data(device_id, data["away"])

            self.send_rep_ack(status, reason, command_id, device_name)
 def on_mdp_request(self, msg):
     # display the req message
     Plugin.on_mdp_request(self, msg)
     # call a function to reply to the message depending on the header
     action = msg.get_action().split(".")
     self.log.debug(u"MQ Request {0}".format(msg))
     if action[0] == 'vigilightning':
         handled = False
         status = False
         reason = u""
         data = msg.get_data()
         self.log.debug(u"Handle MQ request action {0}.".format(action))
         reply_msg = MQMessage()
         reply_msg.set_action("{0}.{1}.{2}".format(action[0], action[1],
                                                   action[2]))
         if action[1] == "manager":
             if action[2] in [
                     'getalertstatus', 'getstrikes', 'getalertevents',
                     'gethistorystrikes', 'setdeviceparams'
             ]:
                 if 'device_id' in data:
                     handled = True
                     status = True
                     data['device_id'] = int(data['device_id'])
                     reply_msg.add_data('device_id', data['device_id'])
                     if data['device_id'] in self.vigi_List:
                         if action[2] == 'getalertstatus':
                             report = self.vigi_List[
                                 data['device_id']].getAlertStatus()
                             for k, item in report.items():
                                 reply_msg.add_data(k, item)
                         if action[2] == 'getstrikes':
                             report = self.vigi_List[
                                 data['device_id']].getStrikes()
                             reply_msg.add_data('strikes', report)
                         if action[2] == 'getalertevents':
                             report = self.vigi_List[
                                 data['device_id']].getLastHistoryAlert(
                                     int(data['number']))
                             reply_msg.add_data('events', report)
                         if action[2] == 'gethistorystrikes':
                             eventAlert = {
                                 "level": int(data['level']),
                                 "begin": float(data['begin']),
                                 "end": float(data['end'])
                             }
                             report = self.vigi_List[
                                 data['device_id']].getEventHistoryStrike(
                                     eventAlert)
                             reply_msg.add_data('strikes', report)
                         if action[2] == 'setdeviceparams':
                             for a_device in self.devices:
                                 if a_device['id'] == data['device_id']:
                                     nbParam = 0
                                     nb = 0
                                     for p in data:
                                         if self.getDeviceParamId(
                                                 a_device, p):
                                             nbParam += 1
                                     for p in data:
                                         paramid = self.getDeviceParamId(
                                             a_device, p)
                                         if paramid:
                                             nb += 1
                                             topublish = (nb == nbParam)
                                             self.log.debug(
                                                 u"udpate_device_param {0}: id {1} valule {2}"
                                                 .format(
                                                     p, paramid, data[p]))
                                             self.udpate_device_param(
                                                 paramid, data[p],
                                                 topublish)
                     else:
                         reason = u"Unknown device {0}".format(
                             data['device_id'])
                 else:
                     reason = u"Abording command, no extra key 'device_id' in MQ command: {0}".format(
                         data)
         elif action[1] == "plugin":
             if action[2] == 'getlog':
                 handled = True
                 report = self.getLoglines(data)
                 for k, item in report.items():
                     reply_msg.add_data(k, item)
             if action[2] == 'getwsstatus':
                 handled = True
                 report = self.getWSStatus()
                 for k, item in report.items():
                     reply_msg.add_data(k, item)
         if not handled:
             self.log.warning(
                 u"MQ request unknown action {0} : {1}.".format(
                     action, data))
             reply_msg.add_data('status', False)
             reply_msg.add_data(
                 'reason',
                 u"Abording command, unknown action {0} : {1}.".format(
                     action, data))
             self.reply(reply_msg.get())
         else:
             reply_msg.add_data('status', status)
             reply_msg.add_data('reason', reason)
             self.reply(reply_msg.get())
示例#14
0
    def on_mdp_request(self, msg):
        self.log.error(u"Received MQ command, processing...")
        Plugin.on_mdp_request(self, msg)
        b = Bridge(self.ip_bridge)
        b.connect()
        sensors = {}
        if msg.get_action() == "client.cmd":
            reason = None
            status = True
            data = msg.get_data()
            device_id = data["device_id"]
            command_id = data["command_id"]
            if device_id not in self.device_list:
                self.log.error(
                    u"### MQ REQ command, Device ID '%s' unknown, Have you restarted the plugin after device creation ?"
                    % device_id)
                status = False
                reason = u"Plugin Hue: Unknown device ID %d" % device_id
                self.send_rep_ack(status, reason, command_id, "unknown")
                # Reply MQ REP (acq) to REQ command
                return
            device_name = self.device_list[device_id]["name"]
            self.log.debug(u"==> Received MQ REQ command message: %s" %
                           format(data))
            command = list(self.commands[device_id].keys())[list(
                self.commands[device_id].values()).index(command_id)]
            if command == "set_brightness":
                if data['current'] == 0:
                    sensors[self.sensors[device_id]['light']] = 0
                else:
                    sensors[self.sensors[device_id]['light']] = 1
                sensors[self.sensors[device_id]
                        ['brightness']] = data['current']
                try:
                    self._pub.send_event('client.sensor', sensors)
                except:
                    # We ignore the message if some values are not correct
                    self.log.debug(
                        u"Bad MQ message to send. This may happen due to some invalid rainhour data. MQ data is : {0}"
                        .format(data))
                    pass

                new_value = int(data['current']) * 254 / 100
                self.log.debug(u"Set brightness to '%s'  light to '%s'" %
                               (data['current'], new_value))
                set = b.set_light(self.device_list[device_id]['address'],
                                  'bri', new_value)
                if ("success" in set):
                    if (set.index("success")) != -1:
                        status = True
                    else:
                        status = False
            elif command == "set_on":
                sensors[self.sensors[device_id]['light']] = data['current']
                try:
                    self._pub.send_event('client.sensor', sensors)
                except:
                    # We ignore the message if some values are not correct
                    self.log.debug(
                        u"Bad MQ message to send. This may happen due to some invalid rainhour data. MQ data is : {0}"
                        .format(data))
                    pass
                set = b.set_light(
                    self.device_list[device_id]['address'], 'on',
                    self.from_DT_Switch_to_off_on(
                        sensors[self.sensors[device_id]['light']]))
                if ("success" in set):
                    if (set.index("success")) != -1:
                        status = True
                    else:
                        status = False
            elif command == "send_alert":
                self.log.debug(u"Sending alert on device " +
                               self.device_list[device_id]['address'])
                sensors[self.sensors[device_id]['light']] = data['current']
                try:
                    self._pub.send_event('client.sensor', sensors)
                except:
                    # We ignore the message if some values are not correct
                    self.log.debug(
                        u"Bad MQ message to send. This may happen due to some invalid rainhour data. MQ data is : {0}"
                        .format(data))
                    pass
                set = b.set_light(self.device_list[device_id]['address'],
                                  'alert', 'lselect')
                if ("success" in set):
                    if (set.index("success")) != -1:
                        status = True
                    else:
                        status = False

            # Reply MQ REP (acq) to REQ command
            self.send_rep_ack(status, reason, command_id, device_name)
            return
    def on_mdp_request(self, msg):
        # display the req message
        Plugin.on_mdp_request(self, msg)
        # call a function to reply to the message depending on the header
        action = msg.get_action().split(".")
        if action[0] == 'rfplayer':
            handled = False
            self.log.debug(u"Handle MQ request action <{0}>.".format(action))
            if action[1] in ["manager", "client"]:
                handled = True
                data = msg.get_data()
                report = self.managerRFP.processRequest(
                    "{0}.{1}".format(action[1], action[2]), data)
                # send the reply
                reply_msg = MQMessage()
                reply_msg.set_action("{0}.{1}.{2}".format(
                    action[0], action[1], action[2]))
                for k, item in report.items():
                    reply_msg.add_data(k, item)
                self.reply(reply_msg.get())
                if "ack" in data and data['ack'] == "pub":
                    self.publishMsg(
                        "{0}.{1}.{2}".format(action[0], action[1], action[2]),
                        report)
            if not handled:
                self.log.warning(
                    u"MQ request unknown action <{0}>.".format(action))
        elif action[0] == "client" and action[1] == "cmd":
            # action on dmg device
            data = msg.get_data()
            cmd = {}
            for k in data.keys():
                if k not in ['device_id', 'command_id']:
                    cmd[k] = data[k]
            reply_msg = MQMessage()
            reply_msg.set_action('client.cmd.result')
            if cmd != {}:
                device = self.dmgDeviceFromId(data['device_id'])
                if device:
                    status, reason = self.managerRFP.sendRFPcmd(
                        device, data['command_id'], cmd)
                    reply_msg.add_data('status', status)
                    reply_msg.add_data('reason', reason)
                else:
                    self.log.warning(
                        u"Abording command, no device found for command MQ: {0}"
                        .format(data))
                    reply_msg.add_data('status', False)
                    reply_msg.add_data(
                        'reason',
                        u"Abording command, no device found for MQ command: {0}"
                        .format(data))
            else:
                self.log.warning(
                    u"Abording command, no extra key in command MQ: {0}".
                    format(data))
                reply_msg.add_data('status', False)
                reply_msg.add_data(
                    'reason',
                    u"Abording command, no extra key in MQ command: {0}".
                    format(data))

            self.log.debug(u"Reply to MQ: {0}".format(reply_msg.get()))
            self.reply(reply_msg.get())