Properties
Properties are the element of the schema that describes the device's attributes.
status
and volume
):{
...
"properties: {
"status" : {
"type": "string",
},
"volume": {
"title": "volume",
"description": "The volume of the Sound Stereo System",
"type": "integer",
"minimum": 0,
"maximum": 100
}
}
}
Each of these properties is described by some additional information like
type
, minimum
, and maximum
.
The Thing
schema provides standard options for both the "types" that
properties can be, and for the ways we can further define those types.
array
- Expects a list of results
boolean
- Expects a true/false
number
- Expects any real number
integer
- Expects any whole number
object
- Expects a JSON object with additional properties defined.Note: Using Object type properties enables you to nest properties within properties to create rich structures.
string
- Expects a series of letters and/or numbers
null
- Expects no value
Depending on the property type
, each property can be additionally
defined with metadata. Again, you can see this in the above example;
volume
has the additional metadata key definitions of
title
, description
, type
,
minimum
, and maximum
. The additional metadata
you are able to add to properties are defined below.
Metadata Definition | Description | Required? | Type |
---|---|---|---|
title |
Title of the property to display in the UI | No | string |
description |
Additional content to help the user understand what the property is for. | No | string |
type |
Primitive data type for validation. | No | string |
unit |
Provides a reference unit, especially for numbers and integers. | No | string |
readOnly |
Validates that a value should not be written to. | Yes (default is false ) |
boolean |
Metadata Definition | Description | Required? | Type |
---|---|---|---|
minimum |
Minimum value. Used for validation. | No | number |
maximum |
Maximum value. Used for validation. | No | number |
Metadata Definition | Description | Required? | Type |
---|---|---|---|
minimum |
Minimum value. Used for validation. | No | integer |
maximum |
Maximum value. Used for validation. | No | integer |
{
...
"properties": {
"rgb": {
"type":"array",
"title": "RGB color value",
"description": "This property expects an array of json objects as defined below. Example value is [233,122,0]",
"readOnly": false
},
"mode": {
"type": "string",
"title": "Operating Mode",
"readOnly": false,
"description": "This property expects a string. Example value is \"cleaning\" "
},
"temperature": {
"type": "number",
"title": "Temperature (F)",
"description": "This property expects a number value (decimals are allowed). Example value is 98.6",
"unit": "F",
"maximum": 140.0,
"minimum": -100.0,
"readOnly": false
},
"groupId": {
"type": "integer",
"title": "Parent Group ID",
"description": "This property expects a whole number value. Example is 312.",
"minimum": 0,
"maximum": 65535,
"readOnly": false
},
"status": {
"type": "object",
"title": "Latest and current status",
"description": "This property expects a JSON object which conforms to WoT schema definitions.",
"readOnly": false
},
"isOn?": {
"type": "boolean",
"title": "Is this asset powered on?",
"description": "This property expects either true or false",
"readOnly": false
}
}
}