# Relay control widgets not working for relays in raspberry pi

**URL:** https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878
**Category:** Forum
**Tags:** cumulocity, thin-edge-io
**Created:** [November 6, 2023, 10:23am UTC](https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878 "2023-11-06T10:23:24Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![lall.gaurav](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@lall.gaurav](https://community.cumulocity.com/u/lall.gaurav)
#### Post date: [November 6, 2023, 10:23am UTC](https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878/1 "2023-11-06T10:23:24Z")

</div>

Relay control widgets not working for relays in raspberry pi.

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

#### _Detailed explanation of the problem:_

I am using raspberry pi with sensors and relays. I am able to control the relays using shell command in cumulocity’s ‘Device Management’ platform. But when I am using ‘relay control’ widget in custom built application then I am getting a message ‘Operation not supported by this device’. Please help to solve this issue. I want to control relays using ‘RELAY CONTROL’ widget.  
Thanks in advance.

#### _Error messages / **full error** message screenshot / **log** file:_

 ![Capture relay](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/b/9/b9f5a7a3331cd33dbdd7b6d41d23b3efe844d650.png)

#### _Question related to a **free trial** , or to a **production (customer)** instance?_

---

<div class="post-metadata">

### Author: ![Tristan\_Bastian](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/tristan_bastian/32/18259_2.png) [@Tristan\_Bastian](https://community.cumulocity.com/u/Tristan_Bastian)
#### Post date: [November 6, 2023, 10:33am UTC](https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878/2 "2023-11-06T10:33:13Z")

</div>

Hi Lall,

your device needs to support the `c8y_Relay` operation: [Sensor library - Cumulocity IoT Guides](https://cumulocity.com/guides/reference/sensor-library/#c8y_relay)  
In order for the Cumulocity UI to know that this operation is supported by your device, you will need to also list it within the `c8y_SupportedOperations`: [Device management library - Cumulocity IoT Guides](https://cumulocity.com/guides/reference/device-management-library/#announcing-capabilities)

Regards,  
Tristan

---

<div class="post-metadata">

### Author: ![lall.gaurav](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@lall.gaurav](https://community.cumulocity.com/u/lall.gaurav)
#### Post date: [November 8, 2023, 11:27am UTC](https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878/3 "2023-11-08T11:27:58Z")

</div>

I am able to get the ‘Relay Control’ buttons. And also in the control tab of device I am getting ‘close relay’ and ‘open relay’ commands. But the actual relays of the device is not responding.

 ![relay control](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/d/f/df23954d418e12e9129c8a876fedb70ea3c04fa5.png)  
Please help.

---

<div class="post-metadata">

### Author: ![Tristan\_Bastian](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/tristan_bastian/32/18259_2.png) [@Tristan\_Bastian](https://community.cumulocity.com/u/Tristan_Bastian)
#### Post date: [November 8, 2023, 12:06pm UTC](https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878/4 "2023-11-08T12:06:24Z")

</div>

Your device/agent needs to support the `c8y_Relay` operation.  
As you are using thin-edge, you need something on your device that receives the relay operation ([SmartREST - Cumulocity IoT Guides](https://cumulocity.com/guides/reference/smartrest-two/#relay-518)) processes it and updates it status. You would need to connect to the respective thin-edge mqtt topics on your local mqtt broker.

Regards,  
Tristan

---

<div class="post-metadata">

### Author: ![lall.gaurav](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@lall.gaurav](https://community.cumulocity.com/u/lall.gaurav)
#### Post date: [November 13, 2023, 12:07pm UTC](https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878/5 "2023-11-13T12:07:34Z")

</div>

I am able to send relay command to switch on the relay in raspberry pi. First I sent “relayState” : “OPEN” through postman to this path ‘/inventory/managedObjects’ then I have created a file named ‘c8y\_Relay’ in operations folder in raspberry pi. After that I used java program to receive relay command and send acknowledgement to cumulocity. I am able to see the relay operation ‘successful’ in control tab of 'device management. But when I am reloading the page the state of relay is not changing even after successful relay operation. Also When I am checking the state of c8y\_Relay in config it is not changing.

 ![acknowledge](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/f/4/f4b23580d825600647e08a790b13dcf6ff439792.png)

---

<div class="post-metadata">

### Author: ![lall.gaurav](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@lall.gaurav](https://community.cumulocity.com/u/lall.gaurav)
#### Post date: [November 24, 2023, 11:18am UTC](https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878/6 "2023-11-24T11:18:48Z")

</div>

I am sending acknowledgement in java as " client.publish(“c8y/s/us”, “503,c8y\_Relay,relayState:OPEN”.getBytes(), 2, false)". This is updating the status of relay in real time but status is not getting updated in cumulocity database. Please help in updating relay status in cumulocity database.

 ![acknowledge](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/f/4/f4b23580d825600647e08a790b13dcf6ff439792.png)  
 ![database status not changing](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/9/2/92650449c8023626a230181dfbbf6691bf1c59bf.png)

---

<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 22, 2024, 11:19am UTC](https://community.cumulocity.com/t/relay-control-widgets-not-working-for-relays-in-raspberry-pi/5878/7 "2024-05-22T11:19:47Z")

</div>

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