ThisCalculator

Everyday

Home Assistant Automations, Dashboards & Scripts Guide

Updated · Standard formula, shown below

Home Assistant Automations, Dashboards & Scripts Guide

This guide walks you through the core building blocks of Home Assistant: automations, dashboards, and scripts. You’ll learn how to create a simple automation, design a useful dashboard, and write a script to reuse actions. By the end, you’ll have a working setup that responds to events and is easy to control from your phone or computer.

What You’ll Need

  • A running Home Assistant instance (on a Raspberry Pi, NAS, or virtual machine) with at least one integrated device or entity (e.g., a smart light, sensor, or switch).
  • Access to the Home Assistant web interface (usually at http://homeassistant.local:8123 or your local IP).
  • Basic familiarity with YAML syntax (indentation matters) if you plan to edit configuration files manually.
  • Optional: a second device (phone or tablet) to test the dashboard on a different screen size.

Step-by-Step

  1. Open the Home Assistant interface. Log in to your instance. You’ll see the default dashboard with a few cards. Click the Overview tab (or the house icon) to see the current dashboard.
  2. Create your first automation via the UI. Go to Settings → Automations & Scenes (or Configuration → Automations in older versions). Click Create Automation and choose Start with an empty automation.
  3. Define a trigger. Click Add Trigger. For example, choose State, then select an entity (like a motion sensor) and set the To state to on. This fires the automation when the sensor turns on.
  4. Add a condition (optional). Conditions restrict when the automation can run. Click Add Condition, for instance Time and set After to sunset so it only runs in the evening.
  5. Add an action. Click Add Action. Choose Device (if your device is integrated) or Entity and select the light you want to turn on. Set the Action to Turn on. You can also add a Brightness value.
  6. Save and test the automation. Click Save (give it a name like “Motion Light”). Then trigger the sensor manually (walk in front of it) and verify the light turns on. If not, check the Logbook (from the sidebar) to see if the automation fired.
  7. Create a script. Scripts are reusable sequences of actions. Go to Settings → Automations & Scenes → Scripts (or Configuration → Scripts). Click Create Script and add the same actions you used in the automation (e.g., turn on a light, wait 5 seconds, turn it off). Save it.
  8. Add a script to your dashboard. Go back to the Overview dashboard. Click the three-dot menu (top right) and select Edit Dashboard. Then click Add Card and choose Button. In the card configuration, select Entity and pick your script (it appears as script.your_script_name). The button will appear on the dashboard; clicking it runs the script.
  9. Build a custom dashboard. To have more control, create a new dashboard. In Overview, click the three-dot menu and choose Edit Dashboard, then Take control (or create a new dashboard from the sidebar’s Dashboards section). You can now add multiple cards: Entities for a list of switches, History Graph for sensor trends, Thermostat for climate, etc.
  10. Arrange and resize cards. In edit mode, drag cards to rearrange. Use the card’s Edit (pencil icon) to change its title, icon, or which entity it shows. Resize by dragging the bottom-right corner of the card.
  11. Set a view for different rooms. In the dashboard editor, click Add View to create a new tab (e.g., “Living Room”). Then add cards that are relevant to that room. This keeps your dashboard organized.
  12. Test and iterate. After adding cards, exit edit mode (click Done). Click each button to ensure it works. If a card shows an error, go back to edit mode and check the entity ID (it must match exactly).

Common Mistakes

  • Using the wrong entity ID. In scripts and automations, the entity ID must be exactly as shown in Settings → Devices & Services → Entities (e.g., light.living_room). Copy-paste it to avoid typos.
  • Forgetting to save the automation. If you navigate away without saving, your changes are lost. Always click Save before leaving the editor.
  • Conditions that are too restrictive. A condition like “After sunset” will prevent the automation from running during the day. Test without conditions first to isolate issues.
  • Scripts that run forever. If you add a wait action with a long delay, the script will block other actions. Use reasonable delays (e.g., 5 seconds) and test with a short timeout.
  • Dashboard cards not updating. Some cards need a refresh after changing entities. In the dashboard editor, click Refresh (or reload the page) to see updates.

Tips

  • Use the visual editor first. The UI editor generates YAML automatically, which is less error-prone than writing YAML from scratch. You can switch to YAML mode later if needed.
  • Name your automations and scripts clearly. Use names like “Motion Light – Hallway” so you can find them later.
  • Test automations with the Run button. In the automation editor, you can click Run to execute the actions immediately without waiting for the trigger.
  • Use the Logbook to debug. The Logbook shows when automations fire and which actions were taken. Check it after a failed test.
  • Make a backup of your configuration. Before major changes, go to Settings → System → Backup and create a backup. This saves you if you break something.
  • Start simple. Build one automation, test it, then add complexity. It’s easier to troubleshoot a single feature than a complex chain.

Troubleshooting

  • Automation doesn’t fire. Check the Logbook for the trigger event. If the event appears but the automation doesn’t run, check the conditions. Also verify that the automation is enabled (toggle in the automations list).
  • Script doesn’t appear on dashboard. Make sure you saved the script and that the entity ID is correct. In the dashboard card, you can type the entity ID manually if it’s not in the dropdown.
  • Dashboard shows “Entity not found”. This means the entity ID is wrong or the device is offline. Go to Settings → Devices & Services to confirm the entity exists and is available.
  • Actions run but nothing happens. The device might be unresponsive. Check the device’s own app or try turning it on manually from the Entities page. Also check if the device requires a specific service (e.g., light.turn_on vs. switch.turn_on).
  • YAML errors when editing files. Use the Check Configuration button in Developer Tools → YAML to validate your YAML before restarting. Indentation is critical; use spaces, not tabs.
  • Changes not taking effect. After editing YAML files, you need to restart Home Assistant (or reload automations via Developer Tools → YAML → Reload Automations). UI changes usually apply immediately.

Frequently Asked Questions

Can I use the same script in multiple automations?

Yes. Scripts are designed to be reused. In an automation action, choose Call Service and select script.your_script_name. This runs the script’s actions as part of the automation.

What’s the difference between an automation and a script?

An automation has triggers, conditions, and actions. A script is just a sequence of actions that you can call manually or from an automation. You can think of scripts as functions that you reuse.

How do I make a dashboard accessible from my phone?

Install the Home Assistant Companion app on your phone and log in to the same instance. Your dashboards appear in the app automatically. You can also set the dashboard to be accessible via a web browser on your local network.

Can I control devices from outside my home?

Yes, but it requires remote access. You can use the Nabu Casa cloud service (paid) or set up a secure tunnel like DuckDNS with a reverse proxy. For security, always use HTTPS and two-factor authentication.

How do I add a sensor to my dashboard?

Edit the dashboard, add a card, and choose Entities. Then add the sensor entity (e.g., sensor.temperature_living_room). You can also use a History Graph card to show a time-series chart.

What if my device isn’t listed in the entity dropdown?

First, ensure the device is integrated via Settings → Devices & Services → Add Integration. If it’s a custom device, you may need to set up a manual integration or use a template sensor. Check the Home Assistant community for device-specific guides.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.