智慧型住宅保全系統指南
action.devices.types.SECURITYSYSTEM
:保全系統可啟動及解除。這類攝影機可在多層安全等級 (例如在家和外出) 下啟動,並回報特定感應器的相關資訊,例如可偵測動作或未開啟窗戶的感應器。
這個類型代表裝置會取得保全系統圖示和一些相關的同義詞和別名。
裝置功能
如要瞭解實作詳情 (例如屬性和狀態),以及服務應支援的屬性和狀態,以及如何建構 EXECUTE 和 QUERY 回應,請參閱對應特徵的說明文件。
必要特性
您必須具有這些特徵和指令 (如果裝置適用的話)。如果您的裝置不支援這些特徵,請在 QUERY 或 EXECUTE 回應中輸入 functionNotSupported
的錯誤代碼。詳情請參閱「錯誤和例外狀況」。
推薦特性
建議您採用這些特性 (如果裝置適用)。不過,您可以自由搭配運用所有可用的特徵,以符合現有的產品功能。
品質規定
- 延遲時間:必須小於或等於 2000 毫秒。
- 可靠性:必須大於或等於 97%。
裝置範例:簡易型安全防護系統
本節包含代表上述裝置類型和特徵的常見「安全系統」的意圖酬載範例。如果您在實作中新增或移除特徵,請據此修改回應以反映這些變更。
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 特徵回報的例外狀況代碼提供額外背景資訊。例外狀況可以回報為封鎖或非封鎖。
- 如果非封鎖例外狀況的狀態為「成功」,代表例外狀況並未阻止系統啟動或解除。
- 如果「封鎖例外狀況」處於「EXCEPTIONS」狀態,代表啟動或解除攻擊因這些例外狀況而停止。
與安全系統相關的例外狀況代碼包括:
doorOpen
:有一扇門開著。windowOpen
:視窗已開啟。isOpen
:感應器偵測到東西處於開啟狀態,但無法判斷這是門或窗戶。
示例:非封鎖的例外狀況
這個範例顯示了一個非阻塞例外狀況,也就是保全系統即使已回報為開啟,仍會啟動。
User | 將保全系統設為「高安全性」 |
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"
}
]
}
}
]
}
}
範例:封鎖例外狀況
User | 將保全系統設為「高安全性」 |
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": "EXCEPTIONS",
"states": {
"online": true,
"isArmed": false,
"currentArmLevel": "L2",
"currentStatusReport": [
{
"blocking": true,
"priority": 0,
"statusCode": "windowOpen",
"deviceTarget": "sensor_id1"
}
]
}
}
]
}
}
使用雙重驗證啟動系統
如果啟動流程要求使用者透過雙重驗證對話方塊輸入 PIN 碼,您必須確認使用者在出現有效的例外狀況時 (例如窗戶或門是開啟時),是否要繼續啟動系統。
這類情況可能需要「同時」輸入 PIN 碼或通關密語,接著加上確認訊息。
例如:認可驗證問題
這個範例顯示使用者嘗試啟動保全系統,但系統偵測到前門處於開啟狀態。使用者瞭解即使前門已開啟,保全系統仍應啟動。
User | 啟動保全系統 |
Google 助理 | 前門開著。 確定要啟動保全系統嗎? |
User | 可以。 |
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 碼的保全系統。系統會偵測到前窗和後側視窗為開啟狀態,並要求使用者確認啟動程序應繼續進行。
User | 主動出擊, |
Google 助理 | 請提供你的 PIN 碼 |
User | 1234。 |
Google 助理 | 前視窗和後窗似乎為開啟狀態。確定要繼續啟動保全系統嗎? |
User | 可以。 |
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 } } ] } }