自動化

說明

自動化架構會提供所有自動化行為。當中可能包含多項可以搭配使用的子項自動化動作。

欄位

索引鍵 類型 說明
name 字串

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

選用

可使用變數。

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: 11:00 pm
  actions:
  - type: device.command.OnOff
    devices: TV - Living Room
    on: false
  - type: assistant.command.Broadcast
    message: time to sleep