Google Home操作同步有效负载问题

时间:2018-05-05 21:15:52

标签: json actions-on-google google-home

以下是为SYNC意图生成的有效负载。在智能家居验证器中测试时,它会毫无问题地解析json。

同步响应有效负载:

{
    "payload": {
        "agentUserId": "myhome",
        "devices": [
            {
                "traits": [
                    "action.devices.traits.OnOff"
                ],
                "willReportState": false,
                "name": {
                    "defaultNames": [],
                    "name": "Sky Light",
                    "nicknames": []
                },
                "attributes": [],
                "customData": "",
                "id": "BED_LIGHT",
                "type": "action.devices.types.LIGHT",
                "deviceInfo": {
                    "swVersion": "1.0",
                    "model": "Light",
                    "manufacturer": "Connected Smart Life",
                    "hwVersion": "1.0"
                }
            },
            {
                "traits": [
                    "action.devices.traits.OnOff"
                ],
                "willReportState": false,
                "name": {
                    "defaultNames": [],
                    "name": "Ruthu Room Round Light",
                    "nicknames": []
                },
                "attributes": [],
                "customData": "",
                "id": "SWITCH94",
                "type": "action.devices.types.LIGHT",
                "deviceInfo": {
                    "swVersion": "1.0",
                    "model": "Light",
                    "manufacturer": "Connected Smart Life",
                    "hwVersion": "1.0"
                }
            }
        ]
    },
    "requestId": "18338945788402571764"
}

但是,Google智能助理操作无法解析此问题,日志显示在以下错误:

{
  insertId: "1ha0kvhg1kf0a0t"
  logName: "projects/connectedghome/logs/actions.googleapis.com%2Factions"
  receiveTimestamp: "2018-05-05T21:04:27.318451222Z"
  resource: {…}
  severity: "ERROR"
  textPayload: "SYNC: Request ID 18338945788402571764 update devices failed: INVALID_ARGUMENT. Detail: Error: [Expect a map object but found: []] while parsing JSON [{"payload":{"agentUserId":"myhome","devices":[{"attributes":[],"customData":"","deviceInfo":{"hwVersion":"1.0","manufacturer":"Connected Smart Life","model":"Light","swVersion":"1.0"},"id":"BED_LIGHT","name":{"defaultNames":[],"name":"Sky Light","nicknames":[]},"traits":["action.devices.traits.OnOff"],"type":"action.devices.types.LIGHT","willReportState":false},{"attributes":[],"customData":"","deviceInfo":{"hwVersion":"1.0","manufacturer":"Connected Smart Life","model":"Light","swVersion":"1.0"},"id":"SWITCH94","name":{"defaultNames":[],"name":"Ruthu Room Round Light","nicknames":[]},"traits":["action.devices.traits.OnOff"],"type":"action.devices.types.LIGHT","willReportState":false}]},"requestId":"18338945788402571764"}]"
  timestamp: "2018-05-05T21:04:27.284259780Z"
}

我在这里错过了什么吗?

1 个答案:

答案 0 :(得分:0)

属性应该是JSON对象或未定义。