# Trigger custom operation via SmartRest on thinedge.io device

**URL:** <https://community.cumulocity.com/t/trigger-custom-operation-via-smartrest-on-thinedge-io-device/7845>\
**Category:** Forum\
**Tags:** thin-edge-io, cumulocity\
**Created:** [November 22, 2023, 1:22pm UTC](https://community.cumulocity.com/t/trigger-custom-operation-via-smartrest-on-thinedge-io-device/7845 "2023-11-22T13:22:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![simeon.mendgen](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@simeon.mendgen](https://community.cumulocity.com/u/simeon.mendgen)\
**Post date:** [November 22, 2023, 1:22pm UTC](https://community.cumulocity.com/t/trigger-custom-operation-via-smartrest-on-thinedge-io-device/7845/1 "2023-11-22T13:22:08Z")

</div>

#### _ **Product/components** used and **version/fix** level:_

[thinedge.io](http://thinedge.io) 0.13.1  
.eu-latest.cumulocity.com 1018

#### _Detailed explanation of the problem:_

I try to run a custom operation on my device running [thinedge.io](http://thinedge.io).

Therfore i created a SmartRest Template:

 ![image](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/c/4/c4714eb3c69fe4d0d9e7344ec52f7b2044267fe2.png)

I tested it with MQTT-Box and the template works, i get the MQTT-Message on “s/dc/greenhousewebcam” (`541,mqtt-test2,51886804,5`) when posting a coresponding opereation via rest.

But it does not work for thinedge.  
I created a file “c8y\_Startstream” on “/etc/tedge/operations/c8y/”  
To debug i subscribed on the thinege device to ‘#’.  
But i get nothing when creating my operation for it.

When eg. i try to pull a config via Cumulocity UI, i see the operation on the thinedge broker:  
`[c8y/s/ds] 526,RPI-Device,tedge-configuration-plugin` . Like this i expect to see something when using my custom operation.

Is this an issue with thinedge or with smart rest?  
How should custom operations be done with thinedge?

---

<div class="post-metadata">

**Author:** ![Cyril\_Poder](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/cyril_poder/32/17142_2.png) [@Cyril\_Poder](https://community.cumulocity.com/u/Cyril_Poder)\
**Post date:** [November 22, 2023, 1:35pm UTC](https://community.cumulocity.com/t/trigger-custom-operation-via-smartrest-on-thinedge-io-device/7845/2 "2023-11-22T13:35:36Z")

</div>

Hi,  
I don’t know what you put in your “c8y\_Startstream” file, but ensure it looks like this:

```auto
[exec]
  topic = "c8y/s/dc/greenhousewebcam"
  on_message = "541"
  command = <path to the script to execute>
  timeout = 10

```

See documentation: [https://thin-edge.github.io/thin-edge.io/operate/c8y/supported\_operations/#working-with-custom-operations](https://thin-edge.github.io/thin-edge.io/operate/c8y/supported_operations/#working-with-custom-operations)

Also you need to register your custom template in thin-edge:

```auto
sudo tedge config set c8y.smartrest.templates greenhousewebcam

```

See documentation: [https://thin-edge.github.io/thin-edge.io/operate/c8y/smartrest\_templates/](https://thin-edge.github.io/thin-edge.io/operate/c8y/smartrest_templates/)

Best regards,

Cyril

---

<div class="post-metadata">

**Author:** ![simeon.mendgen](https://avatars.discourse-cdn.com/v4/letter/s/eb9ed0/32.png) [@simeon.mendgen](https://community.cumulocity.com/u/simeon.mendgen)\
**Post date:** [November 22, 2023, 1:49pm UTC](https://community.cumulocity.com/t/trigger-custom-operation-via-smartrest-on-thinedge-io-device/7845/3 "2023-11-22T13:49:58Z")

</div>

Hi Cyril,

this was fast! I missed the part of registering the template in thin-edge.

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [May 20, 2024, 1:50pm UTC](https://community.cumulocity.com/t/trigger-custom-operation-via-smartrest-on-thinedge-io-device/7845/4 "2024-05-20T13:50:14Z")

</div>

Closed on May 20, 2024, 1:50pm UTC

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