Understanding automations
All automationsAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more] are made of at least a triggerA trigger is the part of an automation that makes the automation start when something specific happens, for example, when the sun sets, a door opens, or a button is pressed. [Learn more] and an actionAn action makes Home Assistant do something, for example, turn on a light, send a notification, or activate a scene. Automations and scripts run a list of actions. [Learn more]. Optionally combined with a conditionConditions check whether something is true at that moment, for example, whether a door is closed. You can use them in automations and scripts. If a condition is not met, the actions that come after it in the same sequence do not run. At the top level of an automation or script, this stops the automation or script. [Learn more]. Take for example the automation:
When Paulus enters home and it is after sunset, turn on the lights in the living room.
Parts of an automation
The previous automation example has the following three parts:
(trigger part) When Paulus enters home
(condition part) and it is after sunset
(action part) turn on the lights in the living room
Trigger part
The trigger belongs to the first part of the automation. When the trigger part is verified, the automation starts.
Condition part
The second part of an automation has the condition. If the condition is verified, the action part takes place. In the example of the automation above, the lights in the living room will turn on only if the sun has set. If Paulus comes home before sunset, nothing happens when the sun sets later. For why, and how to cover both cases, refer to how automations react to changes.
Action part
The last part of an automation has the action. The action part will be performed only if the trigger and condition parts are met. Some examples of actions are: turn on a light, set the temperature on a thermostat or activate a scene.
Creating automations
Now that you’ve got a sneak peek of what is possible, it’s time to get your feet wet and create your first automation.
By default, create automations with the visual editor, one of the available automation editors. You can create an automation in the visual editor of the UI by following the steps below.
- Go to Settings > Automations & scenes.
- In the lower right corner, select Create automation > Create new automation.
Adding a trigger
- In the When section, select Add trigger.
- Now you can do one of the following:
- Select a target and then a trigger.
- Under By target, select the entity, device or service to which you want to apply the trigger to. You can find the available entities, devices or services listed by:
- Area of your home, in the Home section.
- Entities, Devices and Services, in the Unassigned section.
- Labels that you have previously created, in the Labels section.
- For that target, you can see the available triggers on the right side. Select + on the desired one.
- Under By target, select the entity, device or service to which you want to apply the trigger to. You can find the available entities, devices or services listed by:
- Select a trigger.
- Select By type, and then select the trigger type from the list on the left.
- From the listed triggers, select + on the one you choose.
- Search for a trigger or target and then select a trigger.
- Enter the name of one of the following in the search box:
- A target: an entity, a device or a service.
- A group of targets: an area or label.
- A trigger.
- From the listed results, select + on the desired trigger.
- Enter the name of one of the following in the search box:
- Select a target and then a trigger.
- In the window on the right, you will have different options depending on the selected trigger. You might find the following ones, for example:
- Under Targets, you can select the first target or another one by selecting Add target.
- Do one of the following:
- Select an entity, device or service to monitor a specific one.
- Select entities, devices or services in an area, floor or with a certain label to monitor a group of them.
- You can add more targets by selecting Add target again.
- Do one of the following:
- Under Trigger when, if you monitor more than one target, you can decide when the automation starts:
- Each: Every time one of the targets makes the change that the trigger reacts to, for example, every time one of the lights turns on.
- First: The first time one of the targets makes that change. The trigger reacts again only after all targets have changed back.
- All: Once all targets have made that change, for example, when the last of the lights turns on.
- Under Targets, you can select the first target or another one by selecting Add target.
- Select Save.
Adding a condition
Note that you don´t need to add a condition to create an automation.
- In the And if section, select Add condition.
- Under Blocks, you have the following options:
- If you want to make sure that a condition is not verified for the automation to run, select + on the Not block.
- If you will add more than one condition, you can select:
- the And block to make sure all conditions are verified for the automation to run.
- the Or block to make sure at least one of the conditions is verified for the automation to run.
- Select Add condition again and now you can:
- Select a target and then a condition.
- Under By target, select the entity, device or service to which you want to apply the condition to. You can find the available entities, devices or services listed by:
- Area of your home, in the Home section.
- Entities, Devices and Services, in the Unassigned section.
- Labels that you have previously created, in the Labels section.
- For that target, you can see the available conditions on the right side. Select + on the desired one.
- Under By target, select the entity, device or service to which you want to apply the condition to. You can find the available entities, devices or services listed by:
- Select a condition.
- Select By type, and then select the condition type from the list on the left.
- From the listed conditions, select + on the one you choose.
- Search for a condition or target and then select a condition.
- Enter the name of one of the following in the search box:
- A target: an entity, a device or a service.
- A group of targets: an area or label.
- A condition.
- From the listed results, select + on the desired condition.
- Enter the name of one of the following in the search box:
- Select a target and then a condition.
- In the window on the right, you will have different options depending on the selected condition. Under Targets, you can add the first target or another one by selecting Add target.
- Do one of the following:
- Select an entity, device or service to monitor a specific one.
- Select entities, devices or services in an area, floor or with a certain label to monitor a group of them.
- You can add another target by selecting Add target again.
- Do one of the following:
- Select Save.
Adding an action
- In the Then do section, select Add action.
- Under Blocks, you have many options that allow you, for example, to:
- Set up conditions for specific actions.
- Define the way a sequence of actions is performed.
- Wait for a trigger or a template to run a sequence of actions.
- Now you can do one of the following:
- Select a target and then an action.
- Under By target, select the entity, device or service to which you want to apply the action to. You can find the available entities, devices or services listed by:
- Area of your home, in the Home section.
- Entities, Devices and Services, in the Unassigned section.
- Labels that you have previously created, in the Labels section.
- For that target, you can see the available actions on the right side. Select + on the desired one.
- Under By target, select the entity, device or service to which you want to apply the action to. You can find the available entities, devices or services listed by:
- Select an action.
- Select By type, and then select the action type from the list on the left.
- From the listed actions, select + on the one you choose.
- Search for an action or target and then select an action.
- Enter the name of one of the following in the search box:
- A target: an entity, a device or a service.
- A group of targets: an area or label.
- An action.
- From the listed results, select + on the desired action.
- Enter the name of one of the following in the search box:
- Select a target and then an action.
- In the window on the right, you will have different options depending on the selected action. Under Targets, you can add the first target or another one by selecting Add target.
- Do one of the following:
- Select an entity, device or service to monitor a specific one.
- Select entities, devices or services in an area, floor or with a certain label to monitor a group of them.
- You can add another target by selecting Add target again.
- Do one of the following:
- Select Save.