TofuPilotTofuPilot

Switch

Prompt operator with toggle switch for true/false values.

You can create a switch toggle with switch:

ui:
  components:
    - key: unit_powered
      type: switch
      label: "Unit Powered On"
      description: "Confirm the unit is powered on before testing"
      required: true

Properties

Display

You can configure how the toggle appears to the operator.

PropertyTypeRequiredDescription
keystringYesUnique identifier for accessing the value
typestringYesMust be "switch"
labelstringNoDisplay label for the toggle
descriptionstringNoHelper text displayed below the toggle

Value

You can set default values and bind to measurements or unit properties.

PropertyTypeRequiredDescription
default_valuebooleanNoDefault value to pre-fill the switch. If not set, switch starts in "Unset" state.
bindstringNoBind to unit property or measurement. See Collect Input for details.

Validation

You can validate input before the value is submitted.

PropertyTypeRequiredDescription
requiredbooleanNoIf true, operator must provide input (shows "Required" badge)

TofuPilot validates operator input before submission, preventing continuation until all constraints are met.

Examples

Unset State

Switches without a default value start in an "Unset" state:

phases:
  - name: Optional Setting
    ui:
      components:
        - key: optional_feature
          type: switch
          label: "Optional Feature"
          # No default_value set - starts as "Unset" #
          description: "Enable if needed, or leave unset"

Feature Toggle

We'll use a switch to enable or disable a feature:

phases:
  - name: Configure Test
    ui:
      components:
        - key: enable_calibration
          type: switch
          label: "Enable Calibration Mode"
          description: "Run test in calibration mode"
          required: false

Conditional Flow

We'll use a switch to determine the next step:

phases:
  - name: Review Results
    ui:
      components:
        - key: retest_required
          type: switch
          label: "Retest Required"
          description: "Check if the unit needs to be retested"
          required: true

How is this guide?