Triggers
There are three kinds of rule event based triggers. You can either trigger an action on a fired event, a state changed event or a device activity event. This allows you to write complex matching, filtering, state or activity processing rules on your data and route chosen data to the desired actions.
An event trigger is represented by the id of the rule that will emit the corresponding event. You can specify multiple rule identifiers as trigger for one action policy.
Format
| Type | Triggered | Filtering criteria |
|---|---|---|
deviceActivity |
on device activity event (example : activity state transition from "SILENT" to "ACTIVE") |
"deviceIds": a list of device identifiers (as String) to be monitored, |
matchingFired |
on simple event processing firing event |
"ruleIds": a list of firing rule identifiers (as String) |
stateChange |
on state change event |
"ruleIds": a list of state processing rule identifiers (as String) |
| When several criterias are present in a filter, they are combined with a AND boolean logic. OR operator is applied between each elements inside filter’s list. |
Examples
{
"id": "6c95837b-251d-41d8-95f1-42facdf8e71e",
"name": "some_user_friendly_name",
"enabled": true,
"triggers": {
"deviceActivity": {
"version": 1,
"filter": {
"deviceIds" :["device_identifier"],
"ruleIds": ["activity-change-event-e64528bd-490e-405f-9c7f-0b80eda62ce5"]
}
}
},
"actions": {
"emails": [{
"to": ["to@orange.com"],
"contentTemplate": "Event for Rule {{activityRule.name}} and device {{deviceAdditionalInfo.deviceName}}"
}],
"sms": [],
"httpPush": [],
"fifoPublish": []
}
}
{
"type": "deviceActivity",
"version": 1,
"deviceId": "device_identifier",
"deviceAdditionalInfo": {
"deviceName": "deviceName",
"groupPath": "groupPath"
},
"activityRule": {
"id": "activity-change-event-e64528bd-490e-405f-9c7f-0b80eda62ce5",
"name": "name"
},
"state": "SILENT",
"timestamp": "2019-08-26T00:00:00.000Z",
"numberOfAlarmReminders": 0
}
{
"id": "6c95837b-251d-41d8-95f1-42facdf8e71e",
"name": "some_user_friendly_name",
"enabled": true,
"triggers": {
"stateChange": {
"version": 1,
"filter": {
"ruleIds": ["state-change-event-6a9a1b48-72da-4405-a65e-7e482abbe826"]
}
},
"actions": {
...
}
}
{
"type": "stateChange",
"version": 1
"tenantId": "it-2f2ab8e7-bd58-4423-adc1-efcba36faaa8",
"stateKey": "stateKey",
"previousState": "previousState",
"newState": "newState",
"timestamp": "2019-09-02T14:08:04.337Z",
"stateProcessingRuleId": "state-change-event-6a9a1b48-72da-4405-a65e-7e482abbe826",
"data": {
"streamId": "streamId",
"timestamp": "2019-09-02T14:08:04.334Z",
"value": {
"string": "input",
"integer": 0
},
"type": "dataMessage",
"version": 1
}
}
{
"id": "6c95837b-251d-41d8-95f1-42facdf8e71e",
"name": "some_user_friendly_name",
"enabled": true,
"triggers": {
"matchingFired": {
"version": 1,
"filter": {
"ruleIds": [
"firing-event-961a4bb5-c244-4df8-88cd-80c4e03c42b9", "10000000-0000-0000-0000-000000000001"
]
}
},
"actions": {
...
}
}
{
"type": "matchingFired",
"version": 1,
"tenantId": "it-cbe67009-7653-4c5e-9762-58b2afe0240d",
"timestamp": "2019-09-02T13:55:17.433Z",
"firingRule": {
"id": "firing-event-961a4bb5-c244-4df8-88cd-80c4e03c42b9"
},
"matchingContext": {
"tenantId": "it-cbe67009-7653-4c5e-9762-58b2afe0240d",
"timestamp": "2019-09-02T13:55:17.433Z",
"matchingRule": {
"id": "cc76a37a-1b18-45f9-8356-7733d9ccbc3b"
},
"data": {
"streamId": "streamId",
"timestamp": "2019-09-02T13:55:17.426Z",
"value": {
"string": "debug",
"integer": 100
},
"type": "dataMessage",
"version": 1
}
}
}