Smart Home Speaker Guide

action.devices.types.SPEAKER - This device is a connected speaker that does not split audio into separate channels (for example, between two left and right devices).

This type indicates that the device gets the Speaker icon and some related synonyms and aliases.

Device capabilities

Refer to the corresponding trait documentation for implementation details, such as attributes and states that your service should support, and how to build EXECUTE and QUERY responses.

Required TRAITS

These traits and commands are required, if applicable to your device. These traits are recommended, if applicable to your device. However, you are free to mix and match from all available traits to best match your existing product functionality.

Sample SYNC Request and Response

This is an example using the device type and traits above. It is intended to give an idea of how to build a SYNC response. If you add or remove traits, this will need to be modified to reflect those changes.
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: "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
    payload: {
      agentUserId: "1836.15267389",
      devices: [{
        id: "123",
        type: "action.devices.types.SPEAKER",
        traits: [
          "action.devices.traits.Volume",
          "action.devices.traits.TransportControl",
          "action.devices.traits.MediaState"
        ],
        name: {
          defaultNames: ["Speaker"],
          name: "Smart speaker",
          nicknames: ["Living room speaker"]
        },
        willReportState: true,
        attributes: {
          transportControlSupportedCommands: [
            "NEXT",
            "PREVIOUS",
            "PAUSE",
            "STOP",
            "RESUME"
          ],
          volumeMaxLevel: 11,
          volumeCanMuteAndUnmute: true,
          supportActivityState: true,
          supportPlaybackState: true
        },
        deviceInfo: {
          manufacturer: "Sirius Cybernetics Corporation",
          model: "492134",
          hwVersion: "3.2",
          swVersion: "11.4"
        },
        customData: {
          fooValue: 74,
          barValue: true,
          bazValue: "lambtwirl"
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
@SmartHomeSnippetJson("smart-home-types-speaker_sync.json")
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.SPEAKER")
            .addTrait("action.devices.traits.Volume")
            .addTrait("action.devices.traits.TransportControl")
            .addTrait("action.devices.traits.MediaState")
            .setName(
                Collections.singletonList("Speaker"),
                "Smart speaker",
                Collections.singletonList("Living room speaker"))
            .setWillReportState(true)
            .setAttributes(
                new JSONObject()
                    .put(
                        "transportControlSupportedCommands",
                        new String[] {"NEXT", "PREVIOUS", "PAUSE", "STOP", "RESUME"})
                    .put("volumeMaxLevel", 11)
                    .put("volumeCanMuteAndUnmute", true)
                    .put("supportActivityState", true)
                    .put("supportPlaybackState", true))
            .setDeviceInfo("Sirius Cybernetics Corporation", "492134", "3.2", "11.4")
            .setCustomData(
                new JSONObject()
                    .put("fooValue", 74)
                    .put("barValue", true)
                    .put("bazValue", "lambtwirl"))
            .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.SPEAKER",
        "traits": [
          "action.devices.traits.Volume",
          "action.devices.traits.TransportControl",
          "action.devices.traits.MediaState"
        ],
        "name": {
          "defaultNames": [
            "Speaker"
          ],
          "name": "Smart speaker",
          "nicknames": [
            "Living room speaker"
          ]
        },
        "willReportState": true,
        "attributes": {
          "transportControlSupportedCommands": [
            "NEXT",
            "PREVIOUS",
            "PAUSE",
            "STOP",
            "RESUME"
          ],
          "volumeMaxLevel": 11,
          "volumeCanMuteAndUnmute": true,
          "supportActivityState": true,
          "supportPlaybackState": true
        },
        "deviceInfo": {
          "manufacturer": "Sirius Cybernetics Corporation",
          "model": "492134",
          "hwVersion": "3.2",
          "swVersion": "11.4"
        },
        "customData": {
          "fooValue": 74,
          "barValue": true,
          "bazValue": "lambtwirl"
        }
      }
    ]
  }
}

Validator

Device ERRORS

See the full list of errors and exceptions.