0
0
IOT Protocolsdevops~10 mins

Topics and topic hierarchy in IOT Protocols - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to publish a message to the correct MQTT topic.

IOT Protocols
client.publish('[1]', 'Hello World')
Drag options to blanks, or click blank then click option'
Ahome-kitchen-temperature
Bhome/kitchen/temperature
Chome.kitchen.temperature
Dhome_kitchen_temperature
Attempts:
3 left
💡 Hint
Common Mistakes
Using underscores or dots instead of slashes in topic names.
2fill in blank
medium

Complete the code to subscribe to all temperature topics under 'home'.

IOT Protocols
client.subscribe('[1]')
Drag options to blanks, or click blank then click option'
Ahome/temperature/#
Bhome/#/temperature
Chome/temperature/+
Dhome/+/temperature
Attempts:
3 left
💡 Hint
Common Mistakes
Using # in the middle of the topic, which is invalid.
3fill in blank
hard

Fix the error in the topic filter to subscribe to all sensors under 'home'.

IOT Protocols
client.subscribe('[1]')
Drag options to blanks, or click blank then click option'
Ahome/#
Bhome/+/#
Chome/+/+
Dhome/+/sensor/#
Attempts:
3 left
💡 Hint
Common Mistakes
Using # in the middle of the topic filter.
4fill in blank
hard

Fill both blanks to create a topic filter that matches any sensor data in any room under 'home'.

IOT Protocols
client.subscribe('home/[1]/[2]')
Drag options to blanks, or click blank then click option'
A+
B#
Csensor
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Using # too early or in the wrong position.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps sensor names to their latest values from a topic list.

IOT Protocols
sensor_data = { [1]: [2] for [3] in topics if 'sensor' in [3] }
Drag options to blanks, or click blank then click option'
Atopic.split('/')[-1]
Bvalue
Ctopic
D{topic: value}
Attempts:
3 left
💡 Hint
Common Mistakes
Using the whole topic string as the key instead of the sensor name.