Called when a message is received with decoded JSON content

def recv(self, message, ref, pos):
        """
        Called when a message is received with decoded JSON content
        """

        # Get action
        action = message.get('action', None)

        # Show the message we got
        if action != 'pingdog':
            self.debug("{} - Receive: {} (ref:{}) - {}".format(pos.name.encode('ascii', 'ignore'), message, ref, pos.uuid), color="cyan")

        # Check the action that it is requesting
        if action == 'get_config':
            # Get all the hardware connected to this POS
            answer = {}
            answer['action'] = 'config'
            answer['commit'] = pos.commit
            answer['hardware'] = []
            for hw in pos.hardwares.filter(enable=True):
                # Prepare to send back the config
                answer['hardware'].append({'kind': hw.kind, 'config': hw.get_config(), 'uuid': hw.uuid.hex})
            self.debug(u"{} - Send: {} - {}".format(pos.name.encode('ascii', 'ignore'), answer, pos.uuid), color='green')
            self.send(answer, ref, pos)
        elif action == 'subscribe':
            # Get UUID
            uid = message.get('uuid', None)
            # Check if we got a valid UUID
            if uid:
                uid = uuid.UUID(uid)
                poshw = POSHardware.objects.filter(uuid=uid).first()
                if poshw:
                    if poshw.enable:
                        # Suscribe this websocket to group
                        self.debug("{} - Subscribed to '{}' - {}".format(pos.name.encode('ascii', 'ignore'), uid.hex, pos.uuid), color="purple")
                        Group(uid.hex).add(self.message.reply_channel)
                        self.send({'action': 'subscribed', 'uuid': uid.hex, 'key': poshw.key}, ref, pos)
                    else:
                        self.send_error("You cannot subscribe to a disabled Hardware!", ref, pos)
                else:
                    self.send_error("You cannot subscribe to a Hardware that is not available, UUID not found!", ref, pos)
            else:
                self.send_error("You have tried to subscribe to a UUID but didn't specify any or is invalid", ref, pos)
        elif action == 'msg':
            uid = message.get('uuid', None)
            msg = message.get('msg', None)
            if uid:
                origin = POSHardware.objects.filter(uuid=uuid.UUID(uid)).first()
                if origin:
                    self.debug("{} - Got a message from {}: {} (ref:{}) - {}".format(pos.name.encode('ascii', 'ignore'), origin.uuid, msg, ref, pos.uuid), color='purple')
                    origin.recv(msg)
                else:
                    self.debug("{} - Got a message from UNKNOWN {}: {} (ref:{}) - {}".format(pos.name.encode('ascii', 'ignore'), uid, msg, ref, pos.uuid), color='purple')
            else:
                self.debug("{} - Got a message from NO-UUID: {} (ref:{}) - {}".format(pos.name.encode('ascii', 'ignore'), msg, ref, pos.uuid), color='purple')
        elif action == 'ping':
            super(POSConsumer, self).send({'message': json.dumps({'action': 'pong', 'ref': ref})})
        elif action == 'pong':
            self.debug("{} - Got PONG {} (ref:{}) - {}".format(pos.name.encode('ascii', 'ignore'), message.get('ref', '-'), ref, pos.uuid), color='white')
        elif action == 'pingdog':
            super(POSConsumer, self).send({'message': json.dumps({'action': 'pongdog', 'ref': ref})})
        elif action == 'error':
            uid = message.get('uuid', None)
            msg = message.get('error', 'No error')
            if uid:
                self.error("{} - Got an error from {}: {} (UUID:{}) (ref:{}) - {}".format(pos.name.encode('ascii', 'ignore'), pos.uuid, msg, uid, ref, pos.uuid))
            else:
                self.error("{} - Got an error from {}: {}) (ref:{}) - {}".format(pos.name.encode('ascii', 'ignore'), pos.uuid, msg, ref, pos.uuid))
            log = POSLog()
            log.pos = pos
            if uid:
                poshw = POSHardware.objects.filter(uuid=uid).first()
                if poshw:
                    log.poshw = poshw
                    log.uuid = poshw.uuid
            else:
                log.uuid = pos.uuid
            log.log = message.get('error', None)
            log.save()
        else:
            # Unknown action
            self.send_error("Unknown action '{}'".format(action), ref, pos)