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 a set of values or conditions of a platform that are defined to cause an automation to run. [Learn more] and an actionActions are used in several places in Home Assistant. As part of a script or automation, actions define what is going to happen once a trigger is activated. In scripts, an action is called sequence. [Learn more]. Optionally combined with a conditionConditions are an optional part of an automation that will prevent an action from firing if they are not met. [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.
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, to create automations, use the automation editor. 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 Behavior, you can decide how the automation starts by selecting one of the options there.
- First: if monitoring multiple targets, the automation only fires on the first time the trigger is verified for a target.
- Last: if monitoring multiple targets, the automation only fires after the trigger is verified for all targets.
- Any: the automation fires whenever a trigger of a monitored target is verified.
- 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.