Lazy Case Switch (auto) (obvpm)
Rename a node, rename a branch
- 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
Case switches usually make you do bookkeeping: write the branch names in one place, wire the branches in another, and keep the two in step while you edit. This version skips the bookkeeping entirely - each branch is named after the node feeding it, so the wiring is the list.
Fork your graph into two model paths, title one Upscale and the other Refine, and those are your cases. Rename a node and its branch renames with it. That's the whole setup, and it's the single nicest thing about this node.
How it works
The node starts with a single empty input and grows another as each one fills, so there's always exactly one spare socket. Unplug one and its gap closes. selected is a dropdown of the branches currently connected, and the branch it names is the one that executes - the others are never run at all, upstream work included. That's the lazy half, and it's why this beats an Anything-Everywhere style routing setup: unrouted branches cost literally nothing.
The name comes from the source node's title, preserving its own spacing and capitals. Two branches fed by identically titled nodes get numbered (Upscale, Upscale_2), so a duplicate title doesn't quietly collapse two cases into one. On the node itself, cases is a required multiline field, but you don't edit it - the tooltip says it plainly: filled in from the connected branches. Treat it as read-only output of your own wiring.
fallback is the safety net: an input that sits above the case pins and stays put no matter how the branches change. It runs when selected matches nothing. Leave it unconnected and the output is just None - no error, which is either convenient or a silent nothing depending on your day.
Inputs and outputs
selected- required; the case to run, shown as a dropdown of the connected branch names. Convert it to an input to drive it from elsewhere: a string from a Dropdown node, a saved preset, whatever.cases- required multiline string, auto-filled from the branches. Not for hand-editing.fallback- optional; output when nothing matches.on_case_1…on_case_16- optional; one per connected branch, up to 16. Only the selected one executes.value- the matching branch's value;Nonewhen that branch is unconnected and there's no fallback.
Auto, or the manual version?
Use this when the names should track the graph. Use the plain Lazy Case Switch when the names should be fixed: driven from a Dropdown's options, matched against a string that arrives from somewhere else, or part of an interface you've published and don't want renamed when someone tidies up their node titles.
The failure mode is exactly that: retitling a node changes the branch name, which changes what a saved selected value means. In your own graph that's a feature. In a workflow you're handing to strangers, it's a support ticket waiting to happen.
Also worth knowing: the plain version keeps its branches when their wire is removed but the line remains, while this one drops the socket as soon as the wire goes. If your workflow survives being partially disconnected, hand-written cases are the sturdier contract.
Install
ComfyUI Manager → search comfyui-obvpm (the pack title), or:
cd ComfyUI/custom_nodes
git clone https://github.com/chanon/comfyui-obvpm
Restart ComfyUI. It arrives under obvpm/switches; a node-menu search for obvpm lists the whole pack. No extra Python dependencies are needed - the pack ships none deliberately. Class ids all carry the (obvpm) suffix as of 0.2.0 (added after a Bundle id collision with another pack), and pre-0.2.0 workflows are migrated when opened.
Practical notes
- Tidy titles are load-bearing now. "KSampler (1)" as a branch name is technically fine and useless as a dropdown entry. Node titles are free - use them.
- Bundles pair beautifully here. One branch carrying several values via the pack's Bundle node means one switch instead of four, with laziness intact end to end.
- Check the run, not the canvas. A branch that didn't execute looks identical to one that ran and produced something you didn't like. The console is where you find out which branch won.
Inputs (19)
| Name | Type | Default | Description |
|---|---|---|---|
| selected | STRING | Which 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. | |
| cases | STRING | Filled in from the connected branches. | |
| 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)
| Name | Type | Description |
|---|---|---|
| value | * | The matching branch's value. None when that branch is unconnected and there is no fallback. |