I'm encountering an issue with Google Assistant when I request to "turn on all devices." Even when I send a "FAILED" status for some devices, Google Assistant responds with "Ok, turning on x things" without any indication of the failure. Here's the JSON response I'm sending for the action.devices.EXECUTE action:
当我请求“打开所有设备”时,我遇到了谷歌助手的问题。即使当我为某些设备发送“失败”状态时,Google Assistant的响应也是“OK,正在打开x个东西”,而没有任何失败的迹象。下面是我为action.devices.EXECUTE操作发送的JSON响应:
{
"requestId": "617XXX27787XXX16813",
"payload": {
"devices": {
"1081614XXX": {
"on": false,
"online": true,
"status": "SUCCESS"
},
// ... (other device entries)
"4153991XXX": {
"on": false,
"online": true,
"status": "FAILED"
}
}
}
}
Here's an overview of how my system works:
以下是我的系统工作原理的概述:
- I issue a command to Google Assistant to turn devices on/off.
- Google Assistant triggers my Lambda function.
- My Lambda function processes the request and calls backend APIs. It processes as many requests/devices as possible within 4 seconds. After 4 seconds, it sends a "FAILED" status for any remaining devices and "PENDING" for devices with a 202 HTTP Status Code. This is done to respond to Google Home within the 5-second time limit.
I have several questions:
我有几个问题:
Does Google Assistant provide a negative response for devices with a "FAILED" status, such as "Unable to turn on/off device"? I'm not receiving such responses.
I tried actuating a single device with a default status of "PENDING" and "FAILED," but I still received the same response ("Ok, turning on the <name of the device>"). Why is this happening?
Is there anything I might be missing in the response I'm sending to Google Assistant?
I'm facing a challenge when I have more than 20 devices to process within the 5-second time limit. Currently, I'm sending "PENDING" for devices with successful actuation but which take time. Is there a better approach to handle this issue without sending "FAILED"?
当我有20多台设备要在5秒的时间内处理时,我面临着一个挑战。目前,我正在发送“待定”的设备与成功的启动,但需要时间。有没有更好的方法来处理这个问题而不发送“失败”?
I appreciate any insights or suggestions to improve this situation. Thank you!
我感谢任何改善这种情况的见解或建议。谢谢!
更多回答
优秀答案推荐
The issue was with the status
key itself, it should have been ERROR
and not FAILED
.
问题出在状态键本身,它应该是错误的,而不是失败。
Here's an example:
下面是一个例子:
{
"requestId": "617XXX27787XXX16813",
"payload": {
"devices": {
"1081614XXX": {
"on": false,
"online": true,
"status": "SUCCESS"
},
// ... (other device entries)
"4153991XXX": {
"on": false,
"online": true,
"status": "ERROR",
"errorCode": "Timeout"
}
}
}
}
更多回答
我是一名优秀的程序员,十分优秀!