Smart Home OnOff Trait Schema

action.devices.traits.OnOff - The basic on and off functionality for any device that has binary on and off, including plugs and switches as well as many future devices. Note that thermostats have an expanded "mode" setting, which is a multiway switch that includes on and off, but thermostats generally will not have this trait.

Device ATTRIBUTES

None

Sample SYNC Request and Response

Request
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "inputs": [{
    "intent": "action.devices.SYNC",
  }]
}
Response
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "agentUserId": "1836.15267389",
    "devices": [{
      "id": "123",
      "type": "action.devices.types.LIGHT",
      "traits": [
        "action.devices.traits.OnOff"     ],
      "name": {
        "defaultNames": ["AAA bulb A19 color hyperglow"],
        "name": "lamp1",
        "nicknames": ["reading lamp"]
      },
      "willReportState": true,

      "roomHint": "living room",
      "deviceInfo": {
        "manufacturer": "BrandX",
        "model": "hg11",
        "hwVersion": "1.2",
        "swVersion": "5.4"
      },
      "customData": {
        "fooValue": 12,
        "barValue": false,
        "bazValue": "dancing alpaca"
      }
    }]
  }
}
Validator

Device STATES

State Definition
on Boolean. Whether a device with an on/off switch is on or off.

Sample QUERY Request and Response

Request
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "inputs": [{
      "intent": "action.devices.QUERY",
      "payload": {
        "devices": [{
          "id": "123"
        },{
          "id": "456"
        }]
      }
  }]
}
Response
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "devices": {
      "123": {
        "on": true,
        "online": true
      },
      "456": {
        "on": false,
        "online": true,
      }
    }
  }
}

Device COMMANDS

Command Parameters/Definition
action.devices.commands.OnOff on Boolean. Required. Whether to turn the device on or off.

Sample EXECUTE Request and Response

This example shows how to turn one light on.
Request
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "inputs": [{
    "intent": "action.devices.EXECUTE",
    "payload": {
      "commands": [{
        "devices": [{
          "id": "123",
          "customData": {
            "fooValue": 74,
            "barValue": true,
            "bazValue": "sheepdip"
          }
        }, {
          "id": "456",
          "customData": {
            "fooValue": 36,
            "barValue": false,
            "bazValue": "moarsheep"
          }
        }],
        "execution": [{
          "command": "action.devices.commands.OnOff",
          "params": {
            "on": true
          }
        }]
      }]
    }
  }]
}
Response
{
    "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
    "payload": {
        "commands": [{
            "ids": ["123"],
            "status": "SUCCESS",
            "states": {
                "on": true,
                "online": true
            }
        }, {
            "ids": ["456"],
            "status": "ERROR",
            "errorCode": "deviceTurnedOff"
        }]
    }
}