Google Home App无法显示漏水传感器状态的技术问题咨询
问题:Google Home App无法显示漏水传感器状态
我尝试将Water Leak Sensor作为SENSOR设备添加至Google Smart Home,开发应用服务器时遵循了Google官方传感器指南,针对action.devices.SYNC请求返回的响应已通过Validator验证无错误,但在Google Home App中查看此设备时仅显示设备设置,无法查看传感器状态。
我的SYNC响应内容如下:
{ "requestId": "6894439706274654512", "payload": { "agentUserId": "2225babc-0569-4a34-8b33-e52decacb832", "devices": [ { "id": "11385100264604812424-~-sensor_rf-~--~-", "type": "action.devices.types.SENSOR", "traits": [ "action.devices.traits.SensorState" ], "roomHint": "Кухня", "name": { "name": "UJIN Aqua-sense" }, "willReportState": true, "notificationSupportedByAgent": true, "attributes": { "sensorStatesSupported": [ { "name": "WaterLeak", "descriptiveCapabilities": { "availableStates": [ "leak", "no leak" ] } } ] } } ] } }
排查与解决方案
1. 修正传感器状态枚举值
Google官方对漏水传感器的状态值有明确规范,需使用detected(检测到漏水)和not_detected(未检测到漏水),而非自定义的leak和no leak。修改SYNC响应中的attributes部分:
"attributes": { "sensorStatesSupported": [ { "name": "WaterLeak", "descriptiveCapabilities": { "availableStates": [ "detected", "not_detected" ] } } ] }
2. 确保STATE响应正确返回
Google Home App的状态展示依赖action.devices.QUERY请求的响应或主动上报的action.devices.REPORT_STATE请求:
- 处理QUERY请求时,返回包含传感器状态的payload示例:
{ "requestId": "请求ID", "payload": { "devices": { "11385100264604812424-~-sensor_rf-~--~-": { "status": "SUCCESS", "online": true, "sensorState": { "WaterLeak": "not_detected" } } } } }
- 若开启
willReportState: true,设备状态变化时需主动向谷歌发送REPORT_STATE请求,确保状态实时同步。
3. 验证设备在线状态
所有状态响应中必须包含online: true,若设备被标记为离线,Google Home App仅会展示设置选项。
4. 重新同步设备
在Google Home App中移除该设备后重新添加,或触发一次SYNC请求,确保谷歌端更新设备的最新配置。
内容的提问来源于stack exchange,提问作者Sonya Anokhovskaya
相关产品推荐
相关产品推荐

