Add Trait
On the trait management screen, click the "+ Add Trait" button.
The JSON editor for registering a trait will show up.
Define the trait using the editor. The following example is setting the trait based on the sample presented in Trait Registration.
First, define the following items using the input form and pull-down menu at the top of the editor.
- Put the trait name in trait name form.
- Set the grouping interval of the state history in dataGroupingInterval pull-down menu.
You can select from 1_MINUTE, 15_MINUTES, 30_MINUTES, 1_HOUR, and 12_HOURS. The chosen interval will be reflected in the
dataGroupingInterval
field in the JSON editor.
Next, continue defining the trait by filling the following fields in the JSON editor.
-
actions
field: Define a list of actions.-
description
field: Set the description of the action (optional). -
payloadSchema
field: Set the expected value of the action parameter.
-
-
states
field: Define a list of states.-
description
field: Set the description of the state (optional). -
payloadSchema
field: Set the expected value of the state.
-
-
properties
field: Define a list of thing properties (optional).-
description
field: Set the description of the property (optional). -
payloadSchema
field: Set the expected value of the property. -
metadata
field: Set the sub property (optional).
-
When you are done, click the "Save" button.
How to set payloadSchema field
You will set the expected value of the action, state, and property in the payloadSchema
field using JSON schema syntax.
You can also use the following original schema:
-
Location information: A schema for checking if the value matches with the GeoJSON format defined in RFC7946.
Set
"$ref": "urn::kii:json-schema:geo:point"
in thepayloadSchema
field. -
Date: A schema for checking if the value matches with the UNIX epoch format.
Set
"$ref": "urn::kii:json-schema:datetime"
in thepayloadSchema
field. -
URL: A schema for checking if the value is an URL.
Set
"$ref": "urn::kii:json-schema:url"
in thepayloadSchema
field.