Smart Home Pet Feeder Guide

Device TYPE

action.devices.types.PETFEEDER Interactions with pet feeders may include dispensing pet food or water in various quantities and presets, and adjusting various modes and toggles.

This type indicates that the device gets the pet feeder icon and some synonyms/aliases.

These are our recommendations for traits on this type of device, however you are free to mix and match from all available traits to best match your existing product functionality.

Please see each individual trait document for implementation details like required attributes, EXECUTE and QUERY.

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.PETFEEDER',
        traits: [
          'action.devices.traits.Dispense'
        ],
        name: {
          defaultNames: ['Sirius Cybernetics Corp Pet Feeder'],
          name: 'Pet Feeder',
          nicknames: ['Cat food dispenser']
        },
        willReportState: true,
        attributes: {
          supportedDispenseItems: [{
            item_name: 'catFood',
            item_name_synonyms: [{
              lang: 'en',
              synonyms: ['cat food', 'kibble']
            }],
            supported_units: [
              'OUNCES',
              'CUPS',
            ],
            default_portion: {
              amount: 1.0,
              unit: 'CUPS'
            }
          }],
          supportedDispensePresets: [{
            preset_name: 'catMeal',
            preset_name_synonyms: [{
              lang: 'en',
              synonyms: [
                'normal meal',
                'dinner'
              ]
            }]
          }]
        },
        customData: {
          fooValue: 42,
          barValue: true,
          catValue: "Fuzzy"
        }
      }]
    }
  };
});

// ...

exports.smarthome = functions.https.onRequest(app);
Java
@NotNull
@Override
public SyncResponse onSync(@NotNull SyncRequest syncRequest, @Nullable Map<?, ?> headers) {
  SyncResponse.Payload payload = new SyncResponse.Payload();
  payload.setAgentUserId("123456789");
  payload.setDevices(new SyncResponse.Payload.Device[] {
      new SyncResponse.Payload.Device.Builder()
          .setId("123")
          .setType("action.devices.types.PETFEEDER")
          .addTrait("action.devices.traits.Dispense")
          .setName(
              Collections.singletonList("Sirius Cybernetics Corp Pet Feeder"),
              "Pet Feeder",
              Collections.singletonList("Cat food dispenser")
          )
          .setWillReportState(true)
          .setAttributes(new JSONObject()
              .put("supportedDispenseItems", new JSONObject[]{
                  new JSONObject()
                      .put("item_name", "catFood")
                      .put("item_name_synonyms", new JSONObject[] {
                          new JSONObject()
                              .put("lang", "en")
                              .put("synonyms", new String[] {"cat food", "kibble"}),
                      })
                      .put("supported_units", new String[] {
                          "OUNCES",
                          "CUPS",
                      })
                      .put("default_portion", new JSONObject()
                          .put("amount", 1.0)
                          .put("unit", "CUPS")
                      )
              })
              .put("supportedDispensePresets", new JSONObject[] {
                  new JSONObject()
                      .put("preset_name", "catFood")
                      .put("preset_name_synonyms", new JSONObject[] {
                          new JSONObject()
                              .put("lang", "en")
                              .put("synonyms", new String[] {
                                  "normal meal",
                                  "dinner"
                              })
                      })
              })
          )
          .setDeviceInfo("Sirius Cybernetics Corporation", "492134", "3.2", "11.4")
          .setCustomData(new JSONObject()
              .put("fooValue", 42)
              .put("barValue", true)
              .put("catValue", "Fuzzy")
              .toString()
          )
          .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.PETFEEDER",
        "traits": [
          "action.devices.traits.Dispense"
        ],
        "name": {
          "defaultNames": [
            "Sirius Cybernetics Corp Pet Feeder"
          ],
          "name": "Pet Feeder",
          "nicknames": [
            "Cat food dispenser"
          ]
        },
        "willReportState": true,
        "attributes": {
          "supportedDispenseItems": [
            {
              "item_name": "catFood",
              "item_name_synonyms": [
                {
                  "lang": "en",
                  "synonyms": [
                    "cat food",
                    "kibble"
                  ]
                }
              ],
              "supported_units": [
                "OUNCES",
                "CUPS"
              ],
              "default_portion": {
                "amount": 1,
                "unit": "CUPS"
              }
            }
          ],
          "supportedDispensePresets": [
            {
              "preset_name": "catMeal",
              "preset_name_synonyms": [
                {
                  "lang": "en",
                  "synonyms": [
                    "normal meal",
                    "dinner"
                  ]
                }
              ]
            }
          ]
        },
        "customData": {
          "fooValue": 42,
          "barValue": true,
          "catValue": "Fuzzy"
        }
      }
    ]
  }
}
Validator

Device ERRORS

See the full list of errors and exceptions.