Smart Home Media Remote Guide

Device TYPE

action.devices.types.REMOTECONTROL Media remotes are used to control media devices. Examples of this device type include hubs, universal remotes, and media controllers.

This type indicates that the device gets the media remote 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.REMOTECONTROL',
        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'
        ],
        name: {
          defaultNames: ['Smart Remote Control'],
          name: 'Smart Remote Control',
          nicknames: ['Remote']
        },
        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',
            }],
          }],
          orderedInputs: false,
          volumeMaxLevel: 11,
          volumeCanMuteAndUnmute: true,
          volumeDefaultPercentage: 6,
          levelStepSize: 2,
          commandOnlyVolume: false,
          supportActivityState: true,
          supportPlaybackState: true,
          availableToggles: [{
            name: "pip",
            name_values: [{
              name_synonym: [ "PIP", "Picture In Picture" ],
              lang: "en"
            }]
          },
          {
            name: "details",
            name_values: [{
              name_synonym: [ "Details", "Program Details" ],
              lang: "en"
            }]
          }],
          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
          }]
        },
        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-remotecontrol_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.REMOTECONTROL")
            .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")
            .setName(
                Collections.singletonList("Smart Remote Control"),
                "Smart Remote Control",
                Collections.singletonList("Remote"))
            .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("orderedInputs", false)
                    .put("volumeMaxLevel", 11)
                    .put("volumeCanMuteAndUnmute", true)
                    .put("volumeDefaultPercentage", 6)
                    .put("levelStepSize", 2)
                    .put("commandOnlyVolume", false)
                    .put("supportActivityState", true)
                    .put("supportPlaybackState", true)
                    .put(
                        "availableToggles",
                        new JSONObject[] {
                          new JSONObject()
                              .put("name", "pip")
                              .put(
                                  "name_values",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"PIP", "Picture In Picture"})
                                        .put("lang", "en")
                                  }),
                          new JSONObject()
                              .put("name", "details")
                              .put(
                                  "name_values",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"Details", "Program Details"})
                                        .put("lang", "en")
                                  })
                        })
                    .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)
                        }))
            .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.REMOTECONTROL",
        "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"
        ],
        "name": {
          "defaultNames": [
            "Smart Remote Control"
          ],
          "name": "Smart Remote Control",
          "nicknames": [
            "Remote"
          ]
        },
        "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"
                }
              ]
            }
          ],
          "orderedInputs": false,
          "volumeMaxLevel": 11,
          "volumeCanMuteAndUnmute": true,
          "volumeDefaultPercentage": 6,
          "levelStepSize": 2,
          "commandOnlyVolume": false,
          "supportActivityState": true,
          "supportPlaybackState": true,
          "availableToggles": [
            {
              "name": "pip",
              "name_values": [
                {
                  "name_synonym": [
                    "PIP",
                    "Picture In Picture"
                  ],
                  "lang": "en"
                }
              ]
            },
            {
              "name": "details",
              "name_values": [
                {
                  "name_synonym": [
                    "Details",
                    "Program Details"
                  ],
                  "lang": "en"
                }
              ]
            }
          ],
          "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
            }
          ]
        },
        "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.