Reducing Data Input usage with your own parser

I will give some tips of how to reduce the usage of your Data Input service by ignoring some irrelevant variables sent by your devices.

Data Input service

Each time a device sends data to TagoIO, the system will count 1 Data Input Transaction for each variable.

These data input transactions are counted against your account in the Profile where your devices are located.

Given how Data Input works, it is very common for users to add their devices to the TagoIO platform, receive 20 device variables but only use 3 for example. For example, LoRaWAN network will add signal level, status, counter, and several other data that may be not relevant for your application.

In order to reduce the Data Input usage, you can create an additional parser for your device.

How to use your own parser

I’ll give you an example, suppose you have a device that is sending you 10 variables, but you only use the temperature and battery variables. To ignore all other variables and make only the temperature and battery variables count as Data Input, go to your device and enter the Payload Parser tab, there you will find a “Run your own parser” key as highlighted in image below.

Turn this key on and the editor will be available, there you will see that there is already a snippet in the editor, which would be the following code:

/* This is a default example for payload parser. 
** The ignore_vars variable in this code should be used to ignore variables 
** from the device that you don't want. 
** 

** Testing: 
** You can do manual tests to this parse by using the Device Emulator. Copy and Paste the following code: 
** [{ "variable": "payload", "value": "0109611395" }] 
** 
*/

// Add ignorable variables in this array. 
const ignore_vars = ['rf_chain', 'channel', 'modulation', 'app_id', 'dev_id', 'time', 'gtw_trusted', 'port']; 

// Remove unwanted variables. 
payload = payload.filter(x => !ignore_vars.includes(x.variable)); 

// You can edit any variable that's being added to your device. 
// For example, if you need to convert a variable from Fahreinth to Celsius, uncomment the following code: 
// const temperature = payload.find(x => x.variable === "temperature"); 
// if (temperature) { 
//   temperature.value = (5 / 9) * (temperature.value - 32); 
//   temperature.unit = "C"; 
// } 

The only thing you need to modify in the code is in the line 11 which deals with the variables that will be ignored (and not sent to your data bucket).

const ignore_vars = ['rf_chain', 'channel', 'modulation', 'app_id', 'dev_id', 'time', 'gtw_trusted', 'port']; 

Modify the array from line 11 to what you need, following the existing structure. For example, if you want to ignore the variables: port, device_number and payload. Just change line 11 to the following line:

const ignore_vars = ['port', 'device_number', 'payload']; 

After you have modified line 11 to ignore the variables you want, just click in the Save button and from there those variables will no longer be counted. If you had any problems or questions regarding this post, please share your difficulty below and I will be very happy to help you!

Did you already know this trick to reduce your Data Input?

  • Very good, but I already knew this trick!
  • I did not know this was possible!

0 voters