Data mapping accessing key with dot notation #1976
-
I'm trying to connect KEPServerEX 6 with ThingsBoard using MQTT. Above is message sent. I can access the "timestamp" key just fine, using ThingsBoard Gateway MQTT Connector's Data Mapping. However, the device keys have dot notations, makng it difficult to map to them on ThingsBoard. I tried ${values.SIEMENS.S7-1200.R1}, ${values.['SIEMENS.S7-1200.R1']}, ${values[]["SIEMENS.S7-1200.R1"]} and none of it worked. I tried using JSONPath with $.values[]["SIEMENS.S7-1200.R1"] and it just prints the code on the device's latest telemetry's value column. I have also confirmed $.values[*]["SIEMENS.S7-1200.R1"] working outside of ThingsBoard. Are keys with dot notations supported or not? Is there any way to use traditional JSONPath code to map to them? If so, how do I do it? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Dot-notations weren't the issue, ThingsBoard not parsing every JSON object is. Basically, when connecting KEPServerEX 6 with ThingsBoard, I can't use the message template below: because ThingsBoard doesn't accept it, which I misunderstood as ThingsBoard don't work with dot notations. However, the below message template works: but it printed in the Latest Telemetry section as "key: values" and "value: {"TAGNAME1":VALUE1,...}", and I can't access the nested objects. Apparently, you can solve it using the "data post-processing" function for keys in widgets, as shown here: You can also use the script node in the Transformation section of the Rule Chain, connecting the "send telemetry" tag with the node before saving it to time series inside the Root Rule Chain. Below s the Javascript I use in the node to achieve this result: The above Javascript parsed everything in a JSON object, allowing access to it. This only work for one level of JSON objects, which means, if there's another JSON or a nested object inside of a JSON, it might not work. |
Beta Was this translation helpful? Give feedback.
Dot-notations weren't the issue, ThingsBoard not parsing every JSON object is. Basically, when connecting KEPServerEX 6 with ThingsBoard, I can't use the message template below:
because ThingsBoard doesn't accept it, which I misunderstood as ThingsBoard don't work with dot notations. However, the below message template works:
but it printed in the Latest Telemetry section as "key: values" and "value: {"TAGNAME1":VALUE1,...}", and I can't access the…