import paho.mqtt.client as mqtt

# Datos de conexión
broker = "localhost"
puerto = 1883
topic = "test/topic"

# Crear una instancia del cliente MQTT
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)

# Conectar al broker
client.connect(broker, puerto, 60)

# Publicar un mensaje en el topic
client.publish(topic, payload="Hello, MQTT!", qos=0, retain=False)

# Desconectar
client.disconnect()
