Integrations

Scripts

Spook tells you when a script in Home Assistant uses something that no longer exists, like an entity, a device or an action, so you find out before it runs, and adds actions to start a script later, restarts included.

A script in Home Assistant is a sequence of actions you can start whenever you like: from a dashboard button, a voice command, or as an action in an automation. Unlike an automation, a script has no trigger of its own. Write the "movie night" steps once, and use them from everywhere.

That makes a broken script sneaky. It does nothing until somebody starts it, and only then you find out one of its steps points at something that is gone. Spook looks through your scripts ahead of time, and raises a repair when it finds something wrong. It also adds actions to start a script once, later, in a way that survives a restart of Home Assistant, and one to read how its last runs went.

A repair raised by Spook for a script.
Spook found an issue with a script that is using non-existing entities.

Actions

Spook adds five actions for scripts: two to start one later, one to call that off, one to see what is coming, and one to read how the last runs went. You find them wherever you add an action, marked with a 👻.

A script with a delay in front already starts something later. Until Home Assistant restarts during the delay: then the run is gone, and nothing tells you. Spook writes every run down, so it survives the restart.

A script has one scheduled run at most. Scheduling it again replaces the run it has, so the "in 20 minutes" button pressed twice moves the reminder, it does not add a second one.

Spook starts the script with script.turn_on, the way you would, under the user who scheduled it. The trace and the logbook name that person, and the actions in the script get checked against their rights, the same as if they had started it themselves. Spook lets the run go once the script has started, not once it is done.

A run whose time passed while Home Assistant was not running starts once Home Assistant is back, after it has finished starting. Several start in the order of their times. Set Skip if missed to drop such a run instead; Spook then says so in the log, at the info level.

Who may schedule or cancel a run is the same as who may start the script with script.turn_on: Home Assistant does not check that per script, so anybody who may perform actions may start any script. Only the list is for administrators, because it shows every run in the house and who scheduled it.

A script that is renamed keeps its run. A script that is deleted loses it. One that is unavailable at its time, because it failed to set up or was taken out of your configuration, is not started: Spook names it in the log, and drops the run.

Templates in an automation are rendered first. Your automation or script renders every template in the data of an action before the action sees it, the variables included. So message: "It is {{ now().hour }} o'clock" is the hour at the moment you schedule the run, not the one at which the script starts. A script does not render its variables again, so raw tags do not help here either. Need something worked out when the script starts? Put the template in the script itself.

Run in

Starts a script once, after a while.

How to use it

  1. Open the automation or script that should do the scheduling, and select Add action.
  2. Search for run in, and select Script: Run in 👻.
  3. Under Targets, choose the script to start.
  4. Set Duration to how long from now, like 00:20:00 for twenty minutes.
  5. Optionally, fill in Variables for the script, like message: The dryer is still full.
  6. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Run at

Starts a script once, at a time.

The same as Run in, with the time given rather than a duration. A time without a time zone, like the one the date and time picker gives, is in the time zone of Home Assistant. A time that is not ahead of now is refused, rather than started right away: that is far more often yesterday's date in a template than a wish. To start a script now, use script.turn_on.

How to use it

  1. Open the automation or script that should do the scheduling, and select Add action.
  2. Search for run at, and select Script: Run at 👻.
  3. Under Targets, choose the script to start.
  4. Set At to when it should start.
  5. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Cancel scheduled run

Drops the run Run in or Run at scheduled for a script. A script without one is left alone, without an error. A script that is unavailable still has its run dropped.

How to use it

  1. Open the automation or script that should do the cancelling, and select Add action.
  2. Search for cancel scheduled run, and select Script: Cancel scheduled run 👻.
  3. Under Targets, choose the scripts whose run to drop.
  4. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

List scheduled runs

Lists every run Run in and Run at scheduled, the first one first: when it starts, the variables it hands the script, and the user who scheduled it.

How to use it

  1. Open the automation or script that needs the list, and select Add action.
  2. Search for list scheduled runs, and select Script: List scheduled runs 👻.
  3. Under Response variable, give the list a name, like runs. The steps after this one can use it.
  4. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Get traces

Returns a summary of the last runs of a script: when it ran, how it ended, the error if there was one, and the last step it reached.

Home Assistant keeps a trace of the last runs of every script, five by default. The trace view shows them, but an automation or another script cannot read them. Get traces hands them over as a response, so you can act on them: a daily note of the scripts whose last run failed, or a check after a run you started yourself.

It is a summary, never the whole trace. A trace holds the variables of the run and the states it read, and secrets can be among them. Those stay out. What a trace says in words of its own, like an error or the reason of a stop, is cleaned of anything that looks like a secret first.

The runs come newest first. Only failed runs keeps the runs that ended in an error, a stop with error: true included. Limit cuts the list after that, so a limit of 1 with only failed runs is the last run that failed, however long ago.

Reading traces is for administrators, the same as the trace view of Home Assistant. Automations can always call it. A script started by a user who is not an administrator runs as that user, and is refused.

How to use it

  1. Open the script or automation that should read the runs, and select Add action.
  2. Search for traces, and select Script: Get traces 👻.
  3. Under Targets, choose the scripts.
  4. Under Response variable, give the response a name, like traces.
  5. Select Save.

Just want to see it work? Try this action opens it in your Home Assistant, ready to run once.

Repairs

Spook looks through your scripts for things that can no longer work, and tells you in the repairs dashboard. Each repair names the script and what is wrong with it.

Fixing one always goes the same way: select the name of the script in the repair, change what the repair points at, and save. Spook looks again when you save, and takes the repair away by itself. New to this? Follow Fix your first repair.

An entity, device, area, floor or label that only disabled steps (enabled: false) name is left alone. A disabled step does nothing, and is usually parked on purpose. Anything a running step names as well is still reported.

Want Spook to leave one script alone? Keep it out on the Exclusions page of Spook's panel, or put the Excluded from Spook label on it. How that works.

Unknown referenced areas

A script targets an area that no longer exists, usually because the area was removed or merged into another. The step that uses it does nothing.

A repair raised by Spook for a script.
Spook found an issue with a script that is using a non-existing area.

How to fix it: Open the script from the repair, and in the step that uses the missing area, pick an area that exists. Or remove the step. The repair disappears by itself once it is fixed.

Unknown referenced attributes

A script waits for, or checks, an attribute its entity does not have, like brightness on a plain switch. An attribute is an extra detail an entity carries next to its state. A wait like that only ends on its timeout, and a check like that never passes. You get no error.

How to fix it: Open the script from the repair and use an attribute the entity has. When Spook is nearly certain what you meant, the repair says so. The repair disappears by itself once it is fixed.

Unknown referenced states

A script waits for, or checks, a state its entity is never in, like On for a light that is on or off. A wait like that only ends on its timeout, and a check like that never passes. You get no error.

How to fix it: Open the script from the repair and use a state the entity can be in. Picking the state from the list in the editor, instead of typing it, avoids this. When Spook is nearly certain what you meant, the repair says so. The repair disappears by itself once it is fixed.

Unknown referenced devices

A script uses a device that no longer exists, usually because it was removed or replaced. Conditions, waits and actions that use it no longer work.

A repair raised by Spook for a script.
Spook found an issue with a script that is using a non-existing device.

How to fix it: Open the script from the repair, and in the step that uses the missing device, pick the device that replaced it. Or remove the step. The repair disappears by itself once it is fixed.

Split devices

A script uses a device that Home Assistant split, by the ID the device had before. It still works today, but stops working in Home Assistant 2027.8.

Home Assistant 2026.8 split every device that belonged to more than one integration into one device per integration, each with an ID of its own. The old ID is no device anymore. For now, Home Assistant passes it on to the devices that replaced it: an action targeting the old ID reaches their entities, and device conditions and actions keep working. Home Assistant 2027.8 stops doing that, and from then on, what uses an old ID does nothing.

How to fix it: Open the script from the repair, and pick the device again where the old one is used. The editor offers the device that replaced it. The repair names those devices too. The repair disappears by itself once nothing in the script uses an old ID anymore.

Unknown referenced integration entries

An action in a script points at an integration entry that no longer exists: one setup of an integration, like your Hue bridge. This usually happens after you removed an integration and added it again: it looks the same, but the action still points at the old one, and fails when it runs.

How to fix it: Open the script from the repair, and pick the integration entry again in the actions it names. The repair disappears by itself once it is fixed.

Unknown referenced entities

A script uses an entity that no longer exists, usually because it was renamed, replaced or removed. The step that uses it does nothing.

How to fix it: Open the script from the repair, and in the step that uses the missing entity, pick the right one. Or remove the step. The guide Fix your first repair walks you through this one for an automation, and a script goes the same way. The repair disappears by itself once it is fixed.

Unknown referenced actions

A script uses an action that does not exist, usually because the integration that provided it was removed. The step fails when it runs.

How to fix it: Open the script from the repair and replace or remove the step. Or bring back the integration the action came from. The repair disappears by itself once it is fixed.

Unknown icons

A script has an icon, or hands one out, that Home Assistant does not have, usually because of a typo or a renamed icon. Whatever gets it shows an empty spot where the icon should be.

How to fix it: Open the script from the repair and pick an icon that exists. When Spook is nearly certain what you meant, the repair says so. The repair disappears by itself once it is fixed.

Unknown referenced floors

A script targets a floor that no longer exists. The step that uses it does nothing.

How to fix it: Open the script from the repair, and in the step that uses the missing floor, pick a floor that exists. Or remove the step. The repair disappears by itself once it is fixed.

Unknown referenced labels

A script targets a label that no longer exists. The step that uses it does nothing.

How to fix it: Open the script from the repair, and in the step that uses the missing label, pick a label that exists. Or remove the step. The repair disappears by itself once it is fixed.

Unknown referenced conditions

A script uses a condition that no integration provides anymore, usually because that integration was removed. The whole script stops working. Home Assistant tells you the script is broken; Spook tells you which condition did it.

How to fix it: Open the script from the repair and remove the condition. Or bring back the integration it came from. The repair disappears by itself once it is fixed.

Unknown referenced triggers

A script waits for a trigger that no integration provides anymore, usually because that integration was removed. A script has no triggers of its own, so this is about a Wait for a trigger step. The whole script stops working. Home Assistant tells you the script is broken; Spook tells you which trigger did it.

How to fix it: Open the script from the repair and remove the trigger from the wait, or the whole wait. Or bring back the integration it came from. The repair disappears by itself once it is fixed.

Templates that can never pass

A script has a template that, the way it is written, can never be true. A template is a small piece of code between {{ }} that works out a value. Its condition always fails, or its wait only ends on a timeout. You get no error.

How to fix it: Open the script from the repair and correct the template. The usual causes: quotes around the template, missing {{ }}, something pasted around it, or a template that gives on where true is needed, and a template in the to, from or state of a state trigger or condition, which Home Assistant never renders. The repair disappears by itself once it is fixed.

Unknown template functions

A script has a template that calls a function Home Assistant does not have, like state('light.hall') where states was meant. A template is a small piece of code between {{ }} that works out a value. Every time the script gets to it, the template stops with an error, and so does the step it is in.

How to fix it: Open the script from the repair and use a function Home Assistant has. Or install the integration that adds the function again. The repair disappears by itself once it is fixed.

Functions limited templates cannot use

A script has a template that Home Assistant renders in its limited environment, and that uses something that environment does not allow, like states('input_select.mode'), now() or | expand. In there, everything that looks up your home is turned off, and using it fails every time. What fails depends on where the template is:

  • In a templated enabled of a condition, like in an if, a choose or a repeat, the step it is in fails every time it gets there.
  • In the event_type, event_data or context of an event trigger, the at of a time trigger, the topic of an MQTT trigger, or a templated enabled of a trigger, all in a wait_for_trigger: that trigger is not set up. When none of them is, the wait ends right away.

How to fix it: Open the script from the repair. For the enabled of a condition, put a template condition next to it instead. For a trigger of a wait_for_trigger, work the value out in a variables step before it: its variables are handed on. The repair disappears by itself once it is fixed.

States used as numbers

A script has a template that uses the state of an entity as a number, like states('sensor.temperature') > 20. A state is always text, even when it looks like a number, and text cannot be compared with a number or worked out with one. Every time the script gets to it, the template stops with an error, and so does the step it is in.

How to fix it: Open the script from the repair and turn the state into a number first, with a default for when it is not one, like unknown: states('sensor.temperature') | float(0) > 20. Use | int(0) for whole numbers. The repair disappears by itself once it is fixed.

States compared with numbers

A script has a template that compares the state of an entity with a number, or with true or false, like states('sensor.people_home') == 2 or is_state('switch.kitchen', true). A state is always text, even when it looks like a number, so it is never equal to a number, nor to true or false. The check is always false, or always true with != or not in, whatever the state is. Nothing fails and nothing tells you: the step it is in just never does what it reads like.

How to fix it: Open the script from the repair and compare with text, like states('sensor.people_home') == '2' or is_state('switch.kitchen', 'on'). Or turn the state into a number first: states('sensor.people_home') | int(0) == 2. The repair disappears by itself once it is fixed.

Wrong kind of entity

A script hands an action an entity of another kind, like input_number.set_value on a number entity. An action like that only acts on entities of its own kind. Handed anything else, it does nothing at all. Home Assistant only logs that the entity is "missing or not currently available", and the script carries on as if it worked.

- action: input_number.set_value
  target:
    entity_id: number.thermostat_offset
  data:
    value: 2

How to fix it: Open the script from the repair and use the action of the entity's own kind. Or hand the action the entity it was meant for. The repair disappears by itself once it is fixed.

- action: number.set_value
  target:
    entity_id: number.thermostat_offset
  data:
    value: 2

Removed users

A script only does something for a certain user, and that user was removed. A check for them never passes again.

How to fix it: Open the script from the repair and use a user that exists. Or remove the check. The repair disappears by itself once it is fixed.

Missing something here?

An action, an entity or a repair this integration should have? Say so. Stuck, or found a bug? There is help.