Properties

Properties are the element of the schema that describes the device's attributes.

Properties define what attributes should be expected for a given entity in the real world. For example, the stereo example from earlier had the following two properties (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.

Properties can be any one of the following "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.

Table 1. All property types can use the following metadata keys
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
Note: In the Web of Things specification from W3C, many more metadata keys are allowed. Those are not yet supported. These include "enum", "titles", "descriptions", "@type", "const", "oneOf", "writeOnly", and "format". Nor do we support "items", "minItems" or "maxItems" on Arrays, as well as "properties" or "required" on Objects yet.
Table 2. Number property types can also use the following metadata keys (plus those in "All")
Metadata Definition Description Required? Type
minimum Minimum value. Used for validation. No number
maximum Maximum value. Used for validation. No number
Table 3. Integer property types can use the following metadata keys (plus those in "All")
Metadata Definition Description Required? Type
minimum Minimum value. Used for validation. No integer
maximum Maximum value. Used for validation. No integer
Note: "String", "boolean" and "null" property types do not offer any additional definition beyond what is allowed in "all"
Below is an example properties section of a schema with examples for each of the above.
{
    ...
    "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
        }
    }
}

Add Properties to a Thing

  1. In the Overview panel of a Thing, click the plus icon next to Properties.


    Figure 1.
    The New Property dialog opens.
  2. Enter the Property Key value. This should be a descriptor of the Property.
  3. Enter a Type, and an Initial Value.
  4. In the Title field, select an option from the dropdown menu.


    Figure 2.
  5. Depending on the Type selection, subsequent fields may appear. Enter the values as required.
  6. If desired, enter any optional descriptors for this Property.
  7. Click Create.
    The information is added to the schema.


    Figure 3.
  8. Once the property has been created, you can click on the Edit icon to make further changes to this property.


    Figure 4.