This sample demonstrates integration between an Android Things device, Android companion app, and the Smart Home APIs, using Cloud Firestore for the backend and FCM + Cloud Functions for communication between the components. It can be used as a starting point for building your own Android projects with Assistant / Smarthome integration.
Note: The Android Things Console will be turned down for non-commercial use on January 5, 2022. For more details, see the FAQ page.
This sample allows control of an Android Things device with a Rainbow Hat mounted on top. The user can:
- Tap buttons on the hat to turn LEDs on and off
- See the LED state from an Android phone (companion app)
- Control the LED state from the companion app
- Control the LED state from any Assistant device (phone, Google Home, etc) using smarthome apis -- e.g "Hey google, turn on the red LED on the rainbow hat."
- Report results back to the main UI thread once that work is complete
IMPORTANT: Please, note that these samples are not necessarily the easiest way to accomplish a task. In particular, they handle all low level I/O protocols directly, on purpose to showcase how to use the Peripheral APIs. In real world applications, you should use or develop a suitable driver that encapsulates the manipulation of low level APIs.
- Android Things compatible board
- Android Studio 3.0+
- Rainbow Hat for Android Things
There are three components to install, each in a subdirectory of this project.
- Android Things app : Follow instructions in app module
- Android companion app : Follow instructions in companionApp module
- Firebase functions (Smarthome integration) : Follow instructions in Firebase module
This sample app is currently configured to launch only when deployed from your
development machine. To enable the main activity to launch automatically on boot,
add the following intent-filter
to the app's manifest file:
<activity ...>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>