I implemented a basic Smart Home service by implementing the SYNC
, EXECUTE
and DISCONNECT
actions. In the SYNC
action, all devices have willReportState
set to false
.
However, on https://developers.google.com/actions/smarthome/report-state I read that it is required for us to report state changes ourselves. This means that all devices must have willReportState
set to true
, I assume?
My main question is what happens if the last reported state is not in sync with the reality?
For example, let's assume we reported 5 minutes ago that a certain device (having the OnOff
trait) is powered off. A few seconds ago, the customer powered the device manually by pressing the power on button. Let's assume that this fact is not yet reported to or known by the Smart Home Graph.
What happens now if the customer asks to the Assistant: turn off my device? Will this request be rejected or not? That is, will the fulfillment service receive this backend, even though the Graph Home service thinks the device is already powered off?
Also, do we still have to implement the QUERY
action if we implement Report State? Or are both required?
On a sidenote, this document does also not really address the frequency in which state changes must be reported. Is it documented somewhere else?
A smart home allows homeowners to control appliances, thermostats, lights, and other devices remotely using a smartphone or tablet through an internet connection. Smart homes can be set up through wireless or hardwired systems. Smart home technology provides homeowners with convenience and cost savings.
Examples of smart home hubs include Amazon Echo, Google Home, Insteon Hub Pro, Samsung SmartThings and Wink Hub. Some smart home systems can be created from scratch, for example, using a Raspberry Pi or other prototyping board.
One way to build out a smart home is to buy lots of components—sensors, smart bulbs, security cameras, speakers, and whatnot—and connect them all to a hub that helps them communicate with each other and with you, via your smartphone.
Yes, you need to support ReportState and return willReportState: true for devices which have traits with states. Refer to the trait documentation for the states which a trait needs to report back.
Regarding on your main question, you need to be able to report back changes in OnOff trait (such as the user turns on the device) including state changes triggered from other surfaces (such as hardware switch or any other smart home platform). Failure to report the most recent state may result in errors when users try to execute commands if the command is state dependent. In this example trying to turn off the light will work (since on/off is not state dependent) but any other state dependent command (such dimming or brightening) may fail.
You still need to implement QUERY, since anytime Google may Query your fulfillment url instead of using the state reported.
Finally, regarding on the frequency, you need to report the states as soon as there is a state change. If there is a series of rapid state changes leading to a terminal state, such as adjusting a dimmer switch until you reach the desired brightness, you may wait until the terminal state is reached.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With