Trigger custom operation via SmartRest (not thinedge in the agent code)

Product/components used and version/fix level:
Cumulocity, version/fix 10.11

Detailed explanation of the problem:
Custom operations are created on the platform using REST API.
Agent/device agent is using MQTT and is subscribed on topic s/ds for notification.
Out of box operations are getting triggered, but we have custom operation that is created by custom UI using webSDK (REST). Agent is not getting this trigger on topic s/ds because its a custom operation.

Is there a way the agent will get notificiation. Please note operation is created by custom UI using webSDK, but the agent needs to be notified on MQTT.


If you want to be notified through MQTT, you need to create a SmartREST template that will match your operation.
The way SmartREST templates match an operation is rather simple, you just need something in your operation that helps differentiate it. Say you have an operation that looks like that:

    "myCustomFragment": {
        "someData": "someValue"

Then most probably you want to create a SmartREST template that will match “myCustomFragment” fragment.
If you do that through the UI, just go to “Device Types” → “SmartREST templates” then create a new template.
Be careful with the template ID as this will be part of the MQTT topic you’ll have to subscribe to (s/dc/<template ID>).
Create a new response: response ID can be whatever you want, again be careful as it will be part of the message sent to you through MQTT so you know what operation it is.
You can leave “base pattern” empty.
Then, in patterns, simply add “myCustomFragment”, save and that’s it.

1 Like

Hi Cyril Poder,

Here is the custom operation
“deviceId”: “123456”,
“description”: “Firmware cancel request”,
“hr_FirmwareCancellation”: {}

and in MQTT box, I have subscribed to s/dc/hr_FirmwareCancellation, but not getting anyting in MQTTbox.

Did I miss anything? Appreciate your help.


Could be several things:

  • Check that the MQTT client id match the c8y_Serial external id of the device. If the device has no such external id (possible if it was created through http API) then create one (in that case you should also change how devices are created and ensure they always have a c8y_Serial external id)
  • Check that the MQTT user is at least the owner of the device or has rights over it (like the admin users)

The condition in your response template is missing.

Just add hr_FirmwareCancellation there too otherwise no Message will be created.
Patterns describe which information will be added to that message in the order you have defined it. In your case just nothing as hr_FirmwareCancellation is an empty object. So the message will basically look like this: 1300,

As Cyril stated it is important that the the owner of the device matches the user used in MQTTBox. Also the ClientID must match the c8y_Serial.
For a simple test just do the following:

  1. Create a new device using MQTTBox 100,TestDevice
  2. Subscribe to s/dc/hr_FirmwareCancellation in MQTTBox.
  3. Create the Operation (Postman or UI etc.)
  4. You should have received you message 1300 with the properties you have defined.