Defining Schema

You need to define the schema to let the mobile application manipulate the thing.

This page assumes that you are familiar with the basic concepts of the schema, actions, action results, and thing state. To learn about these concepts, see Schema.

Schema

You need to define the action names, their parameters, and state fields as a schema. The schema is to be used as the system design information when you are using the iOS SDK (this is different from when you are using the Android SDK on which you need to define the schema as classes and set them in the API).

As explained in Schema, the schema needs to be shared within the entire framework. You need to implement the thing based on the schema. You also need to be careful when you are upgrading the implementation so as to align the schema in the framework. Although you can implement an iOS application without explicitly defining the schema, we strongly encourage you to define it before starting the implementation.

Here, we will define a sample schema for an air conditioner. We will define the actions and state as shown below. We will also assign the schema name and version onto it.

Example of Actions

Let us assume that the air conditioner can take the following three actions at the same time. The following shows an example of the actions defined in the schema.

  • TurnPower Action: Action with a boolean value to specify if we are going to turn the power on or off (true to turn the power on).

    Action Name: turnPower

    Parameter example:

    {
      "power" : true
    }
    
  • SetPresetTemperature Action: Action with an integer (from 15 to 30) that represents the preset temperature setting.

    Action Name: setPresetTemperature

    Parameter example:

     {
       "presetTemperature" : 25
     }
    
  • SetFanSpeed Action: Action with an integer (from 0 to 10) that represents the fan speed setting.

    Action Name: setFanSpeed

    Parameter example:

    {
      "fanSpeed" : 5
    }
    

Example of State

Let us assume that the air conditioner allows us to check the "current room temperature" and "humidity" as its state in addition to the above three action settings.

The example of the state is as follows:

{
  "power" : true,
  "presetTemperature" : 25,
  "fanspeed" : 5,
  "currentTemperature" : 28,
  "currentHumidity" : 65
}