User generated free text variable

I would like to be able to give the users of our dashboards the ability to enter a text description or a name to the devices they install. For example, the user places a sensor in their kitchen and I’d like them to be able to label this with ‘Kitchen’ and have the name or location display in their dashboard.

I am using the input form widget.

I would like to create a variable called ‘Location’ that has a blank text string, that will store the user-generated free text but my question is can I create this variable from my device parser/decoder in TTN rather than in Tago?

If I create this variable with the blank string in my device parser/decoder in TTN, every time my device sends an updated message it erases the user-generated free text.

I have tested successfully creating a blank string variable with the emulator in Tago and as it is not also a variable in my device parser it works, however, this is not scalable. If I have thousands of devices I would have to add it to each device in Tago, so I’d prefer to be able to add it to the parser/decoder in TTN.

To summarise I would like to be able to add a blank variable from my device parser/decoder in TTN that does not keep erasing the users generated free text each time the device updates.

Any ideas welcome

Hi @bibi.nelson!

Welcome to our community! We’re glad to have you here. :partying_face:

Soon our team or a user will help you with this query.

Best regards!

Hi Bibi,
There is no way to communicate to TTN your parameters from TagoIO. That said, you can’t change your decoder on TTN based on what you have on TagoIO, at least as far as I know. This is more on TTN side than ours.

What you can do is to create a decoder on TagoIO side. You can still keep your decoder running in TTN, but in TagoIO you can edit your data from TTN to add new parameters to it.

In order to do that, you first need to create an Input form and use whatever variables you want to store the user input. Also, make that Input Form to run an analysis.
In your analysis, you must edit the device Configuration Parameter, it should be a code like this:

const { Account, Analysis } = require('@tago-io/sdk');

async function startAnalysis(context, scope) {
  const account = new Account({ token: 'your-acc-token' });

  // Example with location address
  // The variable location_address must be send by your input form.
  const location_address = scope.find((data) => data.variable === "location_address");

  // Get the Configuration Parameter list of the device
  const parameters = await account.devices.paramList(scope[0].origin);
  let location_param = parameters.find((param) => param.key === "location_param");

  // check if param exist, create it if doesn't.
  if (!location_param) {
    location_param  = { key: 'location_param', value: '' };

  // update the value with the input form value for location_address
  location_param.value = location_address.value;

  // update the configuration parameter in the device
  account.devices.paramSet(scope[0].origin, location_param);

module.exports = new Analysis(startAnalysis);

Then you need to update your Decoder for your device in order to use the configuration parameter. This is an example for the location_param we just used in the analysis:

// I'm assuming you want to edit the location variable.
const location = payload.find((data) => data.variable === 'location');
const location_param = device.params.find((param) => param.key === 'location_param');

// only run the code bellow if location and location_param exists.
if (location && location_param) {
   location.value = location_param.value;

Hi Vitor

Thanks very much, I’ve not yet fully explored the Analysis section so I’ll go through this.

We might also explore having a ‘setup parser/decoder’ from TTN to initially create the variables we need and then an ‘ongoing parser/decoder’, but your Analysis suggestion might work out better