ModPackQTModPackQT
Node-RED ExamplesResourcesSign up
HomeResourcesNode-RED ExamplesThreshold Alert — Notify When a Register Exceeds a Limit
IntegrationNode-RED Modbus Example

Threshold Alert — Notify When a Register Exceeds a Limit

Trigger an alert when a Modbus register value crosses a threshold — an email, a Telegram message, or a webhook. This example monitors a temperature register and sends an alert when it exceeds 80°C, with a cooldown to avoid alert storms.

What you need

  • Node-RED v3+
  • node-red-contrib-modbus installed
  • An email or HTTP endpoint to receive the alert

Flow Overview


Poll every 30s → Read reg 0 → Scale (/10) → threshold > 80?
                                                     │
                                              5 min cooldown OK?
                                                     │
                                              Send webhook POST
                                              "ALERT: 82.4°C"

Node-RED Flow JSON

Node-RED Flow JSON
[
  {"id":"inj13","type":"inject","name":"Poll 30s","repeat":"30","once":true,"wires":[["req13"]],"x":120,"y":1300},
  {"id":"req13","type":"modbus-flex-getter","name":"Read temp","dataType":"HoldingRegister","adr":0,"quantity":1,"server":"srv1","wires":[["fn13"],[]],"x":310,"y":1300},
  {"id":"fn13","type":"function","name":"Check threshold","func":"const temp = msg.payload.data[0] / 10;
context.set('lastTemp', temp);
if (temp > 80) {
  const lastAlert = context.get('lastAlert') || 0;
  if (Date.now() - lastAlert > 300000) {  // 5 min cooldown
    context.set('lastAlert', Date.now());
    msg.payload = 'ALERT: Temperature ' + temp + '°C exceeds 80°C limit';
    msg.topic = 'temperature_alert';
    return msg;
  }
}
return null;","wires":[["http13"]],"x":510,"y":1300},
  {"id":"http13","type":"http request","name":"Send webhook","method":"POST","url":"https://your-webhook-url.example.com/alert","wires":[["dbg13"]],"x":720,"y":1300},
  {"id":"dbg13","type":"debug","name":"Alert sent","active":true,"wires":[],"x":900,"y":1300},
  {"id":"srv1","type":"modbus-client","name":"My Slave","clienttype":"tcp","tcpHost":"192.168.1.100","tcpPort":502,"unit_id":1}
]

To import: open Node-RED → Hamburger menu → Import → paste this JSON → Deploy.

Expected Output

// Only triggered when temp > 80°C and cooldown has passed:
POST https://your-webhook-url.example.com/alert
Body: "ALERT: Temperature 82.4°C exceeds 80°C limit"

Common Gotchas

  • Use context.get/set (not flow or global context) for per-node state so multiple alert nodes don't share cooldown.
  • Returning null from a function node drops the message — essential for the no-alert path.
  • Set a cooldown (5 minutes above) to avoid alert storms when temperature oscillates around the threshold.
  • Consider a hysteresis band: alert when > 80, clear when < 75 — add a second comparison for the 'all clear'.
  • For Telegram: use node-red-contrib-telegrambot instead of http request for richer message formatting.

Same in ModPackQT — in 30 seconds

ModPackQT Signal Bots do exactly this — monitor register values, apply conditions, and trigger webhooks, emails, or MQTT messages. Configure the threshold in the bot editor, no coding required.

Was this example helpful?

More Integration examples

All Node-RED Modbus Examples (30)

ModPackQT · Node-RED Modbus Examples · Updated 2026