智慧型住宅洗衣機指南
action.devices.types.WASHER
- 洗衣機可以任意啟動和停止功能,不受開關影響 (部分洗衣機有獨立的電源鍵,部分洗衣機沒有)。有些可在清洗時暫停並繼續。
洗衣機也有多種模式,每種模式都有各自的設定。這些是屬於洗衣機的專屬資訊,會以一般化的形式解譯。
這個類型表示裝置會取得洗衣機圖示和一些相關的同義詞和別名。
如果想查看如何使用 Google 智慧型住宅控制洗衣機的範例,請參閱「智慧型住宅洗衣機」程式碼研究室。
裝置功能
請參閱對應的特徵說明文件,瞭解實作詳情,例如瞭解服務支援的屬性和狀態,以及如何建構 EXECUTE 和 QUERY 回應。
必要特徵
您需要這些 traits 和指令 (如果裝置適用的話)。如果您的裝置不支援這些特徵,請在 QUERY 或 EXECUTE 回應中輸入 functionNotSupported
的錯誤代碼。詳情請參閱「錯誤與例外狀況」一節。
推薦 traits
建議使用這些 traits (適用於您的裝置)。不過,您可以自由混用所有可用特徵,以最符合現有產品功能的需求。
-
action.devices.traits.Modes
-
action.devices.traits.OnOff
-
action.devices.traits.RunCycle
-
action.devices.traits.Toggles
品質規定
- 延遲時間:必須小於或等於 3000 毫秒。
- 可靠性:必須大於或等於 97%。
裝置範例:簡易洗衣機
本節包含代表上述裝置類型和特徵的意圖酬載範例,代表一個常見的「Washer」。如果您在實作中新增或移除特徵,請根據變更來修改回應。
SYNC 回應範例
{ "requestId": "6894439706274654512", "inputs": [ { "intent": "action.devices.SYNC" } ] }
{ "requestId": "6894439706274654512", "payload": { "agentUserId": "user123", "devices": [ { "id": "123", "type": "action.devices.types.WASHER", "traits": [ "action.devices.traits.OnOff", "action.devices.traits.RunCycle", "action.devices.traits.StartStop", "action.devices.traits.Modes" ], "name": { "name": "Simple washer" }, "willReportState": true, "attributes": { "availableModes": [ { "name": "load_key", "name_values": [ { "name_synonym": [ "Load", "Size", "Load size" ], "lang": "en" } ], "settings": [ { "setting_name": "small_key", "setting_values": [ { "setting_synonym": [ "Small", "Half" ], "lang": "en" } ] }, { "setting_name": "large_key", "setting_values": [ { "setting_synonym": [ "Large", "Full" ], "lang": "en" } ] } ], "ordered": true } ], "pausable": 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, "on": true, "isRunning": true, "isPaused": false, "currentRunCycle": [ { "currentCycle": "rinse", "nextCycle": "spin", "lang": "en" } ], "currentTotalRemainingTime": 600, "currentCycleRemainingTime": 300, "currentModeSettings": { "load_key": "small_key" } } } } }
EXECUTE 指令範例
OnOff
如要進一步瞭解指令參數,請參閱
action.devices.traits.OnOff
參考資料。
{ "requestId": "6894439706274654516", "inputs": [ { "intent": "action.devices.EXECUTE", "payload": { "commands": [ { "devices": [ { "id": "123" } ], "execution": [ { "command": "action.devices.commands.OnOff", "params": { "on": true } } ] } ] } } ] }
{ "requestId": "6894439706274654516", "payload": { "commands": [ { "ids": [ "123" ], "status": "SUCCESS", "states": { "online": true, "on": true } } ] } }
StartStop
如要進一步瞭解指令參數,請參閱
action.devices.traits.StartStop
參考資料。
{ "requestId": "6894439706274654518", "inputs": [ { "intent": "action.devices.EXECUTE", "payload": { "commands": [ { "devices": [ { "id": "123" } ], "execution": [ { "command": "action.devices.commands.StartStop", "params": { "start": true } } ] } ] } } ] }
{ "requestId": "6894439706274654518", "payload": { "commands": [ { "ids": [ "123" ], "status": "SUCCESS", "states": { "online": true, "isRunning": true, "isPaused": false } } ] } }
SetModes
如要進一步瞭解指令參數,請參閱
action.devices.traits.Modes
參考資料。
{ "requestId": "6894439706274654522", "inputs": [ { "intent": "action.devices.EXECUTE", "payload": { "commands": [ { "devices": [ { "id": "123" } ], "execution": [ { "command": "action.devices.commands.SetModes", "params": { "updateModeSettings": { "load_key": "large_key" } } } ] } ] } } ] }
{ "requestId": "6894439706274654522", "payload": { "commands": [ { "ids": [ "123" ], "status": "SUCCESS", "states": { "online": true, "currentModeSettings": { "load_key": "large_key" } } } ] } }