Complete the code to set the MQTT QoS level to 1 when publishing a message.
client.publish('sensor/data', payload='temperature', qos=[1])
The QoS level 1 ensures the message is delivered at least once.
Complete the code to subscribe to the topic 'home/livingroom' with QoS level 2.
client.subscribe('home/livingroom', qos=[1])
QoS 2 ensures the message is delivered exactly once, the highest level of guarantee.
Fix the error in the code to correctly publish a message with QoS 0.
client.publish('alerts', payload='fire detected', qos=[1])
QoS 0 means the message is sent once with no confirmation.
Fill both blanks to create a subscription with QoS 1 and publish a message with QoS 2.
client.subscribe('devices/status', qos=[1]) client.publish('devices/status', payload='online', qos=[2])
Subscription uses QoS 1 for at least once delivery, publishing uses QoS 2 for exactly once delivery.
Fill all three blanks to publish a message with QoS 1, subscribe with QoS 0, and publish another message with QoS 2.
client.publish('alerts', payload='low battery', qos=[1]) client.subscribe('alerts', qos=[2]) client.publish('alerts', payload='battery critical', qos=[3])
The first publish uses QoS 1 for at least once delivery, subscription uses QoS 0 for no guarantee, and the second publish uses QoS 2 for exactly once delivery.