trigger.create
The trigger.create command is used to create a new cloud trigger.
{
"1": {
"command": "trigger.create",
"params": {
"name": "My Trigger",
"eventType": "alarm.change",
"event": {
"thingKey": "corolla",
"thingTags": "cars"
},
"firstAction": "3",
"actions": {
"2": {
"canvas": {
"top": "213",
"left": "195",
"success": "success-end0"
},
"type": "method.exec",
"params": {
"ackTimeout": "safddsa",
"method": "publish_property",
"thingKey": "testtestte",
"thing_def": "561e8c02681fdc78ee0c24cd"
},
"routes": {
"failure": "",
"success": "$endSuccess"
}
},
"3": {
"canvas": {
"top": "181",
"left": "-189"
},
"type": "google.bigquery.publish",
"params": {
"incAttrs": "true",
"incLoc": "true",
"incProps": "true",
"table": "ffdsa"
},
"routes": {
"failure": "",
"success": "2"
}
}
},
"canvas": {
"event": {
"top": "37",
"left": "-90"
},
"success-end": {
"0": {
"top": "344",
"left": "93"
}
}
}
}
}
}
Request Parameters
Name | Type | Required | Description |
---|---|---|---|
name | String | Yes | The name of the trigger. |
desc | String | The description of the trigger. | |
eventType | String | Yes | The trigger event type. |
reportMode | String | The trigger reportMode controls when
a trigger report is generated and
reported.
Off - The generation of the trigger reports is disabled. On - A trigger report is generated for each trigger execution of the trigger. When On is selected the all trigger events are reported for the next 30 days and later it automatically switches to the default On failure mode. On failure(default) - A trigger report is generated only when a trigger fails while executing. |
|
event | Object | It refers to the event object. Parameters depend on the eventType. For more information on event objects, see trigger.event.list. | |
actions | Object | Yes | Object containing action objects indexed by non-zero integers cast as strings. Parameters depend on each action's type. Refer to the trigger.action.listcall. The Actions Parameter table contains more information on each string or object in the action. Each trigger requires at least one action. |
firstAction | Sting | Yes | The numeric string representing the first action to execute after the event. |
canvas | Object | The canvas request object contains positioning information for the event and the success/failure ends. Default values are created if this information is missing and the trigger is loaded in the trigger GUI. | |
activeWindowTz | String | The timezone that the time portion of the activeWindow defines. Wikipedia is capable of providing a list of possible timezones. | |
activeWindow | Object |
This is a data structure defining the days and hours in which a trigger is allowed to execute. If a trigger is always allowed to execute, this parameter should be omitted. The field is a key-value data structure with is a string key followed by the boolean value true. The key is composed of three elements separated by a colon ":". The first element of the key are the letters "DH" which stand for day and hour. The second element is the day of the week, where zero "0" is Sunday, one "1" is Monday, two "2" is Tuesday, three "3" is Wednesday, four "4" is Thursday, five "5" is Friday, and "6" is Saturday. The third and final element is the hour during which the trigger is allowed to fire (in 24 hour format), where 0 is midnight, 12 is noon, and 23 is 11pm. For a trigger that is only allowed to fire on Wednesday after 8am and before 6pm (as defined by the activeWindowTz parameter), the resulting JSON would be:
{
"DH:3:8": true, "DH:3:9": true, "DH:3:10": true, "DH:3:11": true, "DH:3:12": true, "DH:3:13": true, "DH:3:14": true, "DH:3:15": true, "DH:3:16": true, "DH:3:17": true, } "17" in the last data line represents 5pm. This trigger would be allowed to start executing before 6pm on Wednesday, but not on or after 6pm. |
Actions Parameters
Name | Type | Required | Description |
---|---|---|---|
canvas | Object | JSON object consisting of top and left values. Positions the node on the drawing canvas. Units are in pixels. Values are relative to the last position of the node or the top left of the drawing canvas if the node has never been moved. With zooming and manual positioning, values can even become negative. Also, since there can be multiple success and failure ends, these are specified in the canvas object. | |
type | String | Yes | Action type |
params | Object | Parameters specific to each action object. | |
routes | Object | Positioning information for the action object. |
If the command is sent successfully a success message is returned with the ID of the trigger. Otherwise, an error and error message will be returned.
{
"1": {
"success": true,
"params": {
"id": "58b43ad4b2157c704f26005f"
}
}
}
Response Parameters
Name | Type | Description |
---|---|---|
id | String | The unique identifier of the new trigger. |