I’ve been using the micropython mqtt examples in the tutorial book and they work really well, I’ve been able to send messages and receive messages and even control devices flashed with tasmota.
I’ve also used the excellent introduction to node red to checkout messages and alter messages.
Can you give me an example of using ‘QoS’ and ‘last_will’ from micropython ?
Can you also tell me what is the best way of checking that they have been set on the server ?
(I’m using mosquitto on the raspberry pi ?)
Peter
Hi Peter
When publishing messages, you can pass the QoS as an argument.
For example:
client.publish(topic_pub, msg, qos=1)
The QoS can be 0, 1, or 2. When you don’t set the QoS, it is set to 0, by default.
I’ve never used the last_will method. But accordingly to the library, it should be used liked this:
client.set_last_will(topic, msg, qos=0)
What do you mean by “checking that they have been set on the server?” You mean you want to be sure that the last_will is working?
For that, you need to disconnect the publisher and see if the subscribers get the last will message.
I hope this helps.
Regards,
Sara