Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Home Assistant Automations vs Scripts vs Scenes: Which to Use?

· 8 min read · Home Automation

In this article
  1. Background: How Home Assistant Structures Automation
  2. How They Work: Key Differences
  3. Why Not Put Everything in Automations?
  4. When to Use Each: A Practical Guide
  5. Common Misconceptions and Mistakes
  6. Performance and Maintenance Considerations
  7. How to Structure Your Configuration
  8. Frequently Asked Questions

The short answer is no: you shouldn't stop using automations for everything, but you should stop putting complex logic directly inside automations. Scripts and scenes are better for specific tasks—scripts for reusable sequences and complex logic, scenes for restoring a set of device states—while automations remain the best way to trigger those scripts and scenes based on events or schedules.

Background: How Home Assistant Structures Automation

Home Assistant is an open-source home automation platform that runs locally, giving you control over devices from different manufacturers without cloud dependency. Its core automation engine has three main building blocks: automations, scripts, and scenes. Understanding the distinction is key to building a system that's reliable, maintainable, and easy to debug.

An automation is a rule that consists of a trigger (e.g., time, state change, event), an optional condition (e.g., only when someone is home), and an action (what happens). The action can be a single service call, a sequence of steps, or even a call to a script or scene. Automations are the entry point—they watch for something to happen and then respond.

Scripts are sequences of actions that can be reused. They can contain logic like loops, conditionals, delays, and variables. Scripts can be called from automations, dashboards, voice assistants, or other scripts. They are the workhorses for complex behavior.

Scenes are the simplest: they define a desired state for a group of entities (e.g., lights at 50% brightness, thermostat at 22°C, music playing). Activating a scene restores all those entities to the defined state. Scenes are ideal for “moods” or “modes” like “Movie Night” or “Good Morning.”

How They Work: Key Differences

  • Automations are event-driven. They wait for a trigger, check conditions, then execute actions. They can be enabled/disabled individually, and they appear in the Home Assistant UI as cards with toggle switches.
  • Scripts are procedural. They run from start to finish when called, and they can pause (via delays), branch (via choose/if), loop (via repeat), and accept input parameters. Scripts don't have triggers; they must be invoked.
  • Scenes are declarative. They store a snapshot of entity states and apply them on demand. Scenes don't have logic—they just set states. However, a scene can be created from the current state of entities, or you can manually define each entity's target state.

In practice, you might have an automation that triggers at sunset, checks if you're home, and then calls a script that gradually dims lights over 10 minutes. That script might call a scene for the initial light levels, then adjust individual lights. The automation is the brain, the script is the arms, and the scene is the blueprint.

Why Not Put Everything in Automations?

It's tempting to put all your logic directly into an automation's action field, especially for simple tasks like “turn on the light when motion detected.” But as your system grows, this approach becomes problematic:

  • Duplication: If you need the same sequence in multiple automations (e.g., “goodnight” routine triggered by a button, a voice command, or a schedule), you'd copy-paste the same steps. If you later change the routine, you must update every copy.
  • Complexity: Automations with long action sequences are hard to read and debug. The UI's visual editor can handle simple sequences, but for loops and conditionals, you'll end up editing YAML directly, which is error-prone.
  • Testing: Scripts can be run manually from the Developer Tools, making it easy to test a sequence without waiting for a trigger. Automations can also be triggered manually, but only if you know how to use the “Run” button in the UI.
  • Reusability: Scripts can take variables, so you can create a generic “dim lights to X%” script and call it with different values. Automations don't support parameters.

Scenes also avoid duplication. Instead of writing a dozen service calls to set the perfect movie lighting, you define a scene once and call it from any automation, script, or dashboard button.

When to Use Each: A Practical Guide

Here's a simple decision framework:

  • Use an automation when you need to react to something: a sensor state change, a time schedule, a button press, or an event. The automation's job is to decide when to act.
  • Use a script when you have a sequence of actions that is reused in multiple places, or when you need complex logic (loops, conditionals, variables, delays). Scripts are also great for actions that take time, like a “wake up” routine that gradually increases light brightness.
  • Use a scene when you want to set a group of entities to a specific state at once. Scenes are perfect for “modes” and “moods.” They are also useful for restoring states—for example, after a movie, you can call the “Normal Lighting” scene to return to your usual settings.

In many cases, you'll combine all three: an automation triggers a script, which calls a scene as part of its steps. For instance, a “Good Morning” automation triggers at 7 AM on weekdays, calls a script that checks if it's a holiday (via a condition), then sets the bedroom lights to a “Morning” scene, plays a news podcast, and adjusts the thermostat.

Common Misconceptions and Mistakes

One common misconception is that scripts are “better” than automations because they're more powerful. That's false—they serve different purposes. Replacing all automations with scripts would mean you lose the ability to respond to triggers automatically. You'd have to create your own event listeners, which is reinventing the wheel.

Another mistake is using scenes for everything, including complex sequences. Scenes only set states; they can't wait for a device to reach a state before continuing. If you need a sequence with delays or conditionals, a scene won't work—you need a script.

A frequent problem is putting too much logic in an automation's action, making it impossible to reuse. For example, you might have a “motion detected in hallway” automation that turns on the light and then turns it off after 2 minutes. If you later want the same behavior from a door sensor, you'd have to duplicate the entire action block. Instead, create a script “hallway_light_on” and call it from both automations.

Another pitfall is not using variables in scripts. Scripts can accept input parameters, so you can create a generic script like dim_light that takes a target brightness as a parameter. This reduces duplication dramatically.

Performance and Maintenance Considerations

From a performance standpoint, there's no significant difference between automations, scripts, and scenes—they all run in the same event loop. The real cost is in maintainability. A well-structured system with small, reusable scripts and scenes is easier to debug because you can test components individually.

When you have an issue, the Home Assistant logbook shows which automation triggered, but if the automation calls a script, the logbook also shows the script run. This makes it easier to trace the flow. Scenes show up as a single service call, which is clean but hides the individual entity changes—you might need to check the scene definition to see what it changed.

One more consideration: automations can be disabled individually, which is handy when troubleshooting. Scripts and scenes don't have a global enable/disable toggle, but you can comment them out in YAML or remove the call to them.

How to Structure Your Configuration

A good practice is to keep automations minimal—just the trigger and condition, with the action being a single call to a script or scene. Here's a suggested structure:

  1. Define scenes for all your common “modes” (e.g., “Movie,” “Dinner,” “Reading,” “Night,” “Away”).
  2. Create scripts for any multi-step sequence that you use more than once, or that requires logic (e.g., “Good Morning,” “Good Night,” “Vacation Mode”).
  3. Write automations that are thin wrappers: trigger → condition → call script or scene.

This approach makes your configuration modular. If you want to change the “Good Night” routine, you edit one script, not every automation that triggers it. If you want to change the “Movie” scene, you edit the scene, and all scripts that call it automatically use the new state.

For example, instead of having three automations each turning off the same set of lights at different times, you could have one script “all_off” and three automations that call it. Or even better, use a scene “All Off” that defines every light as off, and call that.

Frequently Asked Questions

Can I call a scene from a script?

Yes, you can call a scene from a script using the scene.turn_on service. This is a common pattern: a script might first call a scene to set the base state, then adjust individual entities.

Can I use variables in automations?

Automations don't have input parameters, but you can use the variables key in the automation action to define local variables that can be used in templates within that automation. However, these are not reusable across automations, so scripts are better for parameterized logic.

Do scenes work with devices that don't have a defined state?

Scenes work with any entity that has a state that can be set via a service call. For example, a scene can set a media player's volume and source, or a switch's on/off state. However, scenes cannot control entities that only report state (like a temperature sensor) because there's nothing to set.

Can I create a scene from the current state of my devices?

Yes, in the Home Assistant UI, you can go to the Scenes page, click “Add Scene,” and then “Create from current state.” This will populate the scene with all currently on entities and their states. You can then edit it to remove or change entities.

What's the best way to debug a script that isn't working?

Use the Developer Tools → Services tab to call the script manually. You can also add logbook entries or use the logger integration to print debug messages. Additionally, you can use the script.toggle service to run the script and watch the logbook for errors.

Is there a limit to how many automations or scripts I can have?

No hard limit, but performance can degrade if you have thousands of automations each with complex triggers. In practice, you'll likely run into maintainability issues before performance issues. Using scripts and scenes reduces the number of automations needed, which helps.