Publish a MQTT message

def command_publish(self, command, **kwargs):
        """ Publish a MQTT message """
        mqttc = mqtt.Client()
        mqttc.connect(
            command['host'],
            port=int(command['port']))

        mqttc.loop_start()

        try:
            mqttc.publish(
                command['endpoint'],
                command['payload'])
        finally:
            mqttc.loop_stop(force=False)