Offline handling for Smart Home (AoG Pro Tips)

rootF IMG 636011d128330

As an Amazon Associate I earn from qualifying purchases.

Woodworking Plans Banner

[THEME MUSIC] DAVE SMITH: Device connectivity
isn't always consistent. And it's important
that users are aware when their devices
are unreachable or offline. If you are developing
a Smart Home action, it's critical that you report
this information to the Google Assistant. In today's AoG pro
tip, I'll show you some best practices
for reporting the state of unreachable devices. The Smart Home API supports
multiple ways to indicate that a device is unreachable. You can return the
device status as offline, report an error with the
status code device offline, or report the device state
object with the online flag set to false. Let's explore when each of
these responses is appropriate. When the Assistant attempts to
query an unreachable device, you should return the
device status as offline. This indicates that there is no
additional state we can gather about the device at this time. For execute commands,
return an error status with the error code
set to device offline. This indicates that
the command has failed because the
device is unreachable.

pexels photo 186077

Finally, use the
online flag to publish any changes in
device connectivity through the Report State API. This ensures that the home
graph remains up to date and reduces the chance that
query or execute intents are sent to an offline device. You should also use Report
State to notify home graph when the device comes back online. For more pro tips like
this, be sure to check out the rest of our videos. And share your thoughts
with us on Twitter using the #AoGProTips. Thanks for watching. [THEME MUSIC].

As an Amazon Associate I earn from qualifying purchases.

You May Also Like

About the Author: tech