made print to see if message is sent correctly

This commit is contained in:
ishak jmilou.ishak
2024-10-22 14:53:14 +02:00
parent 5739655e97
commit 0b40f63af0

View File

@@ -8,7 +8,6 @@ mqtt_client = mqtt.Client()
# Verbinding maken met de Raspberry Pi (broker) # Verbinding maken met de Raspberry Pi (broker)
mqtt_client.username_pw_set("ishak", "kobuki") mqtt_client.username_pw_set("ishak", "kobuki")
mqtt_client.connect("ishakpi.ddns.net", 1883, 60) mqtt_client.connect("ishakpi.ddns.net", 1883, 60)
client = mqtt.Client(protocol=mqtt.MQTTv311)
@app.route('/') @app.route('/')
def index(): def index():
@@ -16,7 +15,11 @@ def index():
@app.route('/move', methods=['POST']) @app.route('/move', methods=['POST'])
def move(): def move():
mqtt_client.publish("home/commands", "Knop ingedrukt!") result = mqtt_client.publish("home/commands", "Knop ingedrukt!")
if result.rc == mqtt.MQTT_ERR_SUCCESS:
print("Bericht succesvol gepubliceerd")
else:
print("Fout bij het publiceren van bericht")
return "Bericht verzonden!" return "Bericht verzonden!"
if __name__ == '__main__': if __name__ == '__main__':