Smart Home Television Guide

Device TYPE

action.devices.types.TV Television devices combine a tuner, display, and loudspeakers for the purpose of viewing and hearing media. Examples include smart TV devices.

This type indicates that the device gets the television 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.

Trait Commands
action.devices.traits.AppSelector
  • action.devices.commands.appSelect
action.devices.traits.InputSelector
  • action.devices.commands.setInput
action.devices.traits.MediaState
  • N/A
action.devices.traits.OnOff
  • action.devices.commands.OnOff
action.devices.traits.TransportControl
  • action.devices.commands.mediaClosedCaptioningOff
  • action.devices.commands.mediaClosedCaptioningOn
  • action.devices.commands.mediaNext
  • action.devices.commands.mediaPause
  • action.devices.commands.mediaPrevious
  • action.devices.commands.mediaResume
  • action.devices.commands.mediaStop
action.devices.traits.Volume
  • action.devices.commands.mute
  • action.devices.commands.setVolume

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: body.requestId,
    payload: {
      agentUserId: '1836.15267389',
      devices: [{
        id: '123',
        type: 'action.devices.types.TV',
        traits: [
          'action.devices.traits.AppSelector',
          'action.devices.traits.InputSelector',
          'action.devices.traits.MediaState',
          'action.devices.traits.Modes',
          'action.devices.traits.OnOff',
          'action.devices.traits.TransportControl',
          'action.devices.traits.Toggles',
          'action.devices.traits.Volume',
          'action.devices.traits.Channel'
        ],
        name: {
          defaultNames: ['Smart Television'],
          name: 'Smart Television',
          nicknames: ['Big Screen']
        },
        willReportState: true,
        attributes: {
          transportControlSupportedCommands: [
            'NEXT', 'PREVIOUS', 'PAUSE', 'STOP', 'RESUME', 'CAPTION_CONTROL'
          ],
          availableApplications: [{
            key: 'youtube',
            names: [{
              name_synonym: ['YouTube', 'YouTube_en'],
              lang: 'en',
            }],
          }],
          availableInputs: [{
            key: 'hdmi_1',
            names: [{
              name_synonym: ['HDMI 1', 'First HDMI'],
              lang: 'en',
            }],
          }, {
            key: 'usb_1',
            names: [{
              name_synonym: ['USB 1', 'First USB'],
              lang: 'en',
            }],
          }],
          availableChannels: [
            {
              key : 'ktvu2',
              names : [
                'Fox',
                'KTVU'
              ],
              number: '2'
            },
            {
              key : 'abc1',
              names : [
                'ABC',
                'ABC East'
              ],
              number: '702.4-11'
            }
          ],
          orderedInputs: false,
          volumeMaxLevel: 11,
          volumeCanMuteAndUnmute: true,
          volumeDefaultPercentage: 6,
          levelStepSize: 2,
          commandOnlyVolume: false,
          supportActivityState: true,
          supportPlaybackState: true,
          availableModes: [{
            name: "picture",
            name_values: [{
              name_synonym: ["Picture", "Picture Mode"],
              lang: "en"
            }],
            settings: [{
              setting_name: "normal",
              setting_values: [{
                setting_synonym: ["Normal", "Standard"],
                lang: "en"
              }]
            }, {
              setting_name: "cinema",
              setting_values: [{
                setting_synonym: ["Cinema", "Movie"],
                lang: "en"
              }]
            },
            {
              setting_name: "game",
              setting_values: [{
                setting_synonym: ["Game", "Video Game"],
                lang: "en"
              }]
            }],
            ordered: true
          }],
          availableToggles: [{
            name: "hdr",
            name_values: [{
              name_synonym: ["HDR", "High Dynamic Dange"],
              lang: "en"
            }]
          },
          {
            name: "3d_audio",
            name_values: [{
              name_synonym: ["3D Audio", "3D Sound"],
              lang: "en"
            }]
          }]
        },
        deviceInfo: {
          hwVersion: '1.0.0',
          swVersion: '2.0.0',
          model: 'L',
          manufacturer: 'L'
        },
        customData: {
          fooValue: 74,
          barValue: true,
          bazValue: 'lambtwirl'
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
@SmartHomeSnippetJson("smart-home-types-tv_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.TV")
            .addTrait("action.devices.traits.AppSelector")
            .addTrait("action.devices.traits.InputSelector")
            .addTrait("action.devices.traits.MediaState")
            .addTrait("action.devices.traits.Modes")
            .addTrait("action.devices.traits.OnOff")
            .addTrait("action.devices.traits.TransportControl")
            .addTrait("action.devices.traits.Toggles")
            .addTrait("action.devices.traits.Volume")
            .addTrait("action.devices.traits.Channel")
            .setName(
                Collections.singletonList("Smart Television"),
                "Smart Television",
                Collections.singletonList("Big Screen"))
            .setWillReportState(true)
            .setAttributes(
                new JSONObject()
                    .put(
                        "transportControlSupportedCommands",
                        new String[] {
                          "NEXT", "PREVIOUS", "PAUSE", "STOP", "RESUME", "CAPTION_CONTROL"
                        })
                    .put(
                        "availableApplications",
                        new JSONObject[] {
                          new JSONObject()
                              .put("key", "youtube")
                              .put(
                                  "names",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"Youtube", "Youtube_en"})
                                        .put("lang", "en")
                                  })
                        })
                    .put(
                        "availableInputs",
                        new JSONObject[] {
                          new JSONObject()
                              .put("key", "hdmi_1")
                              .put(
                                  "names",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym", new String[] {"HDMI 1", "First HDMI"})
                                        .put("lang", "en")
                                  }),
                          new JSONObject()
                              .put("key", "usb_1")
                              .put(
                                  "names",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put("name_synonym", new String[] {"USB 1", "First USB"})
                                        .put("lang", "en")
                                  })
                        })
                    .put(
                        "availableChannels",
                        new JSONObject[] {
                          new JSONObject()
                              .put("key", "ktvu2")
                              .put("names", new String[] {"Fox", "KTVU"})
                              .put("number", "2"),
                          new JSONObject()
                              .put("key", "abc1")
                              .put("names", new String[] {"ABC", "ABC East"})
                              .put("number", "702.4-11")
                        })
                    .put("orderedInputs", false)
                    .put("volumeMaxLevel", 11)
                    .put("volumeCanMuteAndUnmute", true)
                    .put("volumeDefaultPercentage", 6)
                    .put("levelStepSize", 2)
                    .put("commandOnlyVolume", false)
                    .put("supportActivityState", true)
                    .put("supportPlaybackState", true)
                    .put(
                        "availableModes",
                        new JSONObject[] {
                          new JSONObject()
                              .put("name", "picture")
                              .put(
                                  "name_values",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"Picture", "Picture Mode"})
                                        .put("lang", "en")
                                  })
                              .put(
                                  "settings",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put("setting_name", "normal")
                                        .put(
                                            "setting_values",
                                            new JSONObject[] {
                                              new JSONObject()
                                                  .put(
                                                      "setting_synonym",
                                                      new String[] {"Normal", "Standard"})
                                                  .put("lang", "en")
                                            }),
                                    new JSONObject()
                                        .put("setting_name", "cinema")
                                        .put(
                                            "setting_values",
                                            new JSONObject[] {
                                              new JSONObject()
                                                  .put(
                                                      "setting_synonym",
                                                      new String[] {"Cinema", "Movie"})
                                                  .put("lang", "en")
                                            }),
                                    new JSONObject()
                                        .put("setting_name", "game")
                                        .put(
                                            "setting_values",
                                            new JSONObject[] {
                                              new JSONObject()
                                                  .put(
                                                      "setting_synonym",
                                                      new String[] {"Game", "Video Game"})
                                                  .put("lang", "en")
                                            })
                                  })
                              .put("ordered", true)
                        })
                    .put(
                        "availableToggles",
                        new JSONObject[] {
                          new JSONObject()
                              .put("name", "hdr")
                              .put(
                                  "name_values",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"HDR", "High Dynamic Dange"})
                                        .put("lang", "en")
                                  }),
                          new JSONObject()
                              .put("name", "3d_audio")
                              .put(
                                  "name_values",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym", new String[] {"3D Audio", "3D Sound"})
                                        .put("lang", "en")
                                  })
                        }))
            .setDeviceInfo("L", "L", "1.0.0", "2.0.0")
            .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.TV",
        "traits": [
          "action.devices.traits.AppSelector",
          "action.devices.traits.InputSelector",
          "action.devices.traits.MediaState",
          "action.devices.traits.Modes",
          "action.devices.traits.OnOff",
          "action.devices.traits.TransportControl",
          "action.devices.traits.Toggles",
          "action.devices.traits.Volume",
          "action.devices.traits.Channel"
        ],
        "name": {
          "defaultNames": [
            "Smart Television"
          ],
          "name": "Smart Television",
          "nicknames": [
            "Big Screen"
          ]
        },
        "willReportState": true,
        "attributes": {
          "transportControlSupportedCommands": [
            "NEXT",
            "PREVIOUS",
            "PAUSE",
            "STOP",
            "RESUME",
            "CAPTION_CONTROL"
          ],
          "availableApplications": [
            {
              "key": "youtube",
              "names": [
                {
                  "name_synonym": [
                    "Youtube",
                    "Youtube_en"
                  ],
                  "lang": "en"
                }
              ]
            }
          ],
          "availableInputs": [
            {
              "key": "hdmi_1",
              "names": [
                {
                  "name_synonym": [
                    "HDMI 1",
                    "First HDMI"
                  ],
                  "lang": "en"
                }
              ]
            },
            {
              "key": "usb_1",
              "names": [
                {
                  "name_synonym": [
                    "USB 1",
                    "First USB"
                  ],
                  "lang": "en"
                }
              ]
            }
          ],
          "availableChannels": [
            {
              "key" : "ktvu2",
              "names" : [
                "Fox",
                "KTVU"
              ],
              "number": "2"
            },
            {
              "key" : "abc1",
              "names" : [
                "ABC",
                "ABC East"
              ],
              "number": "702.4-11"
            }
          ],
          "orderedInputs": false,
          "volumeMaxLevel": 11,
          "volumeCanMuteAndUnmute": true,
          "volumeDefaultPercentage": 6,
          "levelStepSize": 2,
          "commandOnlyVolume": false,
          "supportActivityState": true,
          "supportPlaybackState": true,
          "availableModes": [
            {
              "name": "picture",
              "name_values": [
                {
                  "name_synonym": [
                    "Picture",
                    "Picture Mode"
                  ],
                  "lang": "en"
                }
              ],
              "settings": [
                {
                  "setting_name": "normal",
                  "setting_values": [
                    {
                      "setting_synonym": [
                        "Normal",
                        "Standard"
                      ],
                      "lang": "en"
                    }
                  ]
                },
                {
                  "setting_name": "cinema",
                  "setting_values": [
                    {
                      "setting_synonym": [
                        "Cinema",
                        "Movie"
                      ],
                      "lang": "en"
                    }
                  ]
                },
                {
                  "setting_name": "game",
                  "setting_values": [
                    {
                      "setting_synonym": [
                        "Game",
                        "Video Game"
                      ],
                      "lang": "en"
                    }
                  ]
                }
              ],
              "ordered": true
            }
          ],
          "availableToggles": [
            {
              "name": "hdr",
              "name_values": [
                {
                  "name_synonym": [
                    "HDR",
                    "High Dynamic Dange"
                  ],
                  "lang": "en"
                }
              ]
            },
            {
              "name": "3d_audio",
              "name_values": [
                {
                  "name_synonym": [
                    "3D Audio",
                    "3D Sound"
                  ],
                  "lang": "en"
                }
              ]
            }
          ]
        },
        "deviceInfo": {
          "hwVersion": "1.0.0",
          "swVersion": "2.0.0",
          "model": "L",
          "manufacturer": "L"
        },
        "customData": {
          "fooValue": 74,
          "barValue": true,
          "bazValue": "lambtwirl"
        }
      }
    ]
  }
}

Validator

Device ERRORS

See the full list of errors and exceptions.