欢迎使用 Google Home 开发者中心,您可以在这里学习有关如何开发智能家居 Action 的新平台。注意:你将继续在 Actions 控制台中构建操作。
使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。

智能烟雾检测器指南

action.devices.types.SMOKE_DETECTOR - 烟雾检测器可以报告当前是否检测到烟雾、烟雾水平是否较高,以及当前的烟雾水平(以百万分之一为单位)。

此类型表示设备会获得烟雾检测器图标以及一些相关的同义词和别名。

设备功能

如需了解相应的实现详情(例如您的服务应支持的属性和状态),以及如何构建 EXECUTE 和 QUERY 响应,请参阅相应的特征文档。

所需特征

这些特征和指令(若适用于您的设备)是必需的。

质量要求

  • 延迟时间:必须小于或等于 1000 毫秒
  • 可靠性:必须大于或等于 97%

示例设备:简单的烟雾检测器

本部分包含基于上述设备类型和特征表示常见“烟雾检测器”的 intent 载荷示例。如果您在实现中添加或移除特征,请相应地修改响应以反映这些变化。

SYNC 响应示例

请求
{
  "requestId": "6894439706274654512",
  "inputs": [
    {
      "intent": "action.devices.SYNC"
    }
  ]
}
响应
{
  "requestId": "6894439706274654512",
  "payload": {
    "agentUserId": "user123",
    "devices": [
      {
        "id": "123",
        "type": "action.devices.types.SMOKE_DETECTOR",
        "traits": [
          "action.devices.traits.SensorState"
        ],
        "name": {
          "name": "Simple smoke detector"
        },
        "willReportState": true,
        "attributes": {
          "sensorStatesSupported": [
            {
              "name": "SmokeLevel",
              "descriptiveCapabilities": {
                "availableStates": [
                  "smoke detected",
                  "high",
                  "no smoke detected"
                ]
              },
              "numericCapabilities": {
                "rawValueUnit": "PARTS_PER_MILLION"
              }
            }
          ]
        },
        "deviceInfo": {
          "manufacturer": "smart-home-inc",
          "model": "hs1234",
          "hwVersion": "3.2",
          "swVersion": "11.4"
        }
      }
    ]
  }
}

QUERY 响应示例

请求
{
  "requestId": "6894439706274654514",
  "inputs": [
    {
      "intent": "action.devices.QUERY",
      "payload": {
        "devices": [
          {
            "id": "123"
          }
        ]
      }
    }
  ]
}
响应
{
  "requestId": "6894439706274654514",
  "payload": {
    "devices": {
      "123": {
        "status": "SUCCESS",
        "online": true,
        "currentSensorStateData": [
          {
            "name": "SmokeLevel",
            "currentSensorState": "high",
            "rawValue": 200
          }
        ]
      }
    }
  }
}

设备出错

查看错误和异常的完整列表。