说明
自动化结构体提供所有自动化行为。它可能包含多个可协同运行的子级自动化操作。
字段
键 | 类型 | 说明 |
---|---|---|
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