Edge App Academy · 4 / 5
Add a scheduled health entry point
Keep message handling separate from a five-minute scheduled check.
YOUR TASK
Make this happen
Add a separate health handler returning { alive = true } and a CRON trigger every five minutes (*/5 * * * *). Keep MQTT reception.
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]
configSchema = {
type = "object"
properties = {
MQTT_URL = {
type = "string"
}
MQTT_USERNAME = {
type = "string"
}
MQTT_PASSWORD = {
type = "string"
writeOnly = true
}
MQTT_CA = {
type = "string"
writeOnly = true
}
}
required = ["MQTT_URL", "MQTT_USERNAME", "MQTT_PASSWORD", "MQTT_CA"]
additionalProperties = false
}
}
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 = "$${config:MQTT_URL}"
qos = 1
subscriptions = [edge_app_mqtt_subscription.state]
username = "$${config:MQTT_USERNAME}"
password = {
config = "MQTT_PASSWORD"
}
tls = {
caCertPem = {
config = "MQTT_CA"
}
}
}
subscription.cococo
edge_app_mqtt_subscription "state" {
topic = "plant/+/state"
handler = "receive"
}
health.cococo
edge_app_handler "health" {
name = "health"
# TODO: add source — 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