Skip to content

Home Assistant Script Errors

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Home Assistant Script Errors. We cover key concepts, practical examples, and best practices.

Hook

You write a script in Home Assistant to sequence several actions — turn on lights, wait, then turn them off. When you run the script, nothing happens. Or it starts but stops halfway through. The script errors are unhelpful.

The Wrong Way

Using delay without specifying the time format or putting actions in the wrong sequence order causes scripts to fail silently.

# BAD: Missing time format
script:
  hallway_light_sequence:
    sequence:
      - service: light.turn_on
        entity_id: light.hallway
      - delay: 30  # No time format — how long is 30?
      - service: light.turn_off
        entity_id: light.hallway
Script executed
Light turned on
Light turned off immediately

delay: 30 without a time unit defaults to seconds, which works. But this is unclear and a missing minutes: or seconds: prefix can cause confusion.

The Right Way

Use explicit time formats and validate the script sequence.

# CORRECT: Explicit script
script:
  hallway_light_sequence:
    alias: "Hallway Light Sequence"
    sequence:
      - service: light.turn_on
        target:
          entity_id: light.hallway
      - delay:
          seconds: 30
      - service: light.turn_off
        target:
          entity_id: light.hallway
    mode: single
# Test the script via API
curl -X POST -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  http://hass.local:8123/api/services/script/hallway_light_sequence
{"message": "Script started successfully"}
Script runs: turn on → wait 30s → turn off ✓
# Check script trace for errors
# Web UI → Developer Tools → Scripts → Select script → Trace
Step 1: light.turn_on on light.hallway → completed
Step 2: delay 30 seconds → completed
Step 3: light.turn_off on light.hallway → completed

For conditional scripts, ensure the condition uses the correct syntax:

- condition: state
  entity_id: binary_sensor.motion
  state: "on"

Prevention

  • Use target: instead of entity_id: in service calls (both work, but target is the modern syntax).
  • Always specify time units: seconds:, minutes:, or hours:.
  • Test scripts from Developer Tools before adding them to automations.
  • Use mode: single, mode: restart, or mode: queued to control overlapping executions.
  • Enable script debug logging: logger: logs: homeassistant.components.script: debug.

Advanced Troubleshooting

Check the Logs

Most TOOL errors are logged to stdout or a dedicated log file. Check your logs first:

# Check system logs
journalctl -u tool --since "1 hour ago"

# Or check the application log
tail -50 ~/.tool/logs/error.log

Test with a Minimal Example

Create the simplest possible tool configuration to verify the base setup works:

tool --version
tool --help

If the minimal test passes, add configuration options one at a time until you find the breaking change.

Common Configuration Mistakes

  • Using the wrong file path or URL in configuration
  • Forgetting to restart TOOL after changing config files
  • Mixing tabs and spaces in YAML configuration files
  • Setting incorrect permissions on configuration directories

When to Reinstall

If none of the above resolves the issue, consider a clean reinstall:

# Backup your configuration
cp -r ~/.tool ~/.tool.bak

# Remove and reinstall
# Follow the official TOOL installation guide

This ensures you start from a known good state and can isolate the issue.

Common Mistakes with assistant script

  1. Mixing let bindings with <- bindings in do notation, producing type errors
  2. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors
  3. Non-exhaustive pattern matches that compile with warnings then crash at runtime

These mistakes appear frequently in real-world HOME code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

What is the difference between a script and an automation?

Scripts are manually-triggered sequences of actions. Automations have triggers and conditions that fire automatically. Scripts can be called from automations, dashboards, or voice commands.

Can a script run another script?

Yes — use service: script.script_name to call another script. Be careful with recursion — use mode: single to prevent infinite loops.

Why does my script stop after the first action?

The script may have a condition that fails, or an action that errors out. Check the script trace in Developer Tools. Also ensure mode: is set to allow the sequence to complete.


DodaTech — scripts that do exactly what you expect.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro