Use the sample app

The sample app showcases the basic capabilities of device access and control using the Home APIs for the device types it supports.

Once account authorization is complete and a structure has been selected, the sample app loads all local devices found in that structure. If the device is in a room, it will be listed under that room. The sample app supports these device types:

  • Color Temperature Light (on and off, brightness)
  • Contact Sensor (boolean state)
  • Dimmable Light (on and off, brightness)
  • Extended Color Light (on and off, brightness)
  • Generic Switch
  • Occupancy Sensor (occupancy sensing)
  • On/Off Light (on and off, brightness)
  • On/Off Light Switch
  • On/Off Plug-in Unit (on and off)
  • On/Off Sensor

Actions on existing devices and automations

The sample app consists of two tabs - Devices and Automations. Each tab provides information about the structure and lets you perform tasks.

Devices tab

The Devices tab (Figure 1) shows the rooms in the structure (Backyard, Attic, Travel) and the devices for each room, along with the status of each device. To view or edit the traits on a device, tap the device name. This takes you to the control screen for that device (Figure 2).

To add a device to the structure, tap Add Device from the Devices tab (Figure 1), then follow the instructions to add a device with or without using a QR code.

Devices tab of the Home APIs sample app.
Figure 1: Sample app screen: Devices tab view
Device controls of the Home APIs sample app.
Figure 2: Sample app device controls

Automations tab

The Automations tab (Figure 3) shows a list of all automations for the structure. Each automation shows its starters and actions. Multiple starters and actions are supported.

Tap an automation to view its details, as shown in the example in Figure 4. In this detailed view, you can delete the automation or manually execute the automation without the need for a starter, provided that the Manually Execute button is supported for this automation.

Also in the detailed view of an automation (Figure 4), you can toggle isActive to turn the automation on or off. The isValid field is set by the SDK and is false if there is an issue with device or trait support or some other problem.

Automations tab of the Home APIs sample app.
Figure 3: Automations tab view
Detailed view of a selected automation.
Figure 4: Detailed view of one automation

Create an automation

To create a new automation, tap the Create button from the automations list view (Figure 3). The New Automation screen appears (Figure 5).

Use the +Add Starter and +Add Action buttons (Figure 5) to add one or more starter and action to your automation. Figures 6 and 7 show examples of selecting a starter and an action, respectively. After you have made your selections, and you save the starter or action, you are then presented with the Update Starter and Remove Starter buttons for the starter (and Update Action and Remove Action for the action). This gives you the opportunity to edit the starter or action, or remove it, before you save the automation itself.

When you are done adding starters and actions, you can return to the New Automation screen and tap Create Automation (Figure 8).

Sample app screen for starting a new automation.
Figure 5: Start creating a new automation
Sample app screen for adding a starter for an automation.
Figure 6: Adding a starter to an automation
Sample app screen for adding an action for an automation.
Figure 7: Adding an action to an automation
Sample app screen for creating an automation.
Figure 8: Create the automation

Troubleshooting

The app displays dialog messages for some common events that may occur. Refer to the adb logs for information about how to resolve these events.

If you encounter issues using the sample app, see Troubleshooting.