智能家居传感器指南
action.devices.types.SENSOR
- 单个传感器有多种功能,例如同时监测温度和湿度。传感器可以报告定量测量值(例如,一氧化碳和烟雾浓度以百万分之一为单位),也可以报告定量测量值(例如空气质量状况是否良好)。
此类型表示设备会获得传感器图标和一些相关的同义词和别名。
设备功能
如需了解相应的实现详情(例如您的服务应支持的属性和状态),以及如何构建 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.SENSOR", "traits": [ "action.devices.traits.EnergyStorage", "action.devices.traits.SensorState" ], "name": { "name": "Simple sensor" }, "willReportState": true, "attributes": { "sensorStatesSupported": [ { "name": "AirQuality", "descriptiveCapabilities": { "availableStates": [ "healthy", "moderate", "unhealthy", "very unhealthy" ] } } ], "queryOnlyEnergyStorage": true }, "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": "AirQuality", "currentSensorState": "healthy" } ], "descriptiveCapacityRemaining": "HIGH", "capacityRemaining": [ { "unit": "PERCENTAGE", "rawValue": 90 } ] } } } }