Home Assistant Guide

Simple tutorials for powerful automations

Automations

Automations are at the heart of Home Assistant's power. They let you make your smart home truly smart by having things happen automatically - no need to open an app or press a button. With automations, your home responds to you, your schedule, sensors, time, and even the environment.

What is an Automation?

An automation is a set of instructions that tells Home Assistant: "When something happens (a trigger), and if certain optional conditions are true (the conditions), then do something (the action)."

  • Trigger: What causes your automation to start. This can be just about anything - a motion sensor detecting motion, a time of day, your phone entering an area, and much more.
  • Condition (optional): Extra rules to check before running the action. Conditions are always optional - if you leave them out, the automation will run whenever triggered.
    You can add multiple conditions.
  • Action: What actually happens when your automation runs. This could be turning on a light, sending a notification, playing music, calling a script, and more. You can add multiple actions and use building blocks for more complex logic.

Example of an automation you can create: "Turn on the hallway light if motion is detected, but only at night."

Multiple Triggers & Conditions Explained

  • Multiple Triggers:
    If you add more than one trigger (for example, "motion detected" or "door opened"), the automation will start if any one of the triggers occurs. This uses OR logic.
  • Multiple Conditions:
    By default, if you add more than one condition (e.g. "It's after sunset" and "I'm home"), all conditions must be true for the automation to run. This uses AND logic.
    If you want to change this, Home Assistant's visual editor lets you create groups of conditions with AND or OR blocks. For example, you could require that either "Person A is home" OR "Person B is home".
  • Tip: Conditions are always checked after a trigger fires, so your automation can be triggered often but only act when all your rules match.

Targeting: Area, Device, or Entity

When setting up the action for your automation, you'll often be asked what you want to control. You can usually choose from an area, a device, or an entity. Here's what each means:

  • Area: A group of devices/entities that you've placed together (e.g. "Kitchen" or "Hallway"). Targeting an area lets you control everything in that area at once.
    Example: Turn off all lights in "Bedroom" at bedtime.
    Benefit: Makes automations simpler to manage, especially as you add or change devices. If you add a new light to the "Hallway" area, or replace the existing one, your automations can control it automatically - no need to update each automation.
  • Device: A physical piece of hardware, like a smart bulb or a thermostat. Targeting a device lets you control all its functions together, or access device-specific actions.
    Example: Turn on your "Front Door Sensor" chime.
  • Entity: The most specific level - a single controllable thing in Home Assistant, such as light.kitchen_lamp or sensor.living_room_temperature. Every device creates one or more entities.
    Benefit: Gives you fine-grained control if you want to act on just one specific light or sensor.

Which should you use? If your automation always applies to a whole room, use areas. If you only want to control a single item, use entity or device.

Creating an Automation (Example)

  1. Go to Settings > Automations & Scenes > Automations.
  2. Click "Create Automation" (the + button).
  3. Add one or more triggers: E.g. "Motion detected in Hallway" or "Front Door opens.". As an example, you can select "Device" trigger, find an existing motion sensor in the devices list, and then select "Hall Motion Sensor started detecting motion" as the trigger.
  4. Add conditions (optional): Click "Add Condition" and choose one or more conditions, such as "Time is after sunset," "No one is home," or use AND/OR groups for advanced logic.
  5. Add an action: Choose what you want to happen. You can target an area ("Turn on all lights in Hallway"), a device, or a specific entity.
  6. Name your automation clearly (e.g., "Hallway Light on Motion at Night").
  7. Click Save.

Now your automation is ready to go. Test it by triggering any of your selected triggers and see if the action runs as expected!

Best Practice Tips

  • Start simple - use one trigger, one action, then add complexity.
  • Name everything clearly so you can quickly identify your automations later.
  • Test and tweak - you can run actions manually to check that they work as intended.
  • Use areas for scalability - if you think you'll add more devices to a room in the future, targeting an area saves you having to update your automations.
  • Don't forget to back up if you start editing YAML directly.
  • Avoid accidental loops - watch out for automations that might trigger each other repeatedly.
  • Disable or pause automations during testing, or when you don't need them.

Editing YAML

The visual editor covers almost everything you'll need, but sometimes guides or advanced features might mention "editing YAML."

What is YAML? YAML (pronounced "yammel") is just a way of writing settings or instructions using plain text that's easy for both humans and computers to read. In Home Assistant, YAML files describe things like automations, scripts, or integrations.

You can edit the underlying YAML for any automation by clicking the three dots () in the top right of the automation editor and choosing "Edit in YAML." This is completely optional - many users will never need to touch it, but it can be handy for copying settings, advanced tweaks, or following some online tutorials.

Common Use Cases for Automations

  • Turn on lights by motion, or at sunset
  • Send reminders if doors are left open
  • Lower the heating when you leave
  • Play music when you arrive home
  • Automatically start your kettle, coffee maker, or other appliance

Automations can be as simple or as complex as you like. Don't be afraid to experiment and try out new ideas - Home Assistant is designed to help you make your home work for you! Automations can be disabled or deleted at any time.