Random Any Switch:
AUNRandomAnySwitch chooses one available value at random from a group of candidates, making it useful when you want variation in a workflow without manually changing which branch supplies a value. The choice is controlled by a seed, so the same available candidates and seed produce the same selection. The node can pass through different kinds of values without converting them, which makes it useful for choosing among alternatives such as prompts, images, or settings.
Random Any Switch Input Parameters:
seed
The required integer that controls the selection. Its default is 0, its minimum is 0, and its maximum is 18446744073709551615. Change the seed to get a different possible choice; keeping the same seed and the same available candidates produces the same choice, even when the node runs again. A different seed can still happen to select the same candidate.
input_1
An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 1 when reported by selected_index. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.
input_2
An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 2 when reported by selected_index, regardless of whether input_1 is available. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.
input_3
An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 3 when reported by selected_index; unused earlier positions do not change that number. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.
input_4
An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 4 when reported by selected_index. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.
input_5
An optional candidate that accepts any type of value. If it has a value other than None, it can be selected and retains position 5 when reported by selected_index. Its default is None when no value is supplied. No numeric range or fixed set of options is specified.
Random Any Switch Output Parameters:
output
The value from the selected candidate, passed through without conversion by this node. It can therefore be any type accepted by the candidate inputs. If none of the five candidates has a value other than None, output is None; check this before relying on the result in a later node.
selected_index
An integer identifying which candidate supplied output. Values 1 through 5 correspond directly to input_1 through input_5, not to a renumbered list of available candidates. The value is 0 when no candidate is available, so it can also help you distinguish an empty selection from a valid one.
Random Any Switch Usage Tips:
- Supply values only to the candidates you want considered. Each candidate whose value is not
Noneis included in the selection, while a candidate with aNonevalue is skipped. - Keep the seed unchanged when you need to reproduce a selection with the same available candidates. Change the seed when you want another possible result; changing it does not guarantee a different candidate.
- Use
selected_indexwhen you need to know which original input position was chosen. For example, if onlyinput_2andinput_5are available, the reported index will be2or5. - Check that at least one candidate supplies a value before sending
outputto a downstream node that requires one. If no candidate is available, the node returnsNoneand index0.
Random Any Switch Common Errors and Solutions:
No candidate selected: output is None and selected_index is 0
- Explanation: This is the node’s defined result when all five candidate values are
None; it is not an error message emitted by the node. - Solution: Provide a non-
Nonevalue to at least one ofinput_1throughinput_5, then check the result again.
Re-queuing produces the same selection
- Explanation: The node is set to run again when queued, but it creates its random selection from the supplied seed each time. With the same seed and the same available candidates, the choice repeats.
- Solution: Change the seed to request another possible selection. Remember that two different seeds can still choose the same candidate.
A connected candidate is never selected
- Explanation: The code excludes any candidate whose received value is
None, even if a connection appears to be present. - Solution: Check the upstream value and make sure it is not
Nonewhen this node runs.
selected_index does not match the candidate’s position in the available list
- Explanation: The index refers to the original socket number. For example, when only
input_2andinput_5have values, the possible indices are2and5, not1and2. - Solution: Match the reported number directly to the input name, such as
5forinput_5.
A downstream node cannot use output
- Explanation: This node passes through the selected value without converting its type. A later node may require a different type, or it may receive
Noneif no candidate was available. - Solution: Check which candidates are available and whether their values suit the downstream node. Also check whether
selected_indexis0before usingoutput.
Seed value is outside the allowed range
- Explanation: The interface specifies a minimum seed of
0and a maximum of18446744073709551615. The node source does not define a custom error message for an out-of-range entry. - Solution: Enter an integer within the specified range, or use the default value of
0.
