Complete the code to import the MQTT client library.
import [1]
The correct import for the MQTT client in Python is paho.mqtt.client.
Complete the code to create a new MQTT client instance named 'client'.
client = [1]()The MQTT client is created by calling paho.mqtt.client.Client().
Fix the error in the code to subscribe to the topic 'control/led'.
client.subscribe([1])The topic name must be a string, so it needs quotes like 'control/led'.
Fill both blanks to define a callback function that prints the received message payload.
def on_message(client, userdata, [1]): print('Received:', [2].payload.decode())
The message parameter is commonly named msg. Use the same name to access the payload.
Fill all three blanks to connect to the broker, set the message callback, and start the loop.
client.connect([1]) client.[2] = on_message client.[3]()
loop_forever() instead of loop_start() when asynchronous loop is needed.Connect to the broker at 'localhost', assign the on_message callback, and start the loop with loop_start().