Raspberry Pi - MQTT for IoT
Given this Python code snippet using paho-mqtt on a Raspberry Pi, what will be printed when a message with payload 'ON' is received on topic 'home/livingroom/light'?
def on_message(client, userdata, msg):
if msg.topic == 'home/livingroom/light':
print(f"Light status: {msg.payload.decode()}")
client = mqtt.Client("pi1")
client.on_message = on_message
client.connect("broker.local")
client.subscribe("home/livingroom/light")
client.loop_start()