
* Split MQTT documentation * Add more details * Move content to /docs * Enable sidebar * Move content to /docs * Enable sidebar * Move content * Update links * Remove wizard stuff * Enable sidebar * Minor changes * Move MQTT parts to /docs * update links * Update links and sync content * Fix link * Enable sidebar * Remove navigation * Remove navigation and other minor updates * Update links * Add overview page * Make title linkable * Update * Plit content * Update links * Rearrange content * New getting-started section * Add icons for docs * Update for new structure * Update for new structure * Add docs navigation * Add docs overview page * Remove ecosystem navigation * Add docs and remove other collections * Move ecosystem to docs * Remove duplicate files * Re-add ecosystem overview * Move to ecosystem * Fix permission * Update navigation * Remove collection * Move overview to right folder * Move mqtt to upper level * Move notebook to ecosystem * Remove un-used files * Add one more rectangle for iOS * Move two parts back from docs and rename Run step * Remove colon * update getting-started section * Add redirect * Update * Update navigation
2.8 KiB
layout, title, description, date, sidebar, comments, sharing, footer, redirect_from
layout | title | description | date | sidebar | comments | sharing | footer | redirect_from |
---|---|---|---|---|---|---|---|---|
page | Script Syntax | Documention for the Home Assistant Script Syntax. | 2016-04-24 08:30 +0100 | true | false | true | true | /getting-started/scripts/ |
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
script:
example_script:
sequence:
# This is written using the Script Syntax
- service: light.turn_on
entity_id: light.ceiling
- service: notify.notify
data:
message: 'Turned on the ceiling light!'
{% linkable_title 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
data:
entity_id: group.bedroom
brightness: 100
{% linkable_title 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'
{% linkable_title Delay %}
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
delay:
# supports seconds, minutes, hours, days
minutes: 1
# Waits however many minutes input_slider.minute_delay is set to
# Valid formats include HH:MM and HH:MM:SS
delay: {% raw %}'00:{{ states.input_slider.minute_delay.state | int }}:00'{% endraw %}
{% linkable_title 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.
event: LOGBOOK_ENTRY
event_data:
name: Paulus
message: is waking up
entity_id: device_tracker.paulus
domain: light