Smart Home Router Guide

Device TYPE

action.devices.types.ROUTER - Routers can reboot, update their software, have modes to handle Quality of service (QoS) controls and parental restrictions, and perform network specific operations (such as enabling the guest network and reporting network specific information such as the current internet throughput rates).

This type indicates that the device gets the router icon and some synonyms/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.

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.ROUTER',
        traits: [
          'action.devices.traits.Reboot',
          'action.devices.traits.SoftwareUpdate',
          'action.devices.traits.NetworkControl',
          'action.devices.traits.Modes',
          'action.devices.traits.Toggles'
        ],
        name: {
          defaultNames: ['Sirius Cybernetics Router 2331'],
          name: 'Router',
          nicknames: ['Upstairs router']
        },
        willReportState: true,
        attributes: {
          supportsEnablingGuestNetwork: true,
          supportsDisablingGuestNetwork: true,
          supportsEnablingNetworkProfile: true,
          supportsDisablingNetworkProfile: true,
          supportsNetworkDownloadSpeedTest: true,
          supportsNetworkUploadSpeedTest: true,
          supportsGettingGuestNetworkPassword: true,
          networkProfiles: [
            'kids'
          ],
          availableToggles: [{
            name: 'power saver mode',
            name_values: [{
              name_synonym: ['power saver mode', 'low power mode'],
              lang: 'en'
            }]
          }],
          availableModes: [{
            name: 'parental control',
            name_values: [{
              name_synonym: ['parental restriction', 'restriction'],
              lang: 'en'
            }],
            settings: [{
              setting_name: 'off',
              setting_values: [{
                setting_synonym: ['paused'],
                lang: 'en'
              }]
            }, {
              setting_name: 'moderate',
              setting_values: [{
                setting_synonym: ['medium'],
                lang: 'en'
              }]
            }, {
              setting_name: 'high',
              setting_values: [{
                setting_synonym: ['restricted'],
                lang: 'en'
              }]
            }],
            ordered: true
          }]
        },
        deviceInfo: {
          manufacturer: 'Sirius Cybernetics',
          model: '2331B',
          hwVersion: '11.2',
          swVersion: '11.4'
        },
        customData: {
          fooValue: 74,
          barValue: true,
          bazValue: 'lambtwirl'
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
@SmartHomeSnippetJson("smart-home-types-router_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.ROUTER")
            .addTrait("action.devices.traits.Reboot")
            .addTrait("action.devices.traits.SoftwareUpdate")
            .addTrait("action.devices.traits.NetworkControl")
            .addTrait("action.devices.traits.Modes")
            .addTrait("action.devices.traits.Toggles")
            .setName(
                Collections.singletonList("Sirius Cybernetics Router 2331"),
                "Router",
                Collections.singletonList("Upstairs router"))
            .setWillReportState(true)
            .setAttributes(
                new JSONObject()
                    .put("supportsEnablingGuestNetwork", true)
                    .put("supportsDisablingGuestNetwork", true)
                    .put("supportsEnablingNetworkProfile", true)
                    .put("supportsDisablingNetworkProfile", true)
                    .put("supportsNetworkDownloadSpeedTest", true)
                    .put("supportsNetworkUploadSpeedTest", true)
                    .put("supportsGettingGuestNetworkPassword", true)
                    .put("networkProfiles", new String[] {"kids"})
                    .put(
                        "availableToggles",
                        new JSONObject[] {
                          new JSONObject()
                              .put("name", "power saver mode")
                              .put(
                                  "name_values",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"power saver mode", "low power mode"})
                                        .put("lang", "en")
                                  })
                        })
                    .put(
                        "availableModes",
                        new JSONObject[] {
                          new JSONObject()
                              .put("name", "parental control")
                              .put(
                                  "name_values",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put(
                                            "name_synonym",
                                            new String[] {"parental restriction", "restriction"})
                                        .put("lang", "en")
                                  })
                              .put(
                                  "settings",
                                  new JSONObject[] {
                                    new JSONObject()
                                        .put("setting_name", "off")
                                        .put(
                                            "setting_values",
                                            new JSONObject[] {
                                              new JSONObject()
                                                  .put("setting_synonym", new String[] {"paused"})
                                                  .put("lang", "en")
                                            }),
                                    new JSONObject()
                                        .put("setting_name", "moderate")
                                        .put(
                                            "setting_values",
                                            new JSONObject[] {
                                              new JSONObject()
                                                  .put("setting_synonym", new String[] {"medium"})
                                                  .put("lang", "en")
                                            }),
                                    new JSONObject()
                                        .put("setting_name", "high")
                                        .put(
                                            "setting_values",
                                            new JSONObject[] {
                                              new JSONObject()
                                                  .put(
                                                      "setting_synonym",
                                                      new String[] {"restricted"})
                                                  .put("lang", "en")
                                            })
                                  })
                              .put("ordered", true)
                        }))
            .setDeviceInfo("Sirius Cybernetics", "2331B", "11.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.ROUTER",
        "traits": [
          "action.devices.traits.Reboot",
          "action.devices.traits.SoftwareUpdate",
          "action.devices.traits.NetworkControl",
          "action.devices.traits.Modes",
          "action.devices.traits.Toggles"
        ],
        "name": {
          "defaultNames": [
            "Sirius Cybernetics Router 2331"
          ],
          "name": "Router",
          "nicknames": [
            "Upstairs router"
          ]
        },
        "willReportState": true,
        "attributes": {
          "supportsEnablingGuestNetwork": true,
          "supportsDisablingGuestNetwork": true,
          "supportsEnablingNetworkProfile": true,
          "supportsDisablingNetworkProfile": true,
          "supportsNetworkDownloadSpeedTest": true,
          "supportsNetworkUploadSpeedTest": true,
          "supportsGettingGuestNetworkPassword": true,
          "networkProfiles": [
            "kids"
          ],
          "availableToggles": [
            {
              "name": "power saver mode",
              "name_values": [
                {
                  "name_synonym": [
                    "power saver mode",
                    "low power mode"
                  ],
                  "lang": "en"
                }
              ]
            }
          ],
          "availableModes": [
            {
              "name": "parental control",
              "name_values": [
                {
                  "name_synonym": [
                    "parental restriction",
                    "restriction"
                  ],
                  "lang": "en"
                }
              ],
              "settings": [
                {
                  "setting_name": "off",
                  "setting_values": [
                    {
                      "setting_synonym": [
                        "paused"
                      ],
                      "lang": "en"
                    }
                  ]
                },
                {
                  "setting_name": "moderate",
                  "setting_values": [
                    {
                      "setting_synonym": [
                        "medium"
                      ],
                      "lang": "en"
                    }
                  ]
                },
                {
                  "setting_name": "high",
                  "setting_values": [
                    {
                      "setting_synonym": [
                        "restricted"
                      ],
                      "lang": "en"
                    }
                  ]
                }
              ],
              "ordered": true
            }
          ]
        },
        "deviceInfo": {
          "manufacturer": "Sirius Cybernetics",
          "model": "2331B",
          "hwVersion": "11.2",
          "swVersion": "11.4"
        },
        "customData": {
          "fooValue": 74,
          "barValue": true,
          "bazValue": "lambtwirl"
        }
      }
    ]
  }
}
Validator

Device ERRORS

See the full list of errors and exceptions.