I would like to keep in memory a previous value received for the calculation of a new value in the payload parser. For example, my device sends a raw acceleration value, but to compute the real acceleration value, I need the sensitivity value of the device which is subject to change. I don’t want to send the sensitivity value every time if it’s the same as the one in the previous payload. Is it possible to store the last sent sensitivity value and re-use it when a new payload is coming in the payload parser?
So, to you use it in your payload parser just use the reserved word device.tags. Device tags is an array of key and value, like: [{ key: ‘foo’, value: ‘bar’}, { key: ‘foo1’, value: ‘bar1’}… ]
To get your desired tag, just use the following code:
const sensitivity_tag = device.tags.find(x => x.key === ‘sensitivity’); // if you use other tag key, change the sensitivity key on .find function
console.log(sensitivity_tag); // prints { key: ‘sensitivity’, value: ‘10’ };
console.log(sensitivity_tag.key); // prints: ‘sensitivity’
console.log(sensitivity_tag.value); // prints: ‘10’