Switch Component

The switch component provides an API for reading the state of a physical switch on a machine that has multiple discrete positions. A simple switch has two positions, and a knob could have any number of positions.

Configuration

To use your switch, you need to add it to your machine’s configuration. Go to your machine’s CONFIGURE page, and add a model that supports your switch.

The following list shows the available switch models. For configuration information, click on the model name:

Model
Description

API

The switch API supports the following methods:

Method NameDescriptionviam-micro-server Support
SetPositionSet the position of the switch.
GetPositionReturn the current position of the switch.
GetNumberOfPositionsReturn the number of valid positions for this switch.
DoCommandExecute model-specific commands that are not otherwise defined by the component API.
CloseSafely shut down the resource and prevent further use.

Troubleshooting

If your switch is not working as expected, follow these steps:

  1. Check your machine logs on the LOGS tab to check for errors.
  2. Review your switch model’s documentation to ensure you have configured all required attributes.
  3. Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the switch there.

If none of these steps work, reach out to us on the Community Discord and we will be happy to help.

Next steps

For general configuration, development, and usage info, see: