We want to hear your thoughts on the Google Smart Home platform. Join a user study and receive a gift for your input. Click here to sign up.

Smart Home InputSelector Trait Schema

action.devices.traits.InputSelector - This trait is used for devices which are able to switch inputs.

Media inputs can have dynamic names per device that represent audio or video feeds. These feeds can be hardwired or networked, but they should be named and reasonably persistent. This trait does not support arbitrary ephemeral feeds, such as a searchable networked library. Paired, named Bluetooth sources are supported. Sources can have multiple names, so user-created and discovered names are supported, as well as default names;for example, 'hdmi_1'might also be 'DVD player,' or 'usb_1' might also be 'Hard drive'.

Media inputs can be ordered to support 'next' and 'previous' commands.

As with Toggles and Modes, the names of inputs should be provided in all available languages; this is especially relevant for default names.

Device ATTRIBUTES

Devices with this trait may report the following attributes as part of the SYNC operation. To learn more about handling SYNC intents, see Intent fulfillment.

Attributes Type Description
availableInputs Array <Object>

List of objects representing input audio or video feeds. Feeds can be hardwired or networked. Each feed should be named and reasonably persistent. Make sure to define your synonyms carefully to prevent undesired (over-)triggering.

Properties:

Available input.

key String

Unique key for the input. The key should not be exposed to users in speech or response.

names Array <Object>

List of names for the input for all available languages.

Properties:

lang String

Language code.

name_synonym Array <String>

User-friendly names for the input, in a given language. The first synonym is used in Google Assistant's response to the user.

Input name.

commandOnlyInputSelector Boolean

(Default: false)

Indicates if the device supports using one-way (true) or two-way (false) communication. Set this attribute to true if the device cannot respond to a QUERY intent or Report State for this trait.

orderedInputs Boolean

(Default: false)

True if the list of output is ordered. This also indicates that the 'next' and 'previous' functionality is available.

Required:

  • availableInputs
Examples

Device with two ordered inputs.

{
  "availableInputs": [
    {
      "key": "hdmi_1",
      "names": [
        {
          "lang": "en",
          "name_synonym": [
            "hdmi 1",
            "1st hdmi",
            "DVD player"
          ]
        },
        {
          "lang": "de",
          "name_synonym": [
            "hdmi 1",
            "zuerst hdmi",
            "DVD Spieler"
          ]
        }
      ]
    },
    {
      "key": "usb_1",
      "names": [
        {
          "lang": "en",
          "name_synonym": [
            "usb 1",
            "first usb",
            "Hard drive"
          ]
        },
        {
          "lang": "de",
          "name_synonym": [
            "usb 1",
            "zuerst usb",
            "Festplatte"
          ]
        }
      ]
    }
  ],
  "orderedInputs": true
}
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.InputSelector'
        ],
        name: {
          defaultNames: ['TV'],
          name: 'Living Room TV',
          nicknames: ['Big TV']
        },
        willReportState: true,
        attributes: {
          availableInputs: [
            {
              key: "hdmi_1",
              names: [
                {
                  name_synonym: [ "HDMI 1", "First HDMI", "DVD player"],
                  lang: "en"
                },
                {
                  name_synonym: ["HDMI 1", "Zuerst HDMI", "DVD Spieler"],
                  lang: "de"
                }
              ]
            },
            {
              key: "usb_1",
              names: [
                {
                  name_synonym: [ "USB 1", "First USB", "Hard drive" ],
                  lang: "en"
                },
                {
                  name_synonym: [ "USB 1", "Zuerst USB", "Festplatte" ],
                  lang: "de"
                }
              ]
            }
          ],
          orderedInputs: true
        },
        deviceInfo: {
          manufacturer: "ACME Inc.",
          model: "TV-R",
          hwVersion: "PVT-2",
          swVersion: "1.0.1"
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
@SmartHomeSnippetJson("smart-home-traits-inputselector_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.InputSelector")
            .setName(
                Collections.singletonList("TV"),
                "Living Room TV",
                Collections.singletonList("Big TV"))
            .setWillReportState(true)
            .setAttributes(
                new JSONObject()
                    .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", "DVD player"})
                                        .put("lang", "en"),
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"HDMI 1", "Zuerst HDMI", "DVD Spieler"})
                                        .put("lang", "de")
                                  }),
                          new JSONObject()
                              .put("key", "usb_1")
                              .put(
                                  "names",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"USB 1", "First USB", "Hard drive"})
                                        .put("lang", "en"),
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"USB 1", "Zuerst USB", "Festplatte"})
                                        .put("lang", "de")
                                  })
                        })
                    .put("orderedInputs", true))
            .setDeviceInfo("ACME Inc.", "TV-R", "PVT-2", "1.0.1")
            .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.InputSelector"
        ],
        "name": {
          "defaultNames": [
            "TV"
          ],
          "name": "Living Room TV",
          "nicknames": [
            "Big TV"
          ]
        },
        "willReportState": true,
        "attributes": {
          "availableInputs": [
            {
              "key": "hdmi_1",
              "names": [
                {
                  "name_synonym": [
                    "HDMI 1",
                    "First HDMI",
                    "DVD player"
                  ],
                  "lang": "en"
                },
                {
                  "name_synonym": [
                    "HDMI 1",
                    "Zuerst HDMI",
                    "DVD Spieler"
                  ],
                  "lang": "de"
                }
              ]
            },
            {
              "key": "usb_1",
              "names": [
                {
                  "name_synonym": [
                    "USB 1",
                    "First USB",
                    "Hard drive"
                  ],
                  "lang": "en"
                },
                {
                  "name_synonym": [
                    "USB 1",
                    "Zuerst USB",
                    "Festplatte"
                  ],
                  "lang": "de"
                }
              ]
            }
          ],
          "orderedInputs": true
        },
        "deviceInfo": {
          "manufacturer": "ACME Inc.",
          "model": "TV-R",
          "hwVersion": "PVT-2",
          "swVersion": "1.0.1"
        }
      }
    ]
  }
}
Validator

Device STATES

Devices with this trait may report the following states as part of the QUERY operation. To learn more about handling QUERY intents, see Intent fulfillment.

InputSelector does not support query grammar. All state changes must be reported via Report State.
States Type Description
currentInput String

Key of the input currently in use.

Required:

  • currentInput
Examples

Device with HDMI input currently selected.

{
  "currentInput": "hdmi_1"
}

Device COMMANDS

Devices with this trait may respond to the following commands as part of the EXECUTE operation. To learn more about handling EXECUTE intents, see Intent fulfillment.

action.devices.commands.SetInput

Parameters

Set the media input.

Parameters Type Description
newInput String

Key of the new input.

Required:

  • newInput
Examples

Select USB input

{
  "newInput": "usb_1"
}

action.devices.commands.NextInput

Parameters

Select the next input. Only applicable when the orderedInputs attribute is set to true.

Parameters
No properties.
Examples

No parameters

action.devices.commands.PreviousInput

Parameters

Select the previous input. Only applicable when the orderedInputs attribute is set to true.

Parameters
No properties.
Examples

No parameters

Example: Set the TV to USB 1 / Change input to USB 1

Request
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "inputs": [{
    "intent": "action.devices.EXECUTE",
    "payload": {
      "commands": [{
        "devices": [{
          "id": "123"
        }],
        "execution": [{
          "command": "action.devices.commands.SetInput",
          "params": {
            "newInput": "usb_1"
          }
        }]
      }]
    }
  }]
}
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: {
          currentInput: 'usb_1'
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
@SmartHomeSnippetJson("smart-home-traits-inputselector_execute.json")
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("currentInput", "usb_1");
              }
            },
            null,
            null)
      });
  return new ExecuteResponse(executeRequest.getRequestId(), payload);
}
JSON
{
  "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
  "payload": {
    "commands": [
      {
        "ids": [
          "123"
        ],
        "status": "SUCCESS",
        "states": {
          "currentInput": "usb_1"
        }
      }
    ]
  }
}

Device ERRORS

See the full list of errors and exceptions.

unsupportedInput: The input is not currently supported.