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:
Add support for other models
If none of the existing models fit your use case, you can create a modular resource to add support for it.
Support Notice
There is currently no support for this component compatible with the Micro-RDK.
API
The switch API supports the following methods:
Method Name | Description | viam-micro-server Support |
---|---|---|
SetPosition | Set the position of the switch. | |
GetPosition | Return the current position of the switch. | |
GetNumberOfPositions | Return the number of valid positions for this switch. | |
DoCommand | Execute model-specific commands that are not otherwise defined by the component API. | |
Close | Safely shut down the resource and prevent further use. |
Troubleshooting
If your switch is not working as expected, follow these steps:
- Check your machine logs on the LOGS tab to check for errors.
- Review your switch model’s documentation to ensure you have configured all required attributes.
- 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:
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!