reportStateAndNotification 是否支持多个设备状态报告?
does reportStateAndNotification support multiple device state reporting?
我正在尝试通过 API 报告几个设备的状态,但我收到了这个错误
请求负载:
{
"requestId":"3310672920401175639",
"agentUserId":"5d8f3dd42ce05140dc1c6a20",
"payload":{
"devices":{
"states":[
{
"5de28e041729ec0cb40ba906":{
"on":true
}
},
{
"5df49862f53ffa4c1452a448":{
"on":false,
"brightness":100
}
}
]
}
}
}
回复:
{
"error":{
"code":400,
"message":"Invalid JSON payload received. Unknown name "states" at 'payload.devices': Proto field is not repeating, cannot start list.",
"status":"INVALID_ARGUMENT",
"details":[
{
"@type":"type.googleapis.com/google.rpc.BadRequest",
"fieldViolations":[
{
"field":"payload.devices",
"description":"Invalid JSON payload received. Unknown name "states" at 'payload.devices': Proto field is not repeating, cannot start list."
}
]
}
]
}
}
可以"states"保存设备的多个状态吗?还是我做错了什么?
有效载荷中的states
值应该是一个对象,每个唯一的设备ID作为键。它不应该与这些包装成数组一起返回。所以你的请求负载应该看起来更像这样:
{
"requestId":"3310672920401175639",
"agentUserId":"5d8f3dd42ce05140dc1c6a20",
"payload": {
"devices": {
"states": {
"5de28e041729ec0cb40ba906": {
"on": true
},
"5df49862f53ffa4c1452a448": {
"on": false,
"brightness": 100
}
}
}
}
}
我正在尝试通过 API 报告几个设备的状态,但我收到了这个错误
请求负载:
{
"requestId":"3310672920401175639",
"agentUserId":"5d8f3dd42ce05140dc1c6a20",
"payload":{
"devices":{
"states":[
{
"5de28e041729ec0cb40ba906":{
"on":true
}
},
{
"5df49862f53ffa4c1452a448":{
"on":false,
"brightness":100
}
}
]
}
}
}
回复:
{
"error":{
"code":400,
"message":"Invalid JSON payload received. Unknown name "states" at 'payload.devices': Proto field is not repeating, cannot start list.",
"status":"INVALID_ARGUMENT",
"details":[
{
"@type":"type.googleapis.com/google.rpc.BadRequest",
"fieldViolations":[
{
"field":"payload.devices",
"description":"Invalid JSON payload received. Unknown name "states" at 'payload.devices': Proto field is not repeating, cannot start list."
}
]
}
]
}
}
可以"states"保存设备的多个状态吗?还是我做错了什么?
有效载荷中的states
值应该是一个对象,每个唯一的设备ID作为键。它不应该与这些包装成数组一起返回。所以你的请求负载应该看起来更像这样:
{
"requestId":"3310672920401175639",
"agentUserId":"5d8f3dd42ce05140dc1c6a20",
"payload": {
"devices": {
"states": {
"5de28e041729ec0cb40ba906": {
"on": true
},
"5df49862f53ffa4c1452a448": {
"on": false,
"brightness": 100
}
}
}
}
}