自動化

說明

自動化結構體會提供所有自動化行為。可能包含多個可協同運作的子自動化動作。

欄位

類型 說明
name String

此自動化動作的內部名稱,供開發人員參考。

選用

starters [Starter]

自動化動作啟動條件。

必填

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