Defining Methods

The Methods tab is used to define methods for the thing definition. Methods define the interface to functions that are implemented in a gateway trigger (using TR50 Method trigger event type) or are implemented in an application. The following are the possible ways a method gets called:

  • A gateway trigger, 
  • From an application, 
  • From the thing's page in the Management Portal, or 
  • From a cloud trigger within the IoT Portal.

Defining Methods is a sub task while Creating a Thing definition or Editing a Thing definition. To define a method within the Methods tab, do the following:

  1. Click on the to add a new method
    The New method definition screen appears that will allow you to define the new method
  2. Enter the Key of the method definition. For more information on defining the key, see Field Formats and Limitations
    The Key must correspond to a trigger key or a method key.
  3. Enter the Name of the method definition
  4. Click the Handler drop-down and do one of the following:
    1. Select Method - If you want to execute a method on a gateway or any other TR50 application with the corresponding key selected in Step 2
    2. Select Trigger - If you want to execute a cloud trigger (must be triggered through a method.exec event) with the corresponding key selected in Step 2. For a detailed example on executing a trigger from a method, see Invoking a Trigger from a Method.
  5. Enter the Default ack timeout (seconds) - The number of seconds the method needs to wait for the response before timing out.

    The Default ack timeout cannot exceed a maximum of 300 seconds. If the Default ack timeout is not set, then the Default method timeout defined in Updating user profile is used. If neither Default ack timeout nor Default method timeout is set then the method times out in 30 seconds.

  6. Enter the Security tags that will control the access by a user or application trying to execute the method. The user or application must have a role that has the same <update> security tag associated with it in order to execute a method with an <update> security tag associated with it. For more information on Security Tags, see Using Security Tags
  7. To define a Notification variable, click on theNotification variables are input parameters passed to the method.
    The Notification variable is a input variable send from the deviceWISE Cloud to either a cloud Trigger or to the gateway or TR50 application where it gets executed.

    1. Enter the Key to the notification variable
    2. Enter the Name of the method notification variable definition
    3. Enter the Count, the count that denotes the array with the number of elements in the input variable
    4. Enter the Length. The length of input Type variable.
    5. Select the Type of your input variable
    6. Select the UI type for the notification variable from the UI Type drop-down. This is used to model the method in the Thing's page while executing the method from the Management Portal.  The options includes:
      • Text box
      • Multilinetext box
      • Check box
      • Select
      • Multi-select
      • Tag input box
  8. To define a Completion variable, click on the . Completion variables are returned parameters from executing a method.
    1. Enter the key of the completion variable
    2. Enter the Name of the method completion variable.
    3. Enter the Count. The count is returned array.
    4. Enter the Length. The length of data that will be returned.
    5. Select the Type of data that will be returned
    6. Select the UI type for the completion variable from the UI Type drop-down. This is used to model the method in the Thing's page while executing the method from the Management Portal.  The options includes:
      • Text box
      • Multilinetext box
      • Check box
      • Select
      • Multi-select
      • Tag input box
  9. (optional)Click on the to list all the methods from all the Thing definitions. You will be able to select the method you want and copy it to your Thing definition.    

Related Topics Link IconRelated Topics