Lazy Case Switch (obvpm)
Name your branches instead of counting them
- 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
A boolean switch is fine for two branches. For four it's a lie: you end up chaining switches, or running an integer through a pile of comparison nodes, and nobody - including future you - can read the result. The problem isn't the routing, it's that branches have no names.
Lazy Case Switch fixes that. You write the branch names, one per line, and pick one. Named branches, lazy execution, and a fallback for when nothing matches.
What it does
cases is a multiline text field - one case name per line. Everything downstream of that list is derived from it:
- One
on_caseinput per line, in order, labelled with the line's name. selectedis a dropdown of those same lines.
Add a line and a socket appears. Delete a line and the socket goes away - unless something is still plugged into it, in which case it stays put and just reads as having no line, rather than silently dropping your link. Blank lines are ignored and don't consume a socket; surrounding spaces are trimmed; names match exactly; up to 16 cases.
fallback is a separate optional input that sits above the case pins and doesn't move when you edit the list - the source declares it first on purpose, so the one socket that always exists never reorders itself under your wires. No match falls through to it. If there's no fallback connected either, value comes out as None and the node logs which name matched nothing, which is a much better Monday morning than a mystery.
Why laziness matters here
Exactly as with the plain Lazy Switch: only the chosen branch is asked for. check_lazy_status resolves selected against the case list and requests that one input - plus the guard that an unconnected selected pin isn't requested at all, because asking the engine for a lazy input with no link is a hard error. So a case switch with six model branches costs you one branch's worth of VRAM, and the other five - their loaders, their LoRAs, their samplers - simply don't execute.
That's the difference between a case switch and a pile of bypassed groups. Bypassed groups still get considered; unselected cases never run.
The pairing that makes it click
Wire a Dropdown in. options → cases, value → selected. Now the choices you type in one place are simultaneously the dropdown you pick from, the sockets on the switch, their labels, and the routing. Edit the list and both nodes follow.
That's also why you'd choose this over the auto version: the names are fixed by an explicit list, so a name means the same thing after you rewire. If selected is being driven by a string from somewhere else - a bundle field, a filename parser, a text node - this is the node you want, because the string is matched against a list you control rather than against whatever happens to be feeding the branch today.
There's one more thing to know, and it's the good kind of surprising: this switch is transparent to the pack's bundle tracing. An Unbundle can trace names back through a Lazy Case Switch when every connected branch packs the same field names - which is exactly the case where the answer is the same whichever branch wins. Branches that pack different fields legitimately have no single answer, so no names are offered and you give the consumer an explicit list.
The traps
Names are matched exactly. Karras is not karras. The trim helps, casing doesn't.
A case list is a contract with your saved workflows. Rename a line and any saved selected value that pointed at it stops matching and falls to fallback. If you change the meaning of the names often, use the auto variant and rename the source nodes instead.
Laziness stops the branch, not the sink. If a Save or Preview node still has a live path into it, it will run regardless. Killing a branch completely means lazy on the value path and a muting gate downstream - the plumbing notes cover the same distinction for the wider ecosystem's routing nodes.
Install
Manager, search comfyui-obvpm. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/chanon/comfyui-obvpm
Restart ComfyUI afterwards. No packages to install, no models to download. The whole pack is listed in the node menu with an (obvpm) suffix, so obvpm in the search box is all you need.
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 | first second | The 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)
| Name | Type | Description |
|---|---|---|
| value | * | The matching branch's value. None when that branch is unconnected and there is no fallback. |