Google智能家居(恒温器)的错误响应

问题描述 投票:0回答:1

我无法理解Json在我尝试过的错误中的语法

return {
        "requestId": self.request_id,
        "payload": {
            "commands": [{
                "ids": [self.device_id],
                "status": "OFFLINE",
                "errorCode": "deviceTurnedOff"
            }]
        }
    }

return {
        "requestId": self.request_id,
        "payload": {
            "errorCode": "authFailure",
            "commands": [{
                "devices":  [{
                    "ids": [self.device_id],
                    "status": "ERROR",
                    "errorCode": "deviceTurnedOff"
                }]
            }]
        }
    }

return {
      "requestId": self.request_id,
      "payload": {
        "errorCode": self.error_code
      }
    }

以上语法都没有工作,大部分时间谷歌主页说你的行为已经执行但我在那里返回错误Json。

我已阅读谷歌行动文档,但未能理解。

actions-on-google google-home google-assistant-sdk google-smart-home
1个回答
1
投票

我提出了一些有效载荷,并在咨询了the docs之后设法使用AoG模拟器成功触发了错误。

Node.js片段:

let resBody = {
    requestId: request.requestId,
    payload: {
        "errorCode": "notSupported"
    }
}
response.status(200).json(resBody);

您确定智能家居请求中的requestId是否相同?你是如何测试这些错误的?

© www.soinside.com 2019 - 2024. All rights reserved.