Nodes/WAS Node Suite v3/Any Switch (First Connected)
ComfyUI Node Runs on cloud

Any Switch (First Connected)

Muting a branch just falls through

By WASasquatch·Created 3 years ago·Updated 4 days ago· 1,844
Any Switch (First Connected)
  • input_a
  • input_b
  • input_c
  • input_d
  • input_e
  • input_f
  • input_g
  • input_h
  • input_i
  • input_j
  • input_k
  • input_l
  • input_m
  • input_n
  • input_o
  • input_p
  • input_q
  • input_r
  • input_s
  • input_t
  • input_u
  • input_v
  • input_w
  • input_x
  • input_y
  • input_z
  • output
  • resolved_index
  • count

You know those fallback switches in other packs - "pass the first input that isn't empty"? Any Switch (First Connected) is WAS Node Suite's take on that idea, and the difference matters: this one passes the first input that's connected, not the first that's non-empty. That sounds like hair-splitting until you've built a graph with several optional upstream branches and you want to audition them by muting. Mute branch one, and branch two quietly answers the call. No rewiring, no selector to remember to flip.

It sits under WAS Suite/Logic/Switch and it takes up to 26 inputs - input_a through input_z - of any type. Slots are tried in order, input_a first; the earliest slot still wired is the one that leaves on the output socket. A muted node feeding a slot is treated as disconnected, so muting a branch falls through to the next one. Each slot only ever gets evaluated if the ones before it are out of the running, which means the work behind the losing branches is skipped entirely, not done and thrown away. Wire a heavy sampler into input_b behind a lighter input_a and the heavy one won't run unless you mute the light one - that's lazy evaluation doing real work for you.

The two outputs that earn their keep

Beyond output, the node reports on its own decision:

  • resolved_index - which slot answered, counting from 0 (input_a = 0, input_c = 2). Handy for logging or for feeding a parallel index somewhere.
  • count - how many slots are still connected. Wire this into a note or a text list and a glance tells you whether your "fallback chain" has quietly collapsed to nothing.

The first connection also fixes the type for the whole node. Connect an IMAGE into input_a and the remaining slots and the output all narrow to IMAGE; connect a LATENT and the whole node becomes a latent router. That's the "any" in the name - the node isn't typed until you type it by wiring.

The trap to know about

Because it keys on connection, not content, a connected branch that genuinely produces nothing still "answers." If you want a switch that skips branches whose output came back empty - the classic first-non-null behaviour you get from rgthree's Any Switch - this isn't that node. This one is a first-connected switch, which is better for the mute-to-audition workflow and worse for "skip the branch that failed." If you find yourself wiring WAS Any Is Empty in front of each input to do first-non-empty by hand, you've picked the wrong tool for the job and should look at a first-non-null switch instead.

Where it shines

Use it to keep several alternative pipelines in one workflow and switch between them by muting rather than editing wires. Think "three different upscalers, pick which one is active today," or "prompt A by default, prompt B when I unmute it." Because the answering branch is the only one evaluated, you can park expensive paths downstream of the losing slots without paying for them.

Installing

Part of WAS Node Suite v3 (WASasquatch/was-node-suite-comfyui), WASasquatch's MIT suite - one of the packs that's been in the essential-toolkit conversation since 2023. Logic nodes like this one are pure plumbing: no extra packages, no models, nothing to configure. Needs ComfyUI 0.14.0+ (v3 is written against the newer node backend).

Via ComfyUI Manager, search WAS Node Suite v3, or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui

Restart and the switch appears under WAS Suite/Logic/Switch. Can't find it? Your ComfyUI predates 0.14.0 and needs an update - that's the whole troubleshooting story for this node.

CategoryWAS Suite/Logic/Switch

Inputs (26)

NameTypeDefaultDescription
input_aoptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_boptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_coptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_doptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_eoptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_foptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_goptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_hoptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_ioptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_joptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_koptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_loptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_moptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_noptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_ooptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_poptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_qoptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_roptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_soptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_toptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_uoptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_voptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_woptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_xoptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_yoptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.
input_zoptCOMFY_MATCHTYPE_V3One candidate branch. Any type, and the first connection fixes the type for the rest. Slots are tried in order, input_a first: with input_a muted or unwired, input_b answers. Only the branch that answers is evaluated.

Outputs (3)

NameTypeDescription
outputCOMFY_MATCHTYPE_V3The branch that answered, typed to whatever was connected.
resolved_indexINTWhich slot answered, counting the slots on the node from 0: input_a = 0, input_c = 2. With input_a and input_b muted, this reads 2.
countINTHow many slots are still connected. Muting the node feeding a slot drops it by one: 3 wired with 1 muted reads 2.