action.devices.QUERY
此 intent 会向你的执行方式查询设备的当前状态,包括设备是否在线以及是否可触及。
您的 QUERY 响应应仅返回状态信息。
更新设备属性和特征的操作由
SYNC 响应。
如需了解详情,请参阅查询和执行。
请求格式
| 字段 | 类型 | 说明 | 
|---|---|---|
requestId | 
    String | 
       必填。 请求的 ID。  | 
  
inputs | 
    数组 | 
       必填。 与 intent 请求匹配的输入列表。  | 
  
[item, ...] | 
    对象 | 
       与 intent 请求关联的类型和载荷。  | 
  
intent | 
    
       必填。 (常量值: intent 请求类型。  | 
  |
payload | 
    对象 | 
       必填。 QUERY 请求载荷。  | 
  
devices | 
    数组 | 
       必填。 目标设备列表。  | 
  
[item, ...] | 
    对象 | 
       要查询的设备定位条件。  | 
  
id | 
    String | 
       必填。 设备 ID(根据 SYNC 中提供的 ID)。  | 
  
customData | 
    对象 | 
       如果在 SYNC 中提供了不透明的 customData 对象,则该对象会发送到此处。  | 
  
示例
QUERY intent 请求
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [ { "intent": "action.devices.QUERY", "payload": { "devices": [ { "id": "123", "customData": { "fooValue": 74, "barValue": true, "bazValue": "foo" } }, { "id": "456", "customData": { "fooValue": 12, "barValue": false, "bazValue": "bar" } } ] } } ] }
响应格式
| 字段 | 类型 | 说明 | 
|---|---|---|
requestId | 
    String | 
       必填。 相应请求的 ID。  | 
  
payload | 
    对象 | 
       必填。 intent 响应载荷。  | 
  
errorCode | 
    String | 
       针对身份验证失败和开发者系统不可用的整个事务的错误代码。对于单个设备错误,请在设备对象中使用 errorCode。  | 
  
debugString | 
    String | 
       详细错误,此类错误永远不会向用户显示,但可能会在开发过程中被记录或使用。  | 
  
devices | 
    对象 | 
       必填。 设备地图。将开发者设备 ID 映射到状态属性的对象。  | 
  
<string> | 
    对象 | 
       设备状态。  | 
  
online | 
    布尔值 | 
       必填。 指示设备是否在线(即可连接)。  | 
  
status | 
    String | 
       必填。 查询操作的结果。 支持的值: 
  | 
  
errorCode | 
    String | 
       根据需要从预设的错误代码扩展 ERROR 状态,该状态将映射到呈现给用户的错误。  | 
  
示例
QUERY intent 响应
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "devices": { "123": { "on": true, "online": true, "status": "SUCCESS" }, "456": { "on": true, "online": true, "status": "SUCCESS", "brightness": 80, "color": { "spectrumRgb": 16711935 } } } } }