如何通过智能家居应用程序的实时提要报告设备上的状态变化?

How to report state changes on devices over real-time feed for Smart Home apps?

Documentation for SYNC intent 提到如果设备的 willReportState 属性 是 true,设备将通过 Real Time Feed 报告其状态。

如何将状态更新写入实时源?我找不到关于它的任何文档。

The documentation可以做到。

首先您需要启用 HomeGraph API 并获得一个 API 密钥。然后,您应该使用 JWT 和以下有效负载向 https://homegraph.googleapis.com/v1/devices:reportStateAndNotification 发送 POST 请求:

{
 "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf",
 "agent_user_id": "1234",
 "payload": {
    "devices": {
      "states": {
        "1458765": {
          "on": true
        },
        "4578964": {
          "on": true,
          "isLocked": true
        }
      }
    }
  }
}