Reading a json object data in a dashboard table

Hello everyone,

I’m using openremote to read data from a gateway using MQTT, what this gateway does is to detect nfc cards and send their info to the gateway which in return sends it to OR in this format:

{
    "msg": "advData",
    "gmac": "gatewayMac",
    "obj": [
        {
            "type": 4,
            "dmac": "devicemac",
            "uuid": "uuid",
            "majorID": majorId,
            "minorID": minorId,
            "refpower": -59,
            "rssi": -56,
            "time": "2024-01-09 12:30:28.682"
        },
        {
            "type": 4,
            "dmac": "devicemac",
            "uuid": "uuid",
            "majorID": majorId,
            "minorID": minorId,
            "refpower": -59,
            "rssi": -56,
            "time": "2024-01-09 12:30:28.682"
        },
     ..............
    ]
}

since threre will be a lot of devices(cards) scanned, I want to organize these info in a table like this:
columns: |gmac|dmac|uuid|majorID|minorID…
line1 : |gmac1|dmac1|uuid1|majorID1…

I tried doing this with the regular table, but I couldn’t, and I was about to start creating a custom UI widget when I instead came to ask if there’s a better/simpler alternative.

thanks in advance

First of all, welcome to the forum! :partying_face:
Great to see experiments with the insights page!

With our current table widget you select a list of attributes, and the assets that should be listed.
It will show a table with a similar format you’re describing; the device names in rows and its properties
shown in the columns.

I assume you store this JSON data inside an attribute?

In that case you can use the Attribute links configuration item to write the JSON from
one attribute to the other. See here an example from my own Manager instance;

.
Example JSON payload to use in the configuration item;

[
  {
    "ref": {
      "id": "FILL_ASSET_ID_HERE",
      "name": "FILL_ATTRIBUTE_NAME_TO_WRITE_THIS_TOWARDS"
    },
    "filters": [
      {
        "type": "jsonPath",
        "path": "$.obj[0].time",
        "returnFirst": true,
        "returnLast": false
      }
    ]
  }
]

.
From there you can create a table on the Insights page.
Select the correct asset type, and its attributes, and then it should look like this;

1 Like

I would like to thank you for your response,
allow me to paint the full picture:

  • what I have:
    .an asset of type “Gateway Asset” that has an attribute of type “JSON Object”
    .a JSON object that has nested objects represents each device
{
    "msg": "advData",
    "gmac": "gmac",
    "obj": [
        {
            "type": 4,
            "dmac": "dmac",
            "uuid": "uuid",
            "majorID": 5,
            "minorID": 11810,
            "refpower": -59,
            "rssi": -56,
            "time": "2024-01-09 12:30:28.682"
        },
        {
            "type": 4,
            "dmac": "dmac",
            "uuid": "uuid",
            "majorID": 4,
            "minorID": 48791,
            "refpower": -59,
            "rssi": -59,
            "time": "2024-01-09 12:30:28.718"
        },
        {
            "type": 4,
            "dmac": "dmac",
            "uuid": "uuid",
            "majorID": 6,
            "minorID": 64349,
            "refpower": -51,
            "rssi": -43,
            "time": "2024-01-09 12:30:28.718"
        },
        {
            "type": 4,
            "dmac": "dmac",
            "uuid": "uuid",
            "majorID": 4,
            "minorID": 48814,
            "refpower": -59,
            "rssi": -59,
            "time": "2024-01-09 12:30:28.799"
        }
    ]
}
  • what I want to do:
    as you can see under the “obj” key, I want to ‘loop and pars’ through those objects and list them in a table like the following:

which I don’t think possible with the current widget.
also among the attributes available for selection, the only ones available are the pre defined ones and not the custom ones.

I’m currently trying to implement this solutions through a custom widget, so I would be grateful for any help/guidance/info

thanks again for your help

Thanks for the clarification!
Yeah that’s indeed a scenario where we don’t have a widget for.
Especially since most of them require the data to be stored in separate attribute.
Would be nice to parse that JSON array into individual assets,
but I don’t know whether this is possible.

.
On the other hand, building a custom widget is a possible solution to the problem indeed.
Feel free to check the documentation I wrote on the topic;

Be aware that using them in a ‘custom project’ structure is quite tricky at the moment.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.