Script Syntax

Scripts are a sequence of actions that Home Assistant will execute. Scripts are available as an entity through the standalone Script component but can also be embedded in automations and Alexa/Amazon Echo configurations.

The script syntax basic structure is a list of key/value maps that contain actions. If a script contains only 1 action, the wrapping list can be omitted.

# Example script component containing script syntax
      # This is written using the Script Syntax
      - service: light.turn_on
        entity_id: light.ceiling
      - service: notify.notify
          message: 'Turned on the ceiling light!'

Call a Service

The most important one is the action to call a service. This can be done in various ways. For all the different possibilities, have a look at the service calls page.

alias: Bedroom lights on
service: light.turn_on
  entity_id: group.bedroom
  brightness: 100

Test a Condition

While executing a script you can add a condition to stop further execution. When a condition does not return true, the script will finish. There are many different conditions which are documented at the conditions page.

condition: state
entity_id: device_tracker.paulus
state: 'home'


Delays are useful for temporarily suspending your script and start it at a later moment. We support different syntaxes for a delay as shown below.

# Waits 1 hour
delay: 01:00
# Waits 1 minute, 30 seconds
delay: 00:01:30
# Waits 1 minute
  # supports milliseconds, seconds, minutes, hours, days
  minutes: 1
# Waits however many minutes input_number.minute_delay is set to
# Valid formats include HH:MM and HH:MM:SS
delay: '00:{{ states.input_number.minute_delay.state | int }}:00'


Wait until some things are complete. We support at the moment wait_template for waiting until a condition is true, see also on Template-Trigger. It is possible to set a timeout after which the script will abort its execution if the condition is not satisfied. Timeout has the same syntax as delay.

# wait until media player have stop the playing
wait_template: "{{ states.media_player.floor.state == 'stop' }}"
# wait until a valve is < 10 or abort after 1 minutes.
wait_template: "{{ < 10 }}"
timeout: 00:01:00

Fire an Event

This action allows you to fire an event. Events can be used for many things. It could trigger an automation or indicate to another component that something is happening. For instance, in the below example it is used to create an entry in the logbook.

  name: Paulus
  message: is waking up
  entity_id: device_tracker.paulus
  domain: light