IoT Central API Device State

Ellis Dawson 26 Reputation points
2022-04-28T11:48:31.79+00:00

We are using IoT Central and telemetry is happily being stored. If we use the API to query telemetry we get results back as follows:
{
"$id": "BD0B671C-A3EF-492B-AEE0-066BD22A9EA2",
"$ts": "2022-04-28T11:29:00.741Z",
"Heartbeat": "Pulse"
}

If I query with the following I get back our Error Events
Query
{
"query" : "SELECT Error FROM dtmi:modelDefinition:bennamann:weatherstationtest;1"
}
Result

{
    "results": [
        {
            "Error": "Generator failed to start"
        },
        {
            "Error": "Loading Pump stalling"
        }
    ]
}

However, if I then try to add the timestamp in either the order by or in the select we get the timestamp but not the actual error state.
Query

{
    "query" : "SELECT $ts,Error FROM dtmi:modelDefinition:bennamann:weatherstationtest;1 ORDER BY $ts"
}

Result

"results": [
        {
            "$ts": "2022-03-29T11:50:36.682Z"
        },
        {
            "$ts": "2022-03-29T11:50:42.925Z"
        },
        {
            "$ts": "2022-03-29T11:52:50.782Z"
        },
        {
            "$ts": "2022-03-29T11:52:57.018Z"
        },
        {
            "$ts": "2022-03-29T11:53:09.95Z"
        },
        {
            "$ts": "2022-03-29T11:53:16.622Z"
        },
        {
            "$ts": "2022-03-29T11:55:36.681Z"
        },
        {
            "$ts": "2022-03-29T11:56:42.927Z"
        }
    ]
}

Any ideas why this occurs and how we would get our Error Events with timestamp against them?

Azure IoT Central
Azure IoT Central
An Azure hosted internet of things (IoT) application platform.
359 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dom 1,631 Reputation points Microsoft Employee
    2022-04-28T13:32:32.93+00:00

    If Error is defined as an Event in the device template, the implication is that an Error value isn't included in every telemetry value sent from the device. To select telemetry messages that include an Error value, try:

    {
      "query": "SELECT $ts, Error FROM dtmi:azurertos:devkit:hlby5jgib2o  WHERE Error <> ''"
    }
    
    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful