Skip to content

Examples Basic Numeric Averaging

mchristegh edited this page Jul 15, 2026 · 1 revision

Three humidity sensors averaged into one trusted value, triggering at mean ≥ 60% and releasing below 55% (hysteresis).

Import: in the editor, Import → Examples → node-red-contrib-sensor-consensus → 01-basic-numeric-averaging. The flow contains inject buttons for the sensors, the consensus node, and one debug node per output so the routing guarantees are visible in the Debug sidebar.

Demonstrates: Type Modes (numeric, mean) and Trigger and Release (Above direction, hysteresis, latching).

Walkthrough

  1. Press hum1 = 55, hum2 = 58, hum3 = 52. Each press emits a sourceadded event on output 4 (a first reading announces itself — see Events), and the node status settles at a green 55 (3/3 fresh). Below the trigger: outputs 1 and 2 stay silent.
  2. Press hum2 = 75. The mean becomes 60.67 — Trigger fires on output 1, with a duplicate copy on output 4. Note the envelope: consensusState: "triggered", msg.aggregate: 60.67, and the full per-source breakdown in msg.sources.
  3. Press hum2 = 75 again. Nothing on output 1 — the latch fires once per transition. The reading itself is also suppressed on output 4 because the aggregate didn't change (Emit aggregate on change only is checked — see Output Messages).
  4. Press hum2 = 45. Mean 50.67, below the release value 55: Release fires on output 2 with releaseReason: "threshold".
  5. Press query at any time for a snapshot on output 3 — state, aggregate, quorum, and every source's value and last-seen time.

Things worth noticing

  • Values between 55 and 60 do nothing to a released latch and nothing to a triggered one — that dead band is the hysteresis, and it's why one noisy sensor near the threshold doesn't toggle your automation.
  • Every message on every output carries the same envelope, so a downstream switch on msg.consensusEvent can slice the Events stream however you like.

Next: add trust to this exact setup in Examples Staleness and Quorum.

Clone this wiki locally