How to use RelayArray widget to control device operation

What product/components do you use and which version/fix level are you on?

Cumulocity IOT - cockpit
Backend: 1014.0.172
UI: 1014.0.172

Is your question related to the free trial, or to a production (customer) instance?

Free trial

What are you trying to achieve? Please describe it in detail.

I am trying to use a relay array control, but the widget does not show any toggle switches. I have published a “114,supported operations” message to the s/us topic from the device including the c8y_RelayArray fragment.

This works/displays correctly for the single relay widget but not the relay array.

Do you get any error messages? Please provide a full error message screenshot and log file.

No, the widget is blank.

Have you installed all the latest fixes for the products and systems you are using?

N/A

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"

Thank you for your detailed reply.

If I understand correctly, my device needs to send the following:
Set the supported operations of the device. eg 114,c8y_RelayArray
(this removes the “Operation not supported by this device” warning in the widget"

then I need to send an operation successful status to update the relay states (eg 2 channel array)
503,c8y_RelayArray,"CLOSED","OPEN"

I have retried this without success. The widget still appears empty.

The 503 only works to move an already existing operation of the specified type from status EXECUTING to SUCCESSFUL. It can not be used standalone to set the initial status of relays. You can find its documentation here SmartREST 2.0 - Cumulocity IoT Guides

There is no static template prepared for devices to communicate the initial status of a relay array. If you intend to do this using SmartREST you will have create a custom legacy template. A custom SmartREST 2.0 template will not work due to its limited support for setting array parameters.

Thank you Phillipp.

I think I am mixing two concepts here base on the original reply. Managing the object and managing the operation.

I am comfortable managing the operation of the relay array using SmartRest2.0 but I don’t think my managed object has the cy8_RelayArray fragment defined. How do I define it? How do I check it?

I am using python mqtt for messaging.

I am finding the relay array information not very clear and is far more difficult than the single relay. Is there an example of its use anywhere?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.