智能家居安防系统指南
action.devices.types.SECURITYSYSTEM
- 安防系统的报警器可以开启和关闭。它们的报警器可以设置为多个安全等级(例如,“在家”与“外出”),安防系统还可以报告有关某些传感器的信息,例如用于检测运动或打开的窗户的传感器。
此类型表示设备会获得安全系统图标以及一些相关的同义词和别名。
设备功能
如需了解实现详情(例如您的服务应支持的属性和状态,以及如何构建 EXECUTE 和 QUERY 响应),请参阅相应的特征文档。
必需的特征
必须具备以下特征和命令(如果适用于您的设备)。
推荐的特征
如果适用,建议采用以下特征。 不过,您也可以自由搭配所有可用的特征,以与您的现有产品功能最相符。
质量要求
- 延迟时间:必须小于或等于 2000 毫秒。
- 可靠性:必须大于或等于 97%。
示例设备:简单安防系统
本部分包含根据上述设备类型和特征表示常见的“安全系统”的 intent 载荷示例。如果您在实现中添加或移除特征,请相应地修改响应以反映这些更改。
SYNC 响应示例
{ "requestId": "6894439706274654512", "inputs": [ { "intent": "action.devices.SYNC" } ] }
{ "requestId": "6894439706274654512", "payload": { "agentUserId": "user123", "devices": [ { "id": "123", "type": "action.devices.types.SECURITYSYSTEM", "traits": [ "action.devices.traits.StatusReport", "action.devices.traits.ArmDisarm" ], "name": { "name": "Simple security system" }, "willReportState": true, "attributes": { "availableArmLevels": { "levels": [ { "level_name": "home_key", "level_values": [ { "level_synonym": [ "Home and Guarding", "level 1", "home", "SL1" ], "lang": "en" } ] }, { "level_name": "away_key", "level_values": [ { "level_synonym": [ "Away and Guarding", "level 2", "away", "SL2" ], "lang": "en" } ] } ], "ordered": 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, "isArmed": true, "currentArmLevel": "home_key", "currentStatusReport": [ { "blocking": false, "deviceTarget": "123", "priority": 0, "statusCode": "lowBattery" } ] } } } }
EXECUTE 命令示例
ArmDisarm
如需详细了解命令参数,请参阅
action.devices.traits.ArmDisarm
参考文档。
{ "requestId": "6894439706274654516", "inputs": [ { "intent": "action.devices.EXECUTE", "payload": { "commands": [ { "devices": [ { "id": "123" } ], "execution": [ { "command": "action.devices.commands.ArmDisarm", "params": { "arm": true, "armLevel": "away_key" } } ] } ] } } ] }
{ "requestId": "6894439706274654516", "payload": { "commands": [ { "ids": [ "123" ], "status": "SUCCESS", "states": { "online": true, "isArmed": true, "currentArmLevel": "away_key" } } ] } }
设备错误
查看错误和异常的完整列表。开启报警器异常
尝试开启或关闭系统时,您可以通过通过 StatusReport 特征报告的异常代码提供额外的上下文。 异常可以报告为阻塞或不阻塞。
- 如果报告的非阻塞异常为“SUCCESS”状态,则表示该异常不会阻止关闭报警器或关闭报警器。
- 报告为“EXCEPTIONS”状态的屏蔽异常表示因这些异常而停止报警或停用报警功能。
通常与安全系统相关联的异常代码包括:
doorOpen
:车门是开着的。windowOpen
:打开了一个窗口。isOpen
:传感器检测到某个内容处于打开状态(但不知道它是门还是窗)。
示例:非阻塞异常
此示例展示了一种非阻塞的例外情况,即即使报告了窗口处于打开状态,安防系统也可能会开启。
用户 | 将安防系统设为高安全性 |
Google 助理 | 好的,前窗打开了。将安防系统开启到高安保模式 |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.ArmDisarm", "params": { "arm": true, "armLevel": "L2" } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [ { "ids": [ "123" ], "status": "SUCCESS", "states": { "online": true, "isArmed": true, "currentArmLevel": "L2", "currentStatusReport": [ { "blocking": false, "priority": 0, "statusCode": "windowOpen", "deviceTarget": "sensor_id1" } ] } } ] } }
示例:屏蔽异常
用户 | 将安防系统设为高安全性 |
Google 助理 | 控制安防系统时出错。前窗是开着的 |
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.ArmDisarm", "params": { "arm": true, "armLevel": "L2" } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [ { "ids": [ "123" ], "status": "SUCCESS", "states": { "online": true, "isArmed": false, "currentArmLevel": "L2", "currentStatusReport": [ { "blocking": true, "priority": 0, "statusCode": "windowOpen", "deviceTarget": "sensor_id1" } ] } } ] } }
使用双重验证启动
如果您的报警流程要求用户通过双重身份验证对话框输入 PIN 码,您必须确认当存在例外情况时(例如窗口或门打开时),他们是否希望继续开启系统。
在这种情况下,您可能需要输入 PIN 码或口令,然后再输入相应的确认信息。
示例:确认验证
此示例显示用户尝试开启安防系统报警器,但检测到前门处于打开状态。用户确认即使前门开着,安防系统仍应开启。
用户 | 开启安防系统。 |
Google 助理 | 前门是开着的。确定要开启安防系统吗? |
用户 | 是。 |
Google 助理 | 好的,正在开启安防系统。 |
第一步,您应该在回答时提供 ackNeeded
质询。
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.ArmDisarm", "params": { "arm": true } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [ { "ids": [ "123" ], "status": "ERROR", "errorCode": "challengeNeeded", "challengeNeeded": { "type": "ackNeeded" }, "states": { "isArmed": true, "currentArmLevel": "L2", "currentStatusReport": [ { "blocking": false, "priority": 0, "statusCode": "doorOpen", "deviceTarget": "456" } ] } } ] } }
Google 后续向您发送的请求将包含 ack
结果。
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.ArmDisarm", "params": { "arm": true }, "challenge": { "ack": true } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [ { "ids": [ "123" ], "status": "SUCCESS", "states": { "isArmed": true } } ] } }
示例:PIN 码和确认质询
此示例展示了用户尝试开启需要输入 PIN 码的安全系统的报警器。系统会检测到前窗和后窗都是开着的,并让用户确认应该开启报警器。
用户 | 安保报警。 |
Google 助理 | 您的 PIN 码是什么? |
用户 | 1234。 |
Google 助理 | 前窗和后窗似乎处于打开状态。确定要继续关闭安防系统吗? |
用户 | 是。 |
Google 助理 | 好的,正在将安防系统开启 |
首先,您应该以标准的 pinNeeded
质询回应。
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [{ "id": "123" }], "execution": [{ "command": "action.devices.commands.ArmDisarm", "params": { "arm": true } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["456"], "status": "ERROR", "errorCode": "challengeNeeded", "challengeNeeded": { "type": "pinNeeded" } }] } }
然后,Google 会跟进包含所提供的 PIN 码的请求。为了支持第二次转场,您应在响应中提供 ackNeeded
质询,并提供更多相关信息,包括目标实验组级别和当前屏蔽状态的异常报告。
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [...], "execution": [{ "command": "action.devices.commands.ArmDisarm", "params": { "arm": true, "armLevel": "away" }, "challenge": { "pin": "1234" } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [{ "ids": ["456"], "status": "ERROR", "states": { "targetArmLevel": "away", "currentStatusReport": [{ "blocking": true, "priority": 1, "deviceTarget": "front_window_id", "statusCode": "deviceOpen" }, { "blocking": true, "priority": 1, "deviceTarget": "back_window_id", "statusCode": "deviceOpen" } ] }, "errorCode": "challengeNeeded", "challengeNeeded": { "type": "ackNeeded" } }] } }
Google 后续向您发送的请求将仅包含 ack
结果,而不包含第一次转弯中提供的 PIN 码。
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "inputs": [{ "intent": "action.devices.EXECUTE", "payload": { "commands": [{ "devices": [...], "execution": [{ "command": "action.devices.commands.ArmDisarm", "params": { "arm": true, "armLevel": "away" }, "challenge": { "ack": true } }] }] } }] }
{ "requestId": "ff36a3cc-ec34-11e6-b1a0-64510650abcf", "payload": { "commands": [ { "ids": [ "123" ], "status": "SUCCESS", "states": { "isArmed": true } } ] } }