IoT Central application device template

Lukas Rieder 45 Reputation points
2023-10-17T17:55:49+00:00

Hello,

I am using the Dragino LSE01 soil EC sensor. I am sending data from The Things Network (TTN) to Azure IoT Central. The LORAWAN payload is already decoded and human-readable. Unfortunately, the sent data is inside a big nested JSON object. I would know many ways how to extract those Telemetry variables that I am interested in with a script. But how can I access the internal objects in the nested JSON object with the IoT Central user interface for a device template?

So far I can just extract the upper layer variables and not the ones inside those.

I am just able to get the top-level 'uplink_message' with the user interface when I set name=uplink_message.

How can I get the variable 'conduct_SOIL' from the following message for example?

What do I need to type inside the 'name' box in the IoT Central device template UI

Screenshot 2023-10-17 195428

"uplink_message": {
      "session_key_id": "AYs9ZcEXn0WB6R0HO10ObQ==",
      "f_port": 2,
      "f_cnt": 357,
      "frm_payload": "C0wAAAAACQgAABA=",
      "decoded_payload": {
        "Bat": 2.892,
        "TempC_DS18B20": "0.0",
        "conduct_SOIL": 0,
        "temp_SOIL": "23.12",
        "water_SOIL": "0.00"
      },


Azure IoT Central
Azure IoT Central
An Azure hosted internet of things (IoT) application platform.
355 questions
{count} votes

Accepted answer
  1. LeelaRajeshSayana-MSFT 13,871 Reputation points
    2023-10-19T23:40:59.9833333+00:00

    Hi @Lukas Rieder I'm glad that you were able to resolve your issue and thank you for sharing your solution so that others experiencing the same thing can easily reference this! I am reposting your solution in case you'd like to accept the answer.

    Issue:

    Could not access the nested JSON data from the telemetry and display it on the IoT central variables.

    Solution:

    A quick fix for small device numbers (because it requires a lot of individual typing for each sensor in the UI) is to use mapped aliases, thereby extracting the elements from the JSON objects. This will extract those aliases in the telemetry data directly without putting them in nested objects. It allows to access these variables directly with a device template.

    User's image

    Then those variables appear in the telementry "top layer". which can be renamed with the device template and used for creating plots.

    User's image

    If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.

    I hope this helps!

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Sander van de Velde 29,776 Reputation points MVP
    2023-10-17T18:24:31.2733333+00:00

    Hello @Lukas Rieder,

    Welcome to this moderated community forum.

    I'm aware of the TTN message uplink message structure.

    Yes, it's quite complex (although you can probably ignore parts of it) but the trick is to map it to the device model.

    I have no elaborate experience with IoT Central but perhaps this will work...

    It seems IoT Central supports DTDL V2 so the nested parts of the TTN message should map to (nested) objects.

    I'm not sure if the model editor in IoT Central can offer enough manipulation options.

    Is it possible to build a device model in a (JSON) editor outside IoT Central and upload it from there?

    Check out the IoT Central CLI for creating a device template.

    You can also validate DTDLs outside IoT Central so you are better prepared to build your device template.

    Please let us know if this works for you.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.