Edge App Academy · 2 / 5
Listen to plant state topics
Bind plant state messages to the receiving handler.
YOUR TASK
Make this happen
Add the plant MQTT broker, QoS 1, and plant/+/state subscription routed to receive. Connect mqttBrokers to the document.
Keep the working capabilities from the previous lesson and connect the new pieces to the same solution.
Check the complete solution, then inspect any unmet requirements.
This step starts with the earlier solution and one new challenge. Each lesson keeps its own draft.
Read the starter files
main.cococo
edge_app_document "main" {
format = "1"
handle = "plant-monitor"
name = "Plant monitor"
handlers = [edge_app_handler.receive]
}
handlers.cococo
edge_app_handler "receive" {
name = "receive"
source = file("scripts/receive.lua")
}
scripts/receive.lua
bridge.log.info(params.topic) return params.payload
broker.cococo
edge_app_mqtt_broker "plant" {
name = "plant"
# TODO: add url — see the task above.
# TODO: add qos — see the task above.
# TODO: add subscriptions — see the task above.
}
subscription.cococo
edge_app_mqtt_subscription "state" {
# TODO: add topic — see the task above.
# TODO: add handler — see the task above.
}
Supplied supporting files
Reference: edge-apps · getting-startededge-apps · definitionsedge-apps · scripts-triggersedge-apps · mqtt-opcuaedge-apps · industrialedge-apps · exec-httpedge-apps · diagnosticsedge-apps · reference