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.
Open the relayr website using a browser:
Log in to your relayr account.
Change to the Models section in the menu on the left ().
Click on ADD NEW MODEL at the bottom right.
Click on Add reading () and edit it:
Meaning : Timer
Path : leave empty
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
Click on Add command () and edit it:
Meaning : Counter
Value type: Integer
Under Device model details, enter INSYS router as DEVICE MODEL NAME.
Enter www.insys-tec.com or your website as WEBSITE.
Enter any other details you want to enter.
Click on SAVE MODEL at the bottom right.
Change to the Devices section in the menu on the left ().
Click on ADD… .
Change to the By me tab and select the model created above.
Click on FINISH.
Enter a name for the device and click on GO TO DEVICE.
Click on Settings at the top right to open the Device Settings window ().
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).
Close the Device Settings window again ().
Change to the Projects section in the menu on the left ().
Click on CREATE A NEW PROJECT.
Enter a PROJECT NAME and click on NEXT.
Enter an optional AUTHORIZATION URL and click on NEXT.
Click on FINISH.
Click on OPEN PROJECT to open the project created above.
Click on CREATE NEW RULE.
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.
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
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
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.
Open another browser tab or window and start the web interface of the icom Data Suite:
https://192.168.1.10 or https://ids.local (default)
User name: insys (default)
Password: icom (default)
In the Data points → Flags menu, add a new flag () and edit it ():
Description: Counter
Type: Unsigned integer
Click on Save settings.
In the Data points → Timer menu, add a new timer () and edit it ():
Description: Message timer
Type: Interval, triggered every 23 seconds
Click on Save settings.
In the Data points → Timer menu, add a new timer () and edit it ():
Description: Count sample timer
Type: Interval, triggered every 20 seconds
Click on Save settings.
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)
Click on Save settings.
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:
{ "path": "", "meaning": "Timer", [6] "value": "$timer2 ", [7] "received": "$TIME ", [7] }
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
Click on Save settings.
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
Click on Save settings.
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.
Click on Save settings.
Activate the profile ().
Click on Status → Current values to watch the lapsing timers and the increase of the counter.
Click on Status → Log view, check Timer and MQTT to watch timer expiries as well as sent and received MQTT messages.
Change back to the relayr browser tab or window.
Change to the Devices section in the menu on the left ().
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.