ComfyUI Node

HT Switch

A switch that fires once on the flip, not every frame — HT Switch

By ArtHommage·Created 2 years ago·Updated about a year ago· 4
HT Switch
    • trigger
    enabledfalse

    Most toggles in ComfyUI are level-triggered: while the condition holds, the effect holds. Sometimes you want the opposite - a switch that fires a signal once when it's flipped, then goes quiet until you flip it back. That's an edge-triggered switch, and it's what HT Switch (from the HommageTools pack) does. One checkbox in, one boolean out, and the output goes true exactly once per activation.

    How it works

    One input, one output:

    • enabled - a boolean, default false. This is your flip switch.
    • trigger - the output boolean that fires.

    Internally the node keeps a small bit of state (_triggered). When enabled goes from false to true (and it hasn't fired since the last reset), it sets _triggered and emits true on trigger. Once fired, subsequent executions while enabled stays true emit false - no repeat firing. When you flip enabled back off, the state resets, so the next on-flip fires again. It also re-evaluates on every run (IS_CHANGED), which is what makes the edge detection behave correctly across executions instead of getting eaten by ComfyUI's caching.

    The mental model: a momentary button, not a light switch.

    What you'd use it for

    The point of a one-shot trigger is avoiding repeated actions in a loop. If you've got a workflow section that should run once when activated - a one-time initialization, a single save, a one-shot event - wiring it off the trigger output means it doesn't re-fire on every queue while the checkbox stays on. It's also handy for coordinated event sequences, where you want a clean rising edge to hand to the next stage rather than a sustained true that keeps re-triggering downstream logic.

    Installing it

    HommageTools install, once:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ArtHommage/HommageTools.git
    cd HommageTools
    pip install -r requirements.txt
    

    Restart ComfyUI, or ComfyUI Manager → "HommageTools". No models, no extra dependencies. The pack's README carries its usual perpetual-alpha disclaimer - for a stateful one-shot node, the risk is mostly "state behavior changes in an update," which you'll notice immediately.

    The gotcha to understand

    This is edge-triggered, not level-triggered - and that surprises people exactly once. If you flip enabled on and expect trigger to stay true the whole time it's on, you'll be confused when it goes quiet after one fire. It's meant to be that way; that's the "prevent continuous triggering" behavior from the README. Second, the state is held in the node instance, so things like workflow reloads or node duplication can reset it - if your one-shot mysteriously fires twice, check whether the node instance was recreated. If you want a sustained signal instead of a pulse, you'd be better served by a plain boolean source; this node is specifically for the "do it once" case.

    CategoryHommageTools

    Inputs (1)

    NameTypeDefaultDescription
    enabledBOOLEANfalse

    Outputs (1)

    NameTypeDescription
    triggerBOOLEAN