trigger.create

 The trigger.create command is used to create a new cloud trigger.

TR50 Request

{
  "cmd": {
    "command": "trigger.create",
    "params": {
      "name": "My Trigger",
      "eventType": "alarm.change",
      "event": {
        "thingKey": "corolla",
        "thingTags": "car"
      },
      "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

Off

Do not report any trigger events.

On

Report all trigger events. All trigger events are reported for the next 30 days and afterward reporting mode automatically switches to the default On failure mode.

On failure (default)

Report only failed events.

event

Object

 

The event object. Parameters depend on the eventType. For more information, see trigger.event.list.

actions

Object

Yes

Object containing action objects indexed by non-zero integers cast as strings. Parameters depend on the action type. For more information, see trigger.action.list.

The Actions Parameter table contains more information on each string or object in the action. Each trigger requires at least one action.

canvas

Object

 

The canvas request object contains positioning information for the event and the success and failure ends. Default values are created if this information is missing and the trigger is loaded in the trigger GUI.

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.

TR50 Response

If the command is sent successfully a success message is returned with the ID of the trigger. Otherwise, an error and error message are returned.

{
  "cmd": {
    "success": true,
    "params": {
      "id": "58b43ad4b2157c704f26005f"
    }
  }
}

Response Parameters

Name

Type

Description

id

String

The unique identifier of the new trigger.