Skip to main content

Dear Trackunit Support,

I am working on retrieving data for input signals (INPUT1 and INPUT2) for a specific day using the GraphQL API, but I am unsure if I am using the correct query parameter.

I am currently using the following query;

query GetInngangData2 {

  asset(id: "00000000-0000-0000-0000-000004635074") {

    assetId

    timeSeries {

      rangeQuery(

        start: "2025-02-04T00:00:00.000Z"

        end: "2025-02-05T00:00:00.000Z"

        query: "INPUT1,INPUT2"

        step: "PT1H"

      ) {

        data {

          ... on TimeSeriesMatrixData {

            result {

              values {

                timestamp

                value

              }

            }

          }

        }

      }

    }

  }

}

I am trying to retrieve input 1 and input 2 values for each hour (PT1H) within a day.

My questions:

  1. Are "INPUT1" and "INPUT2" the correct metric names for these input values, or should I use different names?
  2. Are there any specific permissions required to access these values?
  3. Are there any alternative recommended approaches to retrieving this type of data via GraphQL?

I appreciate any guidance you can provide.
Thank you in advance!

Best regards,

Erling Ryger

Hello ​@Ryger,

There are 2 ways you can get the values through GQL, depending on what your needs are:

  1. through asset → advancedSensor → historical query you’ll get raw data (all available data samples)
  2. through asset → timeSeries → rangeQuery you can also get historical data with specified step interval

Option 1 - example

query GetInngangData2 {
asset(id: "00000000-0000-0000-0000-000004635074") {
assetId
advancedSensors {
historical(
input: {ids: {sensorType: INPUT1, type: REPORT_MESSAGE_SENSOR}, interval: {to: "2025-03-07T00:00:00.000Z", from: "2025-03-01T00:00:00.000Z"}}
) {
edges {
node {
data {
... on SensorBooleanValue {
booleanValue
timestamp
}
}
}
}
}
}
}
}

 

Option 2 - example

query GetInngangData2 {
asset(id: "00000000-0000-0000-0000-000004635074") {
assetId
timeSeries {
rangeQuery(
start: "2025-03-01T00:00:00.000Z"
end: "2025-03-07T00:00:00.000Z"
query: "advanced_sensor_input_1"
step: "PT1H"
) {
data {
... on TimeSeriesMatrixData {
result {
values {
timestamp
value
}
}
}
}
}
}
}
}

Alternatively you can use query: "{__name__=~\"advanced_sensor_input_1|advanced_sensor_input_2\"}" to request both values in 1 request.

This part of GQL API has its roots in Time Series API better documented here: https://developers.trackunit.com/reference/time-series-introduction

There is no time-series level permissions, if you have access to GraphQL and Time Series API you can query all available metrics.

 

Best regards,

Bartek Orlowski


Reply