TagoIO Integration - Output Location variable on Decoder

Hi, I have created a TagoIO application integrated with TTN. At TagoIO, I need to show 2 variables on a map, so I must send a location (with latitude and longitude) field on JSON object, as Tago requires. I have tried to add the location variable on the decoder function, but the TagoIO payload parser always separate this information on a different JSON object. I’ll explain better.

On TagoIO Help Center, it says: “To display locations on a Map, your data needs to be sent inside the “location” field with the format shown below:”

{
  "variable": "speed",
  "value": 10,
  "location": {
    "lat": 42.2974279,
    "lng": -85.628292
  }
}

So I have tried the following Decoder Functions:

function Decoder(bytes, port) {
  // Decode an uplink message from a buffer
  // (array) of bytes to an object of fields.

  var decoded = {};
  var FillLevel = bytes[0];
  var BatteryLevel = (bytes[1] << 8) + bytes[2];  
  return{
    "myvariable1" : {
      "variable": "FillLevel",
      "value": FillLevel,
      "location":{
         "lat": -22.006680,
         "lng": -47.896187
         }
    },
      
      
      "myvariable2" : {
        "variable": "BatteryLevel",
        "value": BatteryLevel/100,
        "location":{
         "lat": -22.006680,
         "lng": -47.896187
        }
      }
      

  };
}

and a more simple one,

function Decoder(bytes, port) {
  // Decode an uplink message from a buffer
  // (array) of bytes to an object of fields.

  var decoded = {};
  var FillLevel = bytes[0];
  var BatteryLevel = (bytes[1] << 8) + bytes[2];  
  return{
    "FillLevel": FillLevel,
    "BatteryLevel": BatteryLevel/100,
    "location": {
      "lat": -22.00668,
      "lng": -47.896187
    }
  };
}

None of them worked (I have also tried other variations of decoder functions, with no success). When using the Live Inspector on Tago, I always see something like that:

10

In some situations, TagoIO creates a variable called “location_location”, with the location field required. But the “value” field is always equal to the “latitude” variable, so I can only see this on dashboard map, as follows:

20

That means I’m either sending the data on a wrong format, or parsing the data wrongly on TagoIO (I couldn’t understand the parsing function correctly).
Have anyone ever tried to do something related to this? I’m desperate. I’m also posting this on TagoIO community center.

Thanks!

What about (testing with) a third option, only sending a single reading using the format that you quoted from the help:

function Decoder(bytes, port) {
  var FillLevel = bytes[0];
  return {
    variable: "FillLevel",
    value: FillLevel,
    location: {
      lat: -22.006680,
      lng: -47.896187
    }
  };
}

(I have not read the documentation; please add a link to that. Maybe it indeed supports multiple variables as well. And totally as an aside: as the Decoder returns a JavaScript object, there is no need to quote the key names, such as variable: "FillLevel" vs "variable": "FillLevel". But that is not related to any of your problems.)

Is this only about (not) seeing the value in the popover, while the location on the map itself is correct? Or is the pin on longitude zero somewhere?

That makes sense, given the intermediate result you showed:

intermediate results

So the question is how did it get to that intermediate result.

Please add a link here. And please report back here too, which I guess you’re planning to. :slight_smile: