(Solved)Unable to visualizing real data on Dashboard

Hello TagoIO Support Team, I have fixed all the related issues to connect an external device to TagoIO platform, but still unable to visualizing the real data from the Bucket on to the dashboard. Please refer to an attachment for the screenshot to be reviewed by you for further assistance on this. Thanking you.

Hi @wavelinknetworks,
To you see data coming from you MQTT device. You will need to create two more things:
1- Action to receive on your custom MQTT topic, see here how to do that.
2- Create a payload parser for your payload data.

When you have it done, you will can print your data on the dashboards.

NOTE: If you have your payload parser done. Just create the action MQTT topic, as described in the step 1.

The Payload Parser is just a function that runs before trying to store your data to your bucket.

Try this code and change/improve it to match your needs:

 // prevent the code from running for normal inpputed variables (like from analysis or dashboards)
 const mqtt_data = payload.find(data => data.variable === "payload" && data.metadata && data.metadata.mqtt_topic);

 // Suppose that mqtt_data = [{ variable: "payload", value: "0.5,1.5", metadata: { mqtt_topic: "temp hum"} } ];
 console.log(mqtt_data); // outputs content to Live Inspector.

 if (mqtt_data) {
   // Split the topic by the "/", to result in an array
   const splited_topic = mqtt_data.metadata.mqtt_topic.split("_");
   // splited_topic is [ 'temp', 'hum' ]
   const splitted_value = mqtt_data.value.split(",");
   // splited_topic is [ '0.5', '1.5' ]

   // generate a serial based on timestamp. If you add more
   // than one data, the serial will make sure it shows in the same line
   // in a dynamic table widget for example.
   const serie = String(new Date().getTime());

   // now you should start building your normalized data to TagoIO following specifications at https://docs.tago.io/en/articles/34-sending-data
   // remember to cast strings to Number to prevent issues in the future, like showing data in a chart.
   payload = [
    { variable: splited_topic[0], value: Number(splitted_value[0]), serie },
    { variable: splited_topic[1], value: Number(splitted_value[1]), serie }

Hello Vitor, Please let me assist further by changing/entering the required details in your provided Payload Parser code with my device’s real time publishing raw payload data as mentioned in the attached image to be reviewed by you and enter in Payload Parser code to visualizing it on the dashboard. Thanks for keep supporting.

I edited the parser above, copy it again and it should work for you.

I uploaded your updated payload parser code, but it didn’t work. No real data visualization from bucket at all.

It seems to be working. As you can see in the “Result of [device] payload parser” there are two variables being stored, with name “temp” and “humidity”.

You need to change your dashboard to get those variables instead of “payload”.

Hello Vitor,

Thats Great! Finally it did work.

Next, please let me know how to show units along with the displaying readings for temperature in (deg. C) and (%) for humidity? Thanks for keep supporting.

You need to edit your payload parser and add the unit parameter to the JSON objects:

    { variable: splited_topic[0], value: Number(splitted_value[0]), serie, unit: "C" },
    { variable: splited_topic[1], value: Number(splitted_value[1]), serie, unit: "%" }
1 Like

Hello Vitor, Great! Finally its done. Thank you for your support.

1 Like