Issue sending data to MQTT

Issue sending data to MQTT

@Maurizio Spadari

Hello,
I have added a MQTT and I am testing it via a Python application on my MacMini which makes use paho library.
If I look at Live inspector it seems that I am able to connect but anything I publish does not appear.
I took a Python code similar to the one cited in 1 of the examples:import paho.mqtt.client as mqtt

import paho.mqtt.client as mqtt
import random
import json

# Definitions
# put here your device token
device_token = 'TeslaMate'

broker = "mqtt.tago.io"
broker_port = 8883
mqtt_keep_alive = 60

# MQTT publish topic must be tago/data/post
mqtt_publish_topic = "temperature"

# put any name here, TagoIO doesn't validate this username.
mqtt_username = 'tagoio'

# MQTT password must be the device token (TagoIO does validate this password)
mqtt_password =<my token>

# Callback - MQTT broker connection is on


def on_connect(client, userdata, flags, rc):
    print("[STATUS] Connected to MQTT broker. Result: " + str(rc))


def on_publish():
    print("Message published")
# Main program


print("[STATUS] Initializing MQTT...")
client = mqtt.Client()
client.username_pw_set(mqtt_username, mqtt_password)
client.tls_set_context()
client.on_connect = on_connect
x = client.connect(broker, broker_port, mqtt_keep_alive)

# Generate a random temperature to send to TagoIO (from 32 to 86F)
temperature = random.randint(32,86)
txt_temperature="Random temperature generated: {rand_temp}F"
print(txt_temperature.format(rand_temp=temperature) )

# Format data into JSON
temperature_json = {"variable": "temperature", "unit": "F", "value": temperature}
temperature_json_string = json.dumps(temperature_json)

# Send data to TagoIO using MQTT
y = client.publish(mqtt_publish_topic, temperature_json_string)
print(y.rc)
print(y.is_published())
print("Data sent to TagoIO platform")

What I see is on pYthon console is:[STATUS] Initializing MQTT…

Random temperature generated: 78F
0
True
Data sent to TagoIO platform

so the the method is_published() returns true. However the Live inspector returns :