Configure a Fake Switch
The fake switch model is a model for testing switch functionality without physical hardware.
It simulates a multi-position switch which you can control programmatically.
Navigate to the CONFIGURE tab of your machine’s page.
Click the + icon next to your machine part in the left-hand menu and select Component or service.
Select the switch type, then select the fake model.
Enter a name or use the suggested name for your arm and click Create.
Fill in the attributes as applicable to your switch, according to the table below.
{
"components": [
{
"name": "<your-switch-name>",
"model": "fake",
"type": "switch",
"namespace": "rdk",
"attributes": {
"position_count": <number>,
"labels": ["<label1>", "<label2>", "<label3>"]
}
}
]
}
{
"components": [
{
"name": "my_switch",
"model": "fake",
"type": "switch",
"namespace": "rdk",
"attributes": {
"position_count": 4,
"labels": ["Off", "Low", "Medium", "High"]
}
}
]
}
Attributes
The following attributes are available for the fake switch model:
| Name | Type | Required? | Description |
|---|---|---|---|
position_count | int | Required | The number of positions that the switch can be in. Default: 2 |
labels | array | Optional | An array of labels corresponding to the positions. Default: numeric values for the number of positions, starting with 0. |
Test the switch
Once you have configured your switch, open the switch’s TEST panel on the CONFIGURE or CONTROL tab.
Use the buttons to view and change the switch’s position.
Troubleshooting
If your fake switch is not working as expected:
- Check your machine logs on the LOGS tab to check for errors.
- Make sure the
position_countmatches the number oflabelsif both are specified. - Verify that position values used with
SetPositionare within the valid range (0 toposition_count - 1). - Click on the TEST panel on the CONFIGURE or CONTROL tab and test if you can use the switch there.
Next steps
Check out the switch API or check out one of these guides:
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!