Defining Methods
Methods define the interface to functions that are implemented in an application.
A method can be called from an application, from the thing details page in the Management Portal, from a cloud trigger, or from a campaign.
Notification variables are input parameters passed to the method.
Completion variables are output parameters passed from the method back to the caller of the method.
You can add a method when you create a new thing definition or when you edit an existing thing definition.
- On the Developer page, click Thing definitions.
- On the Thing Definitions page, click the Edit icon of the thing definition you want to change.
-
On the thing definition editing page, select the Standard tab, and then select the Methods tab.
-
Select Method Definition,
and then type or select the values for the new method definition.
The fields are as follows:
Field
Description
Key (mandatory)
A unique identifier for the method that is globally unique within the organization. The valid characters for a key are letters, numbers, "_" (underscore), and "-" (hyphen). For more information, see Field Formats and Limitations.
Name
The name of the method definition that is displayed on Management Portal pages.
Description
An optional description of the method functionality.
Handler
Choose Method or Trigger from the drop-down list:-
Method: If you want to execute a method in the device with the corresponding key selected.
-
Trigger: If you want to execute a trigger (must be triggered through a method.exec event) with the corresponding key selected.
Default ack timeout (seconds)
The number of seconds the method needs to wait for the response before timing out.
View security tags
Enter any number of tags to the method that control whether a user or application can view the method. The user or application must have a role that has the same view security tag associated with it to see a method with a view security tag associated with it.
-
- (Optional) To add a new notification variable, do the following:
-
select Notification Variable
-
Type or select the values for the new notification
variable.
The fields are as follows:
Field
Description
Key
The key for the method notification variable definition. A key is an identifier that must be globally unique within the organization. The valid characters for a key are letters, numbers, "_" (underscore), and "-" (hyphen).
Name
The name of the method notification variable definition that is displayed on Management Portal pages.
Type
The data type for the notification variable. The options are: bool, int, float, string.
Count
The number of responses that are expected.
Length
The length of the data that is returned.
UI Type
The type of user interface control for the notification variable used when the method is selected from the thing details page to execute the method from the Management Portal. The options are as follows:
-
Text box
-
Multiline text box
-
Check box
-
Select
-
Multi-select
-
Tag input box
-
-
select Notification Variable
- (Optional) To add a new completion variable, do the following:
-
Select Completion Variable.
-
Type or select the values for the new completion
variable.
The fields are as follows:
Field
Description
Key
The key for the method completion variable definition. A key is an identifier that must be globally unique within the organization. The valid characters for a key are letters, numbers, underscore, and hyphen.
Name
The name of the method completion variable definition that is displayed on Management Portal pages.
Type
Data type for the completion variable. The options are bool, int, float, string.
Count
The number of responses that are expected.
Length
The length of the data that is returned.
-
Select Completion Variable.
- Repeat steps 3 through 6 as needed to define additional methods.
- When you finish, click Update.