自動化

說明

Automation Struct 提供所有自動化行為。當中可能包含多個可協同運作的子自動化動作。

欄位

金鑰 類型 說明
name String

開發人員可參考的自動化內部名稱。

選用

starters [入門]

自動化動作啟動條件。

必填

condition 條件

要套用的全域條件。

選用

actions [動作]

自動化動作。

必填

範例

使用單一自動化動作:在下午 6 點開啟燈具。

automations:
  starters:
    type: time.schedule
    at: 6:00 pm
  actions:
    type: device.command.OnOff
    devices: Light A - Living Room
    on: true

在指令碼中使用多個自動化動作: * 晚上 6 點開啟燈具。 * 晚上 11 點關閉電視,並廣播「該睡覺了」

automations:
- name: At 6pm, turn on light.
  starters:
    type: time.schedule
    at: 6:00 pm
  actions:
    type: device.command.OnOff
    devices: Light A - Living Room
    on: true
- name: At 11pm, turn off TV and broadcast "time to sleep"
  starters:
    type: time.schedule
    at: 6:00 pm
  actions:
  - type: device.command.OnOff
    devices: TV - Living Room
    on: false
  - type: assistant.command.Broadcast
    message: time to sleep