How to keep in memory previous value in payload parser

Hi!

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?

Thank you!­

hi @emile,

You can set the sensitivity data in the device tags, like the image below:

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’

1 Like

Hi!

Thanks for the answer.

Is it possible to change tags value from the payload parser?

Thanks!

Émile Laplante, B.Sc

Développeur matériel et logiciel / Firmware and Hardware Developer

Lynkz Instruments inc.

m:
1-(819)-962-2345

w:
www.lynkz.ca e: emile@lynkz.ca

hi @emile,

It’s not possible. The payload parser is only to convert e use the fields com the device.

To change the tags you need to use an analysis script.

Thanks for the quick response!

How can I do it in an analysis? And what will be the difference between using Tags registers vs Configuration Parameters registers?

Thank you!

Émile Laplante, B.Sc

Développeur matériel et logiciel / Firmware and Hardware Developer

Lynkz Instruments inc.

m:
1-(819)-962-2345

w:
www.lynkz.ca e: emile@lynkz.ca

hi @emile,

Tags are used to add identification to the resources, you can use them in devices, buckets, dashboards, users, and actions. See here an example of tags usage: https://docs.tago.io/en/articles/186-defining-permissions.

Parameters are an item only of devices and are mostly used to define downlink fields. See here an example of parameters usage: https://docs.tago.io/en/articles/172-sigfox-downlink