--- title: "relayr: Sending Values / Receiving Commands - icom Data Suite" slug: "relayr-sending-values-receiving-commands-en" updated: 2024-09-12T06:48:53Z published: 2024-09-12T06:48:53Z canonical: "docs.insys-icom.com/relayr-sending-values-receiving-commands-en" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.insys-icom.com/llms.txt > Use this file to discover all available pages before exploring further. # relayr: Sending Values / Receiving Commands - icom Data Suite The icom Data Suite allows to send data to the relayr cloud service from an INSYS router and receive commands sent from the relayr cloud service to the INSYS router. ## Situation The value of a data point of an INSYS router is to be sent to relayr cloud service by the icom Data Suite. relayr again will send a message to the router to modify a data point of the icom Data Suite. ## Solution The following simple exemplary application transmits the count of a timer of the icom Data Suite to relayr in regular intervals. relayr again sends a message to the icom Data Suite every time the count exceeds a specific value. This message increases a counter in the icom Data Suite that counts how often the timer count has exceeded this threshold. This application is only intended to demonstrate how to send a value to relayr and receive commands from relayr and has no technical importance. ### relayr configuration It is prerequisite that you have a relayr account. 1. Open the relayr website using a browser: - [https://dev.relayr.io](https://dev.relayr.io) 2. Log in to your relayr account. 3. Change to the *Models* section in the menu on the left (). 4. Click on *ADD NEW MODEL* at the bottom right. 5. Click on *Add reading* () and edit it: - *Meaning* : Timer - *Path* : leave empty > [!NOTE] > Please note! > > A path can used to separate multiple readings with the same meaning. For example, if your device includes sensors that are measuring the temperature in different rooms, then path can be used to specify which room each temperature reading is coming from. The property must be supplied, but it can be left blank. - *Value type* : *Number* - *unit* : s - *maximum* : 20 - *minimum* : 0 6. Click on *Add command* () and edit it: - *Meaning* : Counter - *Value type*: *Integer* 7. Under *Device model details*, enter **INSYS router** as *DEVICE MODEL NAME*. 8. Enter **www.insys-tec.com** or your website as *WEBSITE*. 9. Enter any other details you want to enter. 10. Click on *SAVE MODEL* at the bottom right. 11. Change to the *Devices* section in the menu on the left (). 12. Click on *ADD…​* . 13. Change to the *By me* tab and select the model created above. 14. Click on *FINISH*. 15. Enter a name for the device and click on *GO TO DEVICE*. 16. Click on *Settings* at the top right to open the *Device Settings* window (). 17. Copy the JSON code under *Credentials* to a text editor for the following configuration of the icom Data Suite (this contains access data for the relayr MQTT broker and the topic that will be evaluated by this device). 18. Close the *Device Settings* window again (). 19. Change to the *Projects* section in the menu on the left (). 20. Click on *CREATE A NEW PROJECT*. 21. Enter a *PROJECT NAME* and click on *NEXT*. 22. Enter an optional *AUTHORIZATION URL* and click on *NEXT*. 23. Click on *FINISH*. 24. Click on *OPEN PROJECT* to open the project created above. 25. Click on *CREATE NEW RULE*. > [!NOTE] > Please note! > > This rule will evaluate the timer reading transmitted from the INSYS router and issue an MQTT command message every time a counter value exceeding 13 is transmitted. 26. Enter a *Rule name* and specify the *If…​* condition of the rule: - *Select device* : select the device created above - *Select* : select the *Timer* reading - *Select comparison* : *> (Greater than)* - Enter a comparison value of **13** 27. Continue to specify the *Then…​* condition of the rule: - *Select device* : select the device created above - *Select* : select the *Counter* command - Enter a comparator value of **1** 28. Click on *SAVE & CLOSE*. ### icom Data Suite configuration It is prerequisite that you have access to the web interface of the icom Data Suite. The router must have Internet connection. The following instructions assume that the icom Data Suite is in default settings and has the required licenses. 1. Open another browser tab or window and start the web interface of the icom Data Suite: - [https://192.168.1.10](https://192.168.1.10) or [https://ids.local](https://ids.local) (default) - *User name*: insys (default) - *Password*: icom (default) 2. In the *Data points* → *Flags* menu, add a new flag () and edit it (): - *Description*: Counter - Type: *Unsigned integer* 3. Click on *Save settings*. 4. In the *Data points* → *Timer* menu, add a new timer () and edit it (): - *Description*: Message timer - Type: *Interval*, triggered every 23 seconds 5. Click on *Save settings*. 6. In the *Data points* → *Timer* menu, add a new timer () and edit it (): - *Description*: Count sample timer - Type: *Interval*, triggered every 20 seconds 7. Click on *Save settings*. 8. In the *Messages* → *MQTT* menu, add a new broker () and edit it (): - *Description*: relayr - *Server*: mqtt.relayr.io - *Port* : 1883 - *Version* : v3.1 - *User name* : paste the string *user* from the credentials copied above (without quotation marks) - *Password* : paste the string *password* from the credentials copied above (without quotation marks) - *Client ID* : paste the string *clientId* from the credentials copied above (without quotation marks) 9. Click on *Save settings*. 10. In the *Messages* → *MQTT* menu, add a new message () and edit it (): - *Description*: Timer message - *Topic*: paste the string *topic* from the credentials copied above (without quotation marks) and add **data** (adding **data** means that the topic must have a format like **/v1/d677…​cedb/data**) - *Message*: Enter the message in the following JSON format: ```json { "path": "", "meaning": "Timer", [6] "value": "$timer2 ", [7] "received": "$TIME ", [7] } ``` > [!NOTE] > Please note! > > `"Timer"` corresponds to the reading created for the model in relayr above. > > The blank behind the variables `"$timer2 "` and `"$TIME "` is essential. - *Retain*: - *QoS*: 0 11. Click on *Save settings*. 12. In the *Events* menu, add a new event () and edit it (): - *Description*: Send timer message to relayr - *Event*: *Timer expired* - *Timer*: select above added *timer1 - Message timer* - *Topic*: paste the string *topic* from the credentials copied above (without quotation marks) and add **cmd/** (adding **cmd/** means that the topic must have a format like **/v1/d677…​cedb/cmd/#**) - *Action*: *Send message* - *Send message*: select above added timer message 13. Click on *Save settings*. 14. In the *Events* menu, add a new event () and edit it (): - *Description*: Increase counter upon relayr command - *Event*: *MQTT message has been received* - *From MQTT broker*: select above added *mqttBrkr1 - relayr* - *Text* : leave this empty that the icom Data Suite triggers upon each MQTT message from relayr with this topic - *Action*: *Change analogue data point* - *Data point*: select above added *flag1 - Counter* and *increment by* *user-defined value* **1**. 15. Click on *Save settings*. 16. Activate the profile (). 17. Click on *Status* → *Current values* to watch the lapsing timers and the increase of the counter. 18. Click on *Status* → *Log view*, check *Timer* and *MQTT* to watch timer expiries as well as sent and received MQTT messages. 19. Change back to the relayr browser tab or window. 20. Change to the *Devices* section in the menu on the left (). 21. Select your device to watch the changing timer value that is transmitted regularly. ## Troubleshooting - If the icom Data Suite cannot connect to the relayr MQTT broker, check the configuration of the MQTT broker. - If the icom Data Suite can connect to the relayr MQTT broker, but relayr does not receive signal data, check the following: - The topic of the message must be like in the credentials plus the added string. - The blank behind the variables (like behind `$TIME)` and before the quotation mark is important. A missing blank causes that the message will not be valid.