Skip to content

Examples Staleness and Quorum

mchristegh edited this page Jul 15, 2026 · 1 revision

Two temperature sensors with a 15-second staleness window, a quorum of 2 fresh sources, and both sensors declared as Expected Sources. This is the failure mode plain averaging nodes hide: a dead sensor's last value skewing the result forever.

Import: Import → Examples → node-red-contrib-sensor-consensus → 02-staleness-and-quorum.

Demonstrates: Sources Freshness and Quorum (staleness, quorum, expected sources, the Hold policy) and the envelope-ordering nuance in Output Messages.

Walkthrough

  1. Press query before anything else. State is waiting, and msg.sources already lists temp1 and temp2 with seen: false — expected sources are visible from deploy, so a sensor that never comes up is a fact you can see, not an absence you'd have to remember.
  2. Press temp1 = 70 and temp2 = 70. The second reading satisfies quorum (quorumregained on output 4 — note it still reports waiting; envelopes reflect the instant of dispatch) and Trigger fires (mean 70 ≥ 60).
  3. Now wait 15 seconds without pressing anything. Output 4 shows sourcestale for each sensor as its own clock expires it — the first one still shows quorum: true, with the quorumlost that follows as the correction.
  4. Press query. consensusState is still triggered with quorum: false: the Hold policy keeps the last consensus when trust is lost, and the node status shows the held latch: Triggered | No quorum (0/2) | --.
  5. Press both sensors again. sourcerecovered for each, quorumregained, and — importantly — no duplicate Trigger: the latch survived the outage.

Try the other policy

Open the node, switch On Quorum Lost While Latched to Release, redeploy, and repeat steps 2–3: this time quorum loss immediately fires a genuine Release on output 2 with releaseReason: "quorumlost". Hold suits a dehumidifier; Release suits an alarm.

Things worth noticing

  • The 15-second window is demo-short. Deployed for real, size it to a few missed reporting intervals of your slowest sensor — and expect sourcestale chatter on output 4 if you leave this demo deployed and idle.
  • Below quorum the aggregate is still computed and reported (msg.quorum: false) — only the decision is suspended.

Clone this wiki locally