Skip to content

Examples: Cooldown

mchristegh edited this page Jul 10, 2026 · 2 revisions

The full cooldown lifecycle at test scale: trigger on 2 events within 30 seconds, then a 20-second cooldown during which further events bounce off — visibly. Feature reference: Cooldown.

Import it

Import → Examples → node-red-contrib-timer-threshold → cooldown, then Deploy.

What you get

Three inject buttons — Sensor event, Stop, and Query — into a Timer Threshold node (2 in 30s, 20s cooldown — Count Limit 2, Window 30 Seconds, Fixed mode, Cooldown 20 Seconds, Status Reporting Every Second), with a debug on each output.

Walkthrough

1. Trigger into cooldown. Click Sensor event twice. Output 1 fires the Trigger; output 3 shows the duplicate, immediately followed by cooldownstarted (source: "internal"). The label switches to Cooldown: 00:00:19, counting down.

2. Bounce messages off it. Keep clicking Sensor event during the cooldown. Output 1 stays completely silent — that's its guarantee. Every click appears on output 3 as counted with ignored: true, and msg.ignoredCount climbs with each one. The node is telling you, per message: this was a count attempt, and it did not take effect.

3. Query mid-cooldown. Click Query: timerState: "cooldown", with the remaining time in both cooldownRemaining and windowRemaining, and the ignoredCount from step 2.

4. Let it end. Wait out the 20 seconds. Output 3 emits cooldownended — and output 1 emits nothing: the Trigger was already reported once, at step 1, and the cooldown ending merely reopens the gate. Click Sensor event twice and a fresh cycle triggers normally (ignoredCount back at 0).

5. Cut one short. Trigger again (two clicks), then click Stop mid-cooldown. Output 3 shows a genuine stopped, the label returns to Ready, and the very next clicks count normally. stop is the only command that does this — try the experiment of editing the flow to send reset or enable instead and watch them bounce (ignored: true for reset; enable toggles the flag but the cooldown holds). The rationale for that asymmetry is on Cooldown.

Things to try

  • Change Count Limit to 1 and Cooldown to 1 Minute: the node is now a pure rate limiter — first event passes, then nothing for a minute, no matter how fast you click. See the pattern note on Cooldown.
  • Wire a switch node on output 3 matching timerEvent == "counted" and ignored == true into a counter or notification — "the condition kept breaching N times during the cooldown" is often as interesting as the original alert.

Clone this wiki locally