Nodes/comfyui-obvpm/Lazy Case Switch (obvpm)
ComfyUI Node

Lazy Case Switch (obvpm)

Pick a branch by name, run only that branch

By chanon·Created about a month ago·Updated a day ago· 42
Lazy Case Switch (obvpm)
  • fallback
  • on_case_1
  • on_case_2
  • on_case_3
  • on_case_4
  • on_case_5
  • on_case_6
  • on_case_7
  • on_case_8
  • on_case_9
  • on_case_10
  • on_case_11
  • on_case_12
  • on_case_13
  • on_case_14
  • on_case_15
  • on_case_16
  • value
selected
casesfirst second

A boolean switch answers "A or B". The moment you have three model paths, four finishing treatments, or one branch per character, booleans turn into a tree of switches that nobody can read six months later. What you want is a case statement: name the branches, pick one by name.

Lazy Case Switch (obvpm) is that, and the "lazy" part is the reason to care - the branches you didn't pick don't execute at all. Not "run and throw away the result". Never run. On a graph where the branches are a sampler chain, an upscale pass and a video encode, that's the difference between a switch and a very expensive multiplexer.

The list is the node

You write the case names in the cases widget, one per line. Everything else derives from that:

  • one on_case input per line, in order, labelled with that line;
  • selected becomes a dropdown of those lines.

Add a line and a socket appears. Remove one and the socket goes away - unless something is still wired to it, in which case it stays, labelled as having no matching line, rather than yanking the connection out from under you. That's a thoughtful bit of behaviour: editing a list shouldn't silently unplug your graph.

The rules: names are matched exactly, with surrounding spaces ignored. Blank lines are ignored and don't consume a socket. Up to 16 cases. No match falls through to fallback - an input that sits above the case pins and stays put while you edit the list. With no fallback connected, the output is None and the log tells you which name matched nothing.

Inputs and outputs

  • cases - required multiline STRING, default first / second. Your branch names, one per line.
  • selected - required STRING, shown as a dropdown of those lines. Convert it to an input to drive it from outside.
  • fallback - optional, above the case pins; output when nothing matches.
  • on_case_1on_case_16 - optional, one per line, in order. Only the selected one executes.
  • value - the matching branch's value.

Driving it from one list

The pairing that makes this click: a Dropdown node's options output wired into cases, and its value output wired into selected. Now the choices, the switch's sockets, the socket labels and the routing all come from a single editable list. Wire in a list and the sockets appear and relabel as you edit the Dropdown; unwire it and the node goes back to its own text. It's the least error-prone way to build a multi-branch graph, and it's the reason the pack ships a Dropdown at all.

What laziness does and doesn't fix

The unselected branches aren't executed, so everything feeding them is skipped - samplers that don't run, models that don't load, VRAM you don't spend. But laziness can't stop a save or preview node on the unselected side: every OUTPUT_NODE is an execution root, and nothing reaches it through a wire, so there's no evaluation to prune. If a branch has its own Save Image, it will fire regardless. Gate it with the pack's Mute node if that matters.

Also: value is a single wildcard socket. One value per branch. If a branch needs to carry a model, a clip and a latent, that's three switches - or one switch carrying a Bundle, which is the pattern the two nodes were designed around.

Install

ComfyUI Manager → search comfyui-obvpm, or:

cd ComfyUI/custom_nodes
git clone https://github.com/chanon/comfyui-obvpm

Restart. Category obvpm/switches; a node-menu search for obvpm shows the whole pack. No Python dependencies are installed - the pack's pyproject.toml declares none on purpose. Every pre-0.2.0 bare id was suffixed (obvpm) to end a class-id clash with another pack's Bundle; existing workflows migrate automatically on open.

When to use the auto version instead

The pack also ships Lazy Case Switch (auto), which names each branch after the node feeding it - no list to maintain, names follow your node titles. Reach for the plain version when the names must be stable: a list you also feed to a UI control, a string arriving from elsewhere, or a workflow you're sharing, where someone renaming a node shouldn't change what a saved selected value points at.

Categoryobvpm/switches

Inputs (19)

NameTypeDefaultDescription
selectedSTRINGWhich case to run. Shown as a dropdown of the case lines; convert it to an input to drive it from a Choice node or any string.
casesSTRINGfirst secondThe case names, one per line. Each line gets its own on_case input, in order. Blank lines are ignored and surrounding spaces trimmed; names are matched exactly.
fallbackopt*Output when no case line matches. Only executes while selected; may be left unconnected.
on_case_1opt*Output when selected matches case line 1. Only executes while selected; may be left unconnected.
on_case_2opt*Output when selected matches case line 2. Only executes while selected; may be left unconnected.
on_case_3opt*Output when selected matches case line 3. Only executes while selected; may be left unconnected.
on_case_4opt*Output when selected matches case line 4. Only executes while selected; may be left unconnected.
on_case_5opt*Output when selected matches case line 5. Only executes while selected; may be left unconnected.
on_case_6opt*Output when selected matches case line 6. Only executes while selected; may be left unconnected.
on_case_7opt*Output when selected matches case line 7. Only executes while selected; may be left unconnected.
on_case_8opt*Output when selected matches case line 8. Only executes while selected; may be left unconnected.
on_case_9opt*Output when selected matches case line 9. Only executes while selected; may be left unconnected.
on_case_10opt*Output when selected matches case line 10. Only executes while selected; may be left unconnected.
on_case_11opt*Output when selected matches case line 11. Only executes while selected; may be left unconnected.
on_case_12opt*Output when selected matches case line 12. Only executes while selected; may be left unconnected.
on_case_13opt*Output when selected matches case line 13. Only executes while selected; may be left unconnected.
on_case_14opt*Output when selected matches case line 14. Only executes while selected; may be left unconnected.
on_case_15opt*Output when selected matches case line 15. Only executes while selected; may be left unconnected.
on_case_16opt*Output when selected matches case line 16. Only executes while selected; may be left unconnected.

Outputs (1)

NameTypeDescription
value*The matching branch's value. None when that branch is unconnected and there is no fallback.