Sensor Switch Latent
The Latent Switch That Survives WAN's Weird Format
- latent_true
- latent_false
- latent
Latents are the trickiest thing to switch in ComfyUI, because they're not just a tensor - they're a dictionary carrying metadata, and for some models that metadata matters. This is the sensor switch for LATENT objects, with a bonus the other members of the family don't have: it understands WAN 2.1 and 2.2 latents.
Where it shines is img2img and video workflows that offer a choice of starting latents - maybe a fresh Empty Latent for text-to-image, or a VAE Encode of a source image for image-to-image, or an inpaint latent carrying a noise mask. Wire both into latent_true / latent_false and the sensor routes whichever one is live, or let the boolean decide when both are connected.
What makes the latent version different
Two things in the source:
- Inpaint latents pass through. A latent isn't just
samples- it can carrynoise_mask,batch_index, and other keys. The changelog shows this was a real bug: earlier versions dropped those keys when switching, which silently broke inpainted latents. The current code copies the full dictionary and only touches the samples, so your mask survives the trip. - WAN support. WAN latents use a different internal format, and a naive switch will feed
process_out-formatted samples into a sampler expecting raw ones. The node detectslatent_formaton the dict and converts WAN 2.1/2.2 samples back to raw before outputting - added in the Oct 2025 update. So if you're building a Wan workflow that chooses between multiple latent sources, this is the switch that doesn't corrupt the data.
Inputs and outputs
switch- boolean, default true.latent_true/latent_false- optional LATENT inputs.latent- single LATENT output.
Same family logic: one connected input wins, both connected → switch decides, neither → None instead of an error.
The usual caveat
Because ComfyUI can pass data through a bypassed node, don't rely on the sensor to auto-detect a bypassed branch when both inputs are wired - set the toggle manually for that. Auto-detection is for genuinely disconnected ports. And if a latent-switch in some other pack has given you mysterious blank frames in an inpaint or Wan workflow, this is the version that was built specifically to fix those failure modes.
Installing it
Manager search "ComfyUI-Fossiel-QoL-Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Fossiel/ComfyUI-Fossiel-QoL-Nodes
pip install -r ComfyUI-Fossiel-QoL-Nodes/requirements.txt
Restart, find Sensor Switch Latent under Fossiel/QoL. No downloads - the WAN handling is done in code via ComfyUI's own latent format classes.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| switch | BOOLEAN | true | — |
| latent_trueopt | LATENT | — | |
| latent_falseopt | LATENT | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| latent | LATENT | — |