How to use RelayArray widget to control device operation

The Relay Array Control widget requires the device to support the c8y_RelayArray operation and also requires the device to communicate its current status of relays using the c8y_RelayArray fragment in its own managed object.

So the managed object must have at least the following properties:

{
    "c8y_RelayArray": [
        "OPEN",
        "CLOSED",
        "CLOSED",
        "OPEN"
    ],
    "c8y_SupportedOperations": [
        "c8y_RelayArray"
    ]
}

The size of the relay array can vary and its content will define how many individual relays are shown and can be controlled in the widget.

With the example above the widget will show 4 relays in the status as declared like this:
image

When a user toggles the status of one of the relays an operation with the desired status of all relays is sent to the device. So if a user toggles the first relay in this example an operation like this is sent to the device:

{
    "c8y_RelayArray": [
        "CLOSED",
        "CLOSED",
        "CLOSED",
        "OPEN"
    ]
}

As part of processing this operation the device is required to perform the usual status transitions and also update the c8y_RelayArray fragment with the new status in the device’s own managed object. For SmartREST 2 connected devices there is no dedicated static template for this inventory update. The static template for setting operations to successful (503) will implicitly perform this update for c8y_RelayArray operations when the statuses of the relays are added at the end like this:

503,c8y_RelayArray,"CLOSED","CLOSED","CLOSED","OPEN"