Data: Gauge Query Node

The Data: Gauge Query Node allows a workflow to retrieve and aggregate recent state data for one or more attributes across one or more devices.

Gauge Query Node

Node Properties

The configuration for the Data: Gauge Query Node is similar to the Gauge Dashboard Block. There are three major components: Device Selection, Query Configuration, and Result Path.

Device Selection

Gauge Query Node Device Selection

The first step is selecting the devices to query. There are several options for selecting devices:

  • Specific Devices and/or Tags: Allows you to either select specific devices and tags, or define a payload path to pull one or more Device IDs off of the current workflow payload to query.
  • Parent System ID: Queries all devices with a specified parent system or all devices that have no parent system. This field is templatable.
  • Experience Group ID: Queries all devices that are associated with a specified Experience Group. This field is templatable.
  • Experience User ID or Email: Queries all devices that are associated with the specified Experience user. This field is templatable.
  • Advanced Query: Allows you to construct your own device query.

In the example above, all devices associated with the Experience group ID found at the {{working.experienceGroupID}} workflow path are queried.

Query Configuration

Gauge Query Node Config

The Data: Gauge Query Node also requires the following:

  • Attribute: Select one or more attributes to query. Choosing a single attribute versus multiple attributes will affect the format of the final result.
  • Time Range: Defines the time range to query data over. Can be set to Custom to allow for a duration and end time to be entered explicitly or using a template. Default is Last received data point.
  • Aggregation: This templatable input allows you to select an aggregation method to be used. Depending on the aggregation, there may be additional fields to configure. When querying a single device and requesting only the last data point, no aggregation is needed (since there is only a single value).
  • Per Device Results: Allows you to choose between a single result aggregated across all matching devices, or a result per matching device. This choice will affect the format of the final results.

In the above example, the attribute height is averaged over the last 3 hours for the selected devices.

Result

Gauge Query Node Result

Once the query is configured, the node needs a payload path to know where to store the result on the current workflow payload. In the above example, the result is stored at working.gaugeQueryResult. The structure of the result can be very different depending on the configuration options chosen.

Aggregating Across Devices

For A Single Attribute

The value placed at that path is an object with two properties:

  1. value - the value from the query.
  2. time - the time value for the queried value.
{
  "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
  "value": 7.175925925925926
}

The time field is most useful when using the node to query the “Last received data point” for an attribute, as the time value is the time of that data point.

For Multiple Attributes

The result will be an object of attribute names mapping to objects of the time/value form, like so:

{
  "voltage": { "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST), "value": 48.8 },
  "amps": { "time": Fri Feb 19 2016 17:27:00 GMT-0500 (EST), "value": 18.8 }
}

Aggregating Per Device

For A Single Attribute

The result will be an object of device IDs mapping to objects of the time/value form, like so:

{
  "575ecf887ae143cd83dc4aa2": { "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST), "value": 48.8 },
  "575ef5c97ae143cd83dc4aac": { "time": Fri Feb 19 2016 17:27:00 GMT-0500 (EST), "value": 18.8 }
}
For Multiple Attributes

The result will be an object of device IDs mapping to attribute names mapping to objects of the time/value form, like so:

{
  "575ecf887ae143cd83dc4aa2": {
    "voltage": { "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST), "value": 48.8 },
    "amps": { "time": Fri Feb 19 2016 17:27:00 GMT-0500 (EST), "value": 18.8 }
  },
  "575ef5c97ae143cd83dc4aac": {
    "voltage": { "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST), "value": 0 },
    "amps": { "time": Fri Feb 19 2016 17:27:00 GMT-0500 (EST), "value": 0 }
  },
}

Node Example

The payload after the execution of the example Data: Gauge Query Node above looks like:

{
  "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
  "working": {
    "gaugeQueryResult": {
      "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
      "value": 7.175925925925926
    }
  },
  "globals": { },
  "applicationId": "568beedeb436ab01007be53d",
  "applicationName": "Embree",
  "triggerId": "56c794a06895b00100cbe84c",
  "triggerType": "timer",
  "flowId": "56c794a06895b00100cbe84c",
  "flowName": "Query Data"
}

Node Errors

If no devices are found using the query or no data has come from those devices, an empty object is placed at the payload path.

Was this page helpful?


Still looking for help? You can also search the WEGnology Forums or submit your question there.