Skip to content

Examples Boolean Voting

mchristegh edited this page Jul 15, 2026 · 1 revision

Three door contacts reporting the strings open / closed, mapped through custom True/False value lists, with a Majority open trigger rule. Shows the vote fraction, the exact-split latch edge, minority reports, and coercion rejection.

Import: Import → Examples → node-red-contrib-sensor-consensus → 03-boolean-voting.

Demonstrates: Type Modes (boolean coercion, custom lists) and Trigger and Release (vote rules), plus minority reports from Sources Freshness and Quorum.

Walkthrough

  1. Press door1 open. One of one open is a majority — Trigger fires immediately. The denominator is the fresh source count, so don't be surprised that a single sensor can satisfy Majority.
  2. Press door2 closed. The fraction is exactly 0.5, and Majority is ≥ 0.5 — the latch holds. No minority report either: at an exact split there is no consensus for anyone to disagree with.
  3. Press door3 closed. One of three: Release fires, and output 4 carries a minorityreport naming ["door1"] — the sensor now disagreeing with the closed consensus.
  4. Press door3 closed again. No new report — reports fire when the disagreeing set changes, so a stuck sensor produces one report, not a stream.
  5. Press door1 closed. The disagreement resolves: one final minorityreport with an empty set.
  6. Press door1 sends 'true'. Rejected — a reading with ignored: true and rejectedValue: "true" on output 4. Custom lists replace the defaults, so only open/closed coerce here.

Things worth noticing

  • msg.aggregate in boolean mode is the fraction of fresh sources true (0.0–1.0), and the node status renders it as counts, e.g. 2T/1F of 3.
  • For flap suppression, set the Release Rule looser than the trigger (trigger on All, release below Majority) — the boolean form of hysteresis. Try it: with that configuration, one flaky contact can no longer toggle your automation.

Clone this wiki locally