Smart Home Light Effects Trait Schema

action.devices.traits.LightEffects - This trait belongs to devices that can natively support complex lighting effects, such as looping through various colors.

Device ATTRIBUTES

Attribute Definition
supportedEffects List of strings. Required. List of the effects that the device will support. Only the colorLoop effect is currently valid. Setting this effect allows the device to loop through various colors randomly.

Sample SYNC Request and Response

Request
{
    "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
    "inputs": [{
      "intent": "action.devices.SYNC"
    }]
}
Node.js
'use strict';

const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');

const app = smarthome();

app.onSync((body, headers) => {
  return {
    requestId: body.requestId,
    payload: {
      agentUserId: '1836.15267389',
      devices: [{
        id: '123',
        type: 'action.devices.types.LIGHT',
        traits: [
          'action.devices.traits.OnOff',
          'action.devices.traits.LightEffects'
        ],
        name: {
          defaultNames: ['AAA bulb A19 color hyperglow'],
          name: 'Lamp',
          nicknames: ['Reading lamp']
        },
        willReportState: true,
        attributes: {
          supportedEffects: ['colorLoop'],
        },
        deviceInfo: {
          manufacturer: 'BrandX',
          model: 'hg11',
          hwVersion: '1.2',
          swVersion: '5.4'
        },
        customData: {
          fooValue: 12,
          barValue: false,
          bazValue: 'goatjive'
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
public SyncResponse onSync(@NotNull SyncRequest syncRequest, @Nullable Map<?, ?> headers) {
  Payload payload = new Payload();
  payload.setAgentUserId("1836.15267389");
  payload.setDevices(new Device[] {
      new Device.Builder()
          .setId("123")
          .setType("action.devices.types.LIGHT")
          .addTrait("action.devices.traits.OnOff")
          .addTrait("action.devices.traits.LightEffects")
          .setName(
              Collections.singletonList("AAA bulb A19 color hyperglow"),
              "Lamp",
              Collections.singletonList("Reading lamp")
          )
          .setWillReportState(true)
          .setAttributes(new JSONObject()
              .put("supportedEffects", new String[] {"colorLoop"})
          )
          .setDeviceInfo("BrandX", "hg11", "1.2", "5.4")
          .setCustomData(new JSONObject()
              .put("fooValue", 12)
              .put("barValue", false)
              .put("bazValue", "goatjive")
              .toString()
          )
          .build()
  });
  return new SyncResponse(syncRequest.getRequestId(), payload);
}
JSON
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "agentUserId": "1836.15267389",
    "devices": [
      {
        "id": "123",
        "type": "action.devices.types.LIGHT",
        "traits": [
          "action.devices.traits.OnOff",
          "action.devices.traits.LightEffects"
        ],
        "name": {
          "defaultNames": [
            "AAA bulb A19 color hyperglow"
          ],
          "name": "Lamp",
          "nicknames": [
            "Reading lamp"
          ]
        },
        "willReportState": true,
        "attributes": {
          "supportedEffects": [
            "colorLoop"
          ]
        },
        "deviceInfo": {
          "manufacturer": "BrandX",
          "model": "hg11",
          "hwVersion": "1.2",
          "swVersion": "5.4"
        },
        "customData": {
          "fooValue": 12,
          "barValue": false,
          "bazValue": "goatjive"
        }
      }
    ]
  }
}
Validator

Device STATES

Attribute Definition
activeLightEffect String. Optional. Currently active light effect. If there is no active effect, this state is empty.

Sample QUERY Request and Response

Request
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "inputs": [{
    "intent": 'action.devices.QUERY',
    "payload": {
      "devices": [{
        "id": "123",
        "customData": {
          "fooValue": 74,
          "barValue": true,
          "bazValue": "foo"
        }
      }]
    }
  }]
}
Node.js
'use strict';

const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');

const app = smarthome();

app.onQuery((body, headers) => {
  return {
    requestId: body.requestId,
    payload: {
      devices: {
        123: {
          on: true,
          activeLightEffect: 'colorLoop',
          online: true
        }
      }
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
public QueryResponse onQuery(@NotNull QueryRequest queryRequest, @Nullable Map<?, ?> map) {
  QueryResponse.Payload payload = new QueryResponse.Payload();
  payload.setDevices(new HashMap<String, Map<String, Object>>() {{      put("123", new HashMap<String, Object>() {{          put("on", true);
          put("activeLightEffect", "colorLoop");
          put("online", true);
      }});
  }});

  return new QueryResponse(queryRequest.getRequestId(), payload);
}
JSON
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "devices": {
      "123": {
        "on": true,
        "activeLightEffect": "colorLoop",
        "online": true
      }
    }
  }
}

Device COMMANDS

Command Parameters/Definition
action.devices.commands.ColorLoop Activates the ColorLoop command, which requests cycling through a set of colors.
action.devices.commands.StopEffect Stops the current light effect.

Sample EXECUTE Request and Response

Request
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "inputs": [{
    "intent": "action.devices.EXECUTE",
    "payload": {
      "commands": [{
        "devices": [{
          "id": "123",
          "customData": {
            "fooValue": 74,
            "barValue": true,
            "bazValue": "goatjive"
          }
        }],
        "execution": [{
          "command": "action.devices.commands.ColorLoop"
        }]
      }]
    }
  }]
}
Node.js
'use strict';

const {smarthome} = require('actions-on-google');
const functions = require('firebase-functions');

const app = smarthome();

app.onExecute((body, headers) => {
  return {
    requestId: body.requestId,
    payload: {
      commands: [{
        ids: ['123'],
        status: 'SUCCESS',
        states: {
          on: true,
          activeLightEffect: 'colorLoop'
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
public ExecuteResponse onExecute(@NotNull ExecuteRequest executeRequest, @Nullable Map<?, ?> map) {
  ExecuteResponse.Payload payload = new ExecuteResponse.Payload();

  payload.setCommands(new Commands[] {
      new Commands(
          new String[] {"123"},
          "SUCCESS",
          new HashMap<String, Object>() {{              put("activeLightEffect", "colorLoop");
              put("online", true);
          }},
          null
      )
  });
  return new ExecuteResponse(executeRequest.getRequestId(), payload);
}
JSON
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "on": true,
          "activeLightEffect": "colorLoop"
        }
      }
    ]
  }
}