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

Device IDs/Tags

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.

Devices

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.

Filter Attributes

Device State Trigger Filter 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 …: One of the attributes selected can fire this trigger.
  • Any but the following …: These attributes selected will not fire this trigger.

Filter Payload Age

Device State Trigger Filter Payload 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": {}
}