Quick setup an analysis to split up data in different devices based on a ID or Serial. Very useful when sending data to TagoIO using MQTT/NodeRed.
In this tutorial, you will learn:
There are a few situations when you can only send data to one device using MQTT or other kind of integration. When that happens, it is recommended to split the data some way into different devices of your account.
TagoIO main features expects for a device to represents a sensor. Blueprint dashboards only works with that structure, and it is the most useful resource for scaling applications.
Having a different device for each sensor also make easier to pull data from the device when needed, as there is no need to check each data of the device to know from which sensor it belongs.
You will need an working application, which means you need to have your Gateway/Device already communicating with TagoIO using a Custom MQTT or other connector integration.
The network will provide some routes to find a device in your account, that had been created using the network. Later on we will see that in use on the analysis script.
1 Go to Integration → Network to add a network. In this example, the network name is UG65 Network.
This step is one of the most important, as the analysis code is responsible for doing all the job of splitting up your data into different devices.
The script provided in this step does have in-code comments, that you can read to understand each section of the code. You will need to use the scope parameter of the analysis, that is the content that you sent to the analysis, and then get the correct parameter that contains the Serial of your device.
If needed, you can always add a console.log(scope) to see exactly what you’re receiving on the scope parameter.
Now install following analysis template by clicking here
In the analysis screen, go to Environment Variables.
You can place the Network token in the value of the network_token key.
You need a account-token from your profile for the account-token value. Generate one in you Profile → Tokens.
Press the save button.
We need to create an Action, it will be responsible to understand when the Analysis must run and on which conditions.
In this case, we want the analysis to trigger when we receive any message from a specific topic on our Device MQTT Connection. So this is how we set it up:
Go to Action to add an action, select the type as MQTT Topic and action as Run Analysis , then select the analysis you created.
Go to Action tab to add an action, select the type as MQTT Topic and action as Run Analysis , then select the analysis you created.
As the end of the tutorial, you only need now to create devices using the connectors you created, and making sure you input serial that you’re sending to the MQTT.
You can create devices by accessing Devices → + Add Device → My Networks.