Edge App Academy · 3 / 5
Keep credentials with the installation
Make the listener reusable across sites without embedding a password or certificate.
YOUR TASK
Make this happen
Add required MQTT_URL, MQTT_USERNAME, MQTT_PASSWORD and MQTT_CA installation settings. Bind broker credentials and TLS CA to them; mark password and CA writeOnly.
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]
mqttBrokers = [edge_app_mqtt_broker.plant]
}
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"
url = "mqtt://localhost:1883"
qos = 1
subscriptions = [edge_app_mqtt_subscription.state]
}
subscription.cococo
edge_app_mqtt_subscription "state" {
topic = "plant/+/state"
handler = "receive"
}
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