Tag Archive For "Python MQTT Subscribe"
Python MQTT Subscribe Kodu
import paho.mqtt.client as mqtt def on_connect(client, userdata, flags, rc): if rc == 0: print (“MQTT OK.”) client.subscribe(“sensor/balkon/sicaklik”) client.subscribe(“sensor/balkon/nem”) else: print (rc) def on_message(client, userdata, message): if message.topic == “sensor/balkon/sicaklik”: s1 = str(message.payload.decode(“utf-8”)) print (“Sicaklik :”,s1.split(“.”)[0]) if message.topic == “sensor/balkon/nem”: s2 = str(message.payload.decode(“utf-8”)) print (“Nem :”, s2.split(“.”)[0]) client = mqtt.Client(“Python1”) client.on_connect = on_connect client.on_message = on_message …