简体   繁体   English

智能家居和报告状态:如果当前已知状态与现实不同,会发生什么?

[英]Smart Home & Report State: what happens if the current known state is not in sync with the reality?

I implemented a basic Smart Home service by implementing the SYNC , EXECUTE and DISCONNECT actions. 我通过实现SYNCEXECUTEDISCONNECT操作实现了基本的智能家居服务。 In the SYNC action, all devices have willReportState set to false . SYNC操作中,所有设备都将willReportState设置为false

However, on https://developers.google.com/actions/smarthome/report-state I read that it is required for us to report state changes ourselves. 但是,在https://developers.google.com/actions/smarthome/report-state上,我读到我们需要自己报告状态更改。 This means that all devices must have willReportState set to true , I assume? 这意味着所有设备必须将willReportState设置为true ,我假设?

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. 例如,假设我们在5分钟前报告某个设备(具有OnOff特性)已关闭。 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? 也就是说,即使Graph Home服务认为设备已经断电,履行服务是否会收到此后端?

Also, do we still have to implement the QUERY action if we implement Report State? 另外,如果我们实施报告状态,我们还必须实施QUERY操作吗? 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? 它是否记录在其他地方?

Yes, you need to support ReportState and return willReportState: true for devices which have traits with states. 是的,您需要支持ReportState并为具有状态特征的设备返回willReportState:true。 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). 关于您的主要问题,您需要能够报告OnOff特征的变化(例如用户打开设备),包括从其他表面(例如硬件开关或任何其他智能家居平台)触发的状态更改。 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. 您仍然需要实施QUERY,因为Google可以随时查询您的履行网址而不是使用报告的状态。

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. 如果存在导致终端状态的一系列快速状态变化,例如调整调光开关直到达到所需亮度,则可以等到达到终端状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM