【问题标题】:SensorState Smoke Sensor NotificationSensorState 烟雾传感器通知
【发布时间】:2023-02-23 02:13:23
【问题描述】:

检测到烟雾时我无法收到通知。这里有什么问题?有github的例子吗?

已关注: https://developers.google.com/assistant/smarthome/develop/notifications#proactive-notification-payload

语音通知在我的手机中“打开”。

..

通知请求函数工作在exports.reportstate下:

            var randomrequestId = (Math.floor(1000000000 + Math.random() * 9000000000) * 123).toString();
            var randomeventId = (Math.floor(1000000000 + Math.random() * 9000000000) * 11).toString();

            const res = await homegraphClient.devices.reportStateAndNotification({
              requestBody: {
                agentUserId: kullanici,
                eventId: randomeventId,
                requestId: randomrequestId,
                payload: {
                  devices: {
                    notifications: {
                      [deviceId]: {
                        SensorState: {
                          priority: 0,
                          name: "SmokeLevel",
                          currentSensorState: "smoke detected",
                        }
                      }
                    }
                  }
                }
              }
            });

我可以看到 home graph viewer 的变化,按预期工作..

homegraph1homegraph2-smoke detected ..

这是来自云功能日志的响应

{
  "config": {
    "url": "https://homegraph.googleapis.com/v1/devices:reportStateAndNotification",
    "method": "POST",
    "userAgentDirectives": [
      {
        "product": "google-api-nodejs-client",
        "version": "4.4.3",
        "comment": "gzip"
      }
    ],
    "data": {
      "requestId": "1202169683718",
      "eventId": "35996036483",
      "agentUserId": "dafdafdfadaf@gmail-com",
      "payload": {
        "devices": {
          "notifications": {
            "484BA8-1": {
              "SensorState": {
                "priority": 0,
                "name": "SmokeLevel",
                "currentSensorState": "smoke detected"
              }
            }
          }
        }
      }
    },
    "headers": {
      "x-goog-api-client": "gdcl/4.4.3 gl-node/10.24.1 auth/6.1.3",
      "Accept-Encoding": "gzip",
      "User-Agent": "google-api-nodejs-client/4.4.3 (gzip)",
      "Authorization": "Bearer ya29.c.b0AXv0zTMEKY7pLs6MVA_PPM4Ax9U-zvQB6klzF98HZyZXUfdahbvJk5nXScEbBh95H9RD_4tsqskXeiYDK7wtpkUHzuLgnFKr2bwn3l-MEQVMY_l-Sd4awUOy75SQ1imXRURwxcrhagKael0ZtACVYValnRzQe-Ue16xDBN4JVawMPQOvfVRE3RZmNVxPi2_QZYtsy8Tq0wH3SJ8-gLfn9IHoocWKvYPF0G02DFouOlbMuYNa7oOYQEzNa5Ni62p__spJUXCnvlEplUxrVi8WbAVw8WTL0ny0lMyxZLmmzIeU....................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................",
      "Content-Type": "application/json",
      "Accept": "application/json"
    },
    "params": {},
    "retry": true,
    "body": "{\"requestId\":\"1202169683718\",\"eventId\":\"35996036483\",\"agentUserId\":\"dafdafdfadaf@gmail-com\",\"payload\":{\"devices\":{\"notifications\":{\"484BA8-1\":{\"SensorState\":{\"priority\":0,\"name\":\"SmokeLevel\",\"currentSensorState\":\"smoke detected\"}}}}}}",
    "responseType": "json"
  },
  "data": {
    "requestId": "1202169683718"
  },
  "headers": {
    "alt-svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"",
    "cache-control": "private",
    "connection": "close",
    "content-encoding": "gzip",
    "content-type": "application/json; charset=UTF-8",
    "date": "Wed, 06 Jul 2022 07:46:35 GMT",
    "server": "ESF",
    "transfer-encoding": "chunked",
    "vary": "Origin, X-Origin, Referer",
    "x-content-type-options": "nosniff",
    "x-frame-options": "SAMEORIGIN",
    "x-xss-protection": "0"
  },
  "status": 200,
  "statusText": "OK",
  "request": {
    "responseURL": "https://homegraph.googleapis.com/v1/devices:reportStateAndNotification"
  }
}

fb 中的数据: attributes, currentsensordata ...

【问题讨论】:

    标签: notifications google-home google-smart-home


    【解决方案1】:

    Google Assistant 在智能扬声器和智能显示器上以语音通知的形式向用户提供主动通知。目前,手机设备上的 Google Home 应用不支持语音通知。

    【讨论】:

      猜你喜欢
      • 2011-12-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-02
      • 2012-09-13
      相关资源
      最近更新 更多