Application

Device: State Trigger Node

The Device: State Trigger will fire a workflow whenever one or more devices report state.

Device State Trigger

Node Properties

Devices

The Device: State Trigger can be configured with one or more specific devices, a selection of tags, or both. When a device that matches anything in the selection reports state, the workflow will trigger. See the device query documentation for more info about how ID and tag matching works.

Device State Trigger Config

In the above example, the workflow will be triggered whenever any device with the floor tag set to 2 reports state, as well as whenever devices FM00000001A or FM00000002A report.

Batch Behavior

Optionally, you may configure how the Device State: Trigger deals with batch reporting. By default, a trigger will fire for single reports and also fire once per item in a batch report.

Device State Batch Behavior

Trigger On

  • Both individual and batch reports: The trigger will fire for state reported both as individual items and for batches. This is the default.
  • Only individual reports: The trigger will fire only for individual state reports. Batch reports will be ignored.
  • Only batch reports: The trigger will fire only for batch state reports. Individual state reports will be ignored.

Batch Report Behavior

If the trigger is configured to fire on batch reports, there are then two different behavior options.

  • Trigger per item in a batch report: When a batch report is received, the trigger will fire for each individual item in the batch report.
  • Trigger once for a batch report: When a batch report is received, the trigger will only fire once, with the entire batch report placed on the data payload property as an array. NOTE: The Filter By Attributes and Filter By Age options do not apply in this case.

Filter By Attributes

Device State Trigger Filter By Attributes

Optionally, you may only fire the Device State: Trigger if certain attributes are included (or are not included) in the state report. You can filter by:

  • Any …: All attributes fire this trigger.
  • Only the following …: The payload must contain one of the selected attributes to fire this trigger.
  • Any but the following …: The payload must contain at least one attribute not selected to fire this trigger.

Filter By Age

Device State Trigger Filter By Age

Optionally, you may also filter device state changes by the device’s state payload age (time field value relative to now). Thus, if the device state was reported with a time older than this value, it will not fire the trigger. Set the maximum age of the payload by seconds, minutes, hours, or days.

Use cases for filtering the payload age:

  • If a device is batch reporting its state data, this action will trigger a workflow for each state within the batch. If you only care about the most current update, you can use this option to ignore all updates but the most recent.
  • With the use of timestamps, you can overwrite previous states but you may want to filter the overwrites when triggering.

Payload

The payload will include the triggering device’s state on the data field. The payload will only include the attributes currently reported by the device. For example, if the device has four attributes configured, but only reports state containing one, this payload will only include the one attribute. In the general case, a device state workflow payload will look like the following:

{
  "time": <time of the event>,
  "data": {
    "attribute-name": value,
    "attribute-name": value,
    ...
  },
  "applicationId": <id of the current application>,
  "applicationName": <name of the current application>,
  "triggerId": <id of the triggering device>,
  "triggerType": "deviceId",
  "deviceTags": {<any tags for the device>},
  "deviceName": <the device name>,
  "flowId": <id of the current workflow>,
  "flowName": <name of the current workflow>,
  "globals": <object of workflow globals>
}

For the example workflow above, a specific payload for a triggered workflow might look like this:

{
  "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
  "data": {
    "current": 10,
    "on": true
  },
  "applicationId": "568beedeb436ab01007be53d",
  "applicationName": "Embree",
  "triggerId": "56c8967bb8df0f0100d629120",
  "triggerType": "deviceId",
  "deviceTags": {
    "floor": ["2"],
    "location": ["warehouse1"]
  },
  "deviceName": "My Factory Device",
  "flowId": "56c74add04d0b50100043381",
  "flowName": "Power Consumption Warning",
  "globals": {}
}

For a trigger configured to fire once for an entire batch report, the payload might look something like this:

{
  "time": Fri Feb 19 2016 17:26:00 GMT-0500 (EST),
  "data": [
    {
      "time": Fri Feb 18 2016 17:00:00 GMT-0500 (EST),
      "data": { "current": 10, "on": true }
    },
    {
      "time": Fri Feb 18 2016 17:01:00 GMT-0500 (EST),
      "data": { "current": 11, "on": true }
    },
    {
      "time": Fri Feb 18 2016 17:02:00 GMT-0500 (EST),
      "data": { "current": 0, "on": false }
    }
  ],
  "applicationId": "568beedeb436ab01007be53d",
  "applicationName": "Embree",
  "triggerId": "56c8967bb8df0f0100d629120",
  "triggerType": "deviceId",
  "deviceTags": {
    "floor": ["2"],
    "location": ["warehouse1"]
  },
  "deviceName": "My Factory Device",
  "flowId": "56c74add04d0b50100043381",
  "flowName": "Power Consumption Warning",
  "globals": {}
}