def mqtt_on_message(self, client, userdata, msg):
    LOG.info('MQTT Message %s %s', msg.topic, str(msg.payload))
    if msg.topic.startswith(self.mqtt_base_topic):
        topic = msg.topic[(len(self.mqtt_base_topic) + 1):]
        parts = topic.split('/')
        controller_name = parts[1]
        component = parts[2]
        num = int(parts[3])
        iocontroller = self.service.controllers[controller_name]
        if (controller_name not in self.service.controllers.keys()):
            LOG.warning("Message for unknown iocontroller '%s'", controller_name)
            return
        if (component not in ['digitaloutput']):
            LOG.warning("Message for unknown component '%s'", component)
            return
        if (num > iocontroller.num_digital_outputs):
            LOG.warning('Output too high for this board: %s', num)
            return
        action = msg.payload.decode('utf-8').strip().upper()
        if (action not in ['OFF', 'ON']):
            LOG.warning("Unsupported action '%s'", action)
            return
        LOG.debug('Requesting %s %s %s %s %s', iocontroller, controller_name, component, num, action)
        iocontroller.request_digitaloutput(ComponentState(component='digitaloutput', num=num, status=action))
def mqtt_on_message(self, client, userdata, msg):
    LOG.info('MQTT Message %s %s', msg.topic, str(msg.payload))
    if msg.topic.startswith(self.mqtt_base_topic):
        topic = msg.topic[(len(self.mqtt_base_topic) + 1):]
        parts = topic.split('/')
        controller_name = parts[1]
        component = parts[2]
        num = int(parts[3])
        iocontroller = self.service.controllers[controller_name]
        if (controller_name not in self.service.controllers.keys()):
            LOG.warning("Message for unknown iocontroller '%s'", controller_name)
            return
        if (component not in ['digitaloutput']):
            LOG.warning("Message for unknown component '%s'", component)
            return
        if (num > iocontroller.num_digital_outputs):
            LOG.warning('Output too high for this board: %s', num)
            return
        action = msg.payload.decode('utf-8').strip().upper()
        if (action not in ['OFF', 'ON']):
            LOG.warning("Unsupported action '%s'", action)
            return
        LOG.debug('Requesting %s %s %s %s %s', iocontroller, controller_name, component, num, action)
        iocontroller.request_digitaloutput(ComponentState(component='digitaloutput', num=num, status=action))