Files
ComfyUI/custom_nodes/controlaltai-nodes/two_way_switch_node.py
jaidaken f09734b0ee
Some checks failed
Python Linting / Run Ruff (push) Has been cancelled
Python Linting / Run Pylint (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.10, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.11, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-stable (12.1, , linux, 3.12, [self-hosted Linux], stable) (push) Has been cancelled
Full Comfy CI Workflow Runs / test-unix-nightly (12.1, , linux, 3.11, [self-hosted Linux], nightly) (push) Has been cancelled
Execution Tests / test (macos-latest) (push) Has been cancelled
Execution Tests / test (ubuntu-latest) (push) Has been cancelled
Execution Tests / test (windows-latest) (push) Has been cancelled
Test server launches without errors / test (push) Has been cancelled
Unit Tests / test (macos-latest) (push) Has been cancelled
Unit Tests / test (ubuntu-latest) (push) Has been cancelled
Unit Tests / test (windows-2022) (push) Has been cancelled
Add custom nodes, Civitai loras (LFS), and vast.ai setup script
Includes 30 custom nodes committed directly, 7 Civitai-exclusive
loras stored via Git LFS, and a setup script that installs all
dependencies and downloads HuggingFace-hosted models on vast.ai.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 00:56:42 +00:00

57 lines
1.7 KiB
Python

class AnyType(str):
"""A special string subclass that equals any other type for ComfyUI type checking."""
def __ne__(self, __value: object) -> bool:
return False
# Create an instance to use as the any type
any_type = AnyType("*")
class TwoWaySwitch:
"""Two-way switch that selects between two inputs based on selection setting."""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"selection_setting": ("INT", {"default": 1, "min": 1, "max": 2}),
},
"optional": {
"input_1": (any_type,),
"input_2": (any_type,),
}
}
RETURN_TYPES = (any_type,)
RETURN_NAMES = ("output",)
FUNCTION = "switch_inputs"
CATEGORY = "ControlAltAI Nodes/Logic"
@classmethod
def VALIDATE_INPUTS(cls, **kwargs):
"""Allow any input types."""
return True
def switch_inputs(self, selection_setting=1, input_1=None, input_2=None):
"""
Two-way switch that selects between two inputs based on the selection_setting.
Compatible with IntegerSettings node:
- selection_setting = 1 (Disable): selects input_1
- selection_setting = 2 (Enable): selects input_2
"""
if selection_setting == 2:
# Enable state - select second input
selected_output = input_2 if input_2 is not None else input_1
else:
# Disable state (1) or any other value - select first input
selected_output = input_1 if input_1 is not None else input_2
return (selected_output,)
NODE_CLASS_MAPPINGS = {
"TwoWaySwitch": TwoWaySwitch,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"TwoWaySwitch": "Switch (Two Way)",
}