Naming your automations
This image is generated using Dall-EPrompt: Generate an image of a robot performing multiple tasks and scanning each task for a name in a minimalistic flat style
Introduction
In the previous post we saw that we can have multiple automations in a single automation file. We also added comments so we know what the automations are without having to reverse engineer the starters and conditions. Instead of using comments we can also give each animation it’s own name.
Adding the name
If we look at a single animation, we can add the name
attribute to the automation object like this.
1
2
3
4
5
6
7
automations:
- name: Turn on all the lights in the morning
starters:
- type: time.schedule
at: 06:00am
condition:
actions:
This makes it very easy to have bigger automations and being able to comprehend what’s happening without having to read through the starters and conditions. If, for example, we take our automation from the previous post we can update it so it looks like this.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
metadata:
name: Motion in hallway
description: Turn on the hallway lights when motion is detected while I'm home and it's dark outside
automations:
- name: Turn on the lights during the day
starters:
- type: device.state.MotionDetection
state: motionDetectionEventInProgress
is: true
device: MS Hallway - Default
condition:
type: and
conditions:
- type: home.state.HomePresence
state: homePresenceMode
is: HOME
- type: time.between
after: sunrise
before: sunset
actions:
- type: device.command.OnOff
on: true
devices: Hallway light - Hallway
- name: Turn on the lights during the night
starters:
- type: device.state.MotionDetection
state: motionDetectionEventInProgress
is: true
device: MS Hallway - Default
condition:
type: and
conditions:
- type: home.state.HomePresence
state: homePresenceMode
is: HOME
- type: time.between
after: sunset
before: sunrise
- type: or
conditions:
- type: device.state.OnOff
state: on
is: true
device: Bedroom Light - Bedroom
- type: device.state.OnOff
state: on
is: true
device: Living room Light - Living Room
actions:
- type: device.command.OnOff
on: true
devices: Hallway light - Hallway
Categories
Related articles