The failover
module provides sensor models which allow you to designate a primary sensor and backup sensors in case of failure. The models implement the rdk:component:sensor
API, rdk:component:movement_sensor
API, and rdk:component:power_sensor
API respectively.
It supports sensor, power sensor, or movement sensor models as the primary and backup components, depending on the model you configure.
Note
Before configuring your sensor, you must create a machine.
Navigate to the CONFIGURE tab of your machine’s page in the Viam app.
Add sensor
/ failover:sensor
, sensor
/ failover:movement_sensor
, or sensor
/ failover:power_sensor
to your machine.
On the new component panel, copy and paste the following attribute template into your sensor's attributes field:
{
"primary": "sensor-primary",
"backups": [
"sensor-backup",
"sensor-backup2"
]
}
Edit the attributes as applicable to the sensors you have configured.
The following attributes are available for all failover
models:
Name | Type | Required? | Description |
---|---|---|---|
primary |
string | Required | Name of the primary component. |
backups |
string array | Required | List of backups to use if the primary component fails. The order in the array corresponds to the order they will be used in. |
{
"name": "my-failover-sensor",
"model": "viam:failover:sensor",
"type": "sensor",
"namespace": "rdk",
"attributes": {
"primary": "sensor-primary",
"backups": [
"sensor-backup",
"sensor-backup2"
]
}
}
{
"name": "my-failover-power-sensor",
"model": "viam:failover:power_sensor",
"type": "power_sensor",
"namespace": "rdk",
"attributes": {
"primary": "primary-ps",
"backups": [
"backup-ps",
]
}
}
{
"name": "my-failover-movement-sensor",
"model": "viam:failover:movement_sensor",
"type": "movement_sensor",
"namespace": "rdk",
"attributes": {
"primary": "primary-ms",
"backups": [
"backup-ms",
]
}
}
- To test your sensor, movement sensor, or power sensor, expand the TEST section of its configuration pane or go to the CONTROL tab.
- To write code against your sensor, use one of the available SDKs.
- To view examples using a sensor component, explore these tutorials.