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:
- Click on the to add a new
method
The New method definition screen appears that will allow you to define the new method - 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. - Enter the Name of the method
definition
- Click the Handler drop-down and do
one of the following:
- 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
- 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.
- 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.
- 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
- To define a Notification
variable, click on the. Notification
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.
- Enter the Key to the
notification variable
- Enter the Name of the method notification variable definition
- Enter the Count, the count that denotes the array with the number of elements in the input variable
- Enter the Length. The length of input Type variable.
- Select the Type of your input variable
- 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
- Enter the Key to the
notification variable
- To define a Completion variable, click on
the . Completion
variables are returned parameters from executing a
method.
- Enter the key of the
completion variable
- Enter the Name of the method completion variable.
- Enter the Count. The count is returned array.
- Enter the Length. The length of data that will be returned.
- Select the Type of data that will be returned
- 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
- Enter the key of the
completion variable
- (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.