Update script docs

This commit is contained in:
Paulus Schoutsen 2016-05-01 19:25:52 +02:00
parent 99536c46da
commit 4be4102776
18 changed files with 417 additions and 189 deletions

View file

@ -45,7 +45,7 @@ Please note that you can use Haaska and the built-in Alexa component side-by-sid
### {% linkable_title I want to build custom commands to use with Echo %}
The built-in Alexa component allows you to integrate Home Assistant into Alexa/Amazon Echo. This component will allow you to query information and call services within Home Assistant by using your voice. There are no supported sentences out of the box as of now, you will have to define them all yourself.
The built-in Alexa component allows you to integrate Home Assistant into Alexa/Amazon Echo. This component will allow you to query information and call services within Home Assistant by using your voice. Home Assistant offers no built-in sentences but offers a framework for you to define your own.
<div class='videoWrapper'>
<iframe width="560" height="315" src="https://www.youtube.com/embed/1Ke3mtWd_cQ" frameborder="0" allowfullscreen></iframe>
@ -113,7 +113,10 @@ Out of the box, the component will do nothing. You have to teach it about all in
You can use [templates] for the values of `speech/text`, `card/title` and `card/content`.
Actions are using the [Home Assistant Script Syntax] and also have access to the variables from the intent.
[templates]: /topics/templating/
[Home Assistant Script Syntax]: /getting-started/scripts/
Configuring the Alexa component for the above intents would look like this:
@ -137,8 +140,8 @@ alexa:
LocateIntent:
action:
service: notify.notify
data:
message: Your location has been queried via Alexa.
data_template:
message: The location of {{ User }} has been queried via Alexa.
speech:
type: plaintext
text: >

View file

@ -11,15 +11,27 @@ logo: home-assistant.png
ha_category: Automation
---
The script component allows users to create a sequence of service calls and delays. Scripts can be started using the service `script/turn_on` and interrupted using the service `script/turn_off`.
The script component allows users to specify a sequence of actions to be executed by Home Assistant when turned on. The script component will create an entity for each script and allow them to be controlled via services.
The sequence of actions is specified using the [Home Assistant Script Syntax].
[Home Assistant Script Syntax]: /getting-started/scripts/
```yaml
# Example configuration.yaml entry
script:
message_temperature:
sequence:
# This is Home Assistant Script Syntax
- service: notify.notify
data_template:
message: Current temperature is {% raw %}{{ states.sensor.temperature.state }}{% endraw %}
# Turns on the bedroom lights and then the living room lights 1 minute later
wakeup:
alias: Wake Up
sequence:
# This is Home Assistant Script Syntax
- event: LOGBOOK_ENTRY
event_data:
name: Paulus
@ -32,10 +44,28 @@ script:
entity_id: group.bedroom
brightness: 100
- delay:
# supports seconds, milliseconds, minutes, hours, etc.
# supports seconds, milliseconds, minutes, hours
minutes: 1
- alias: Living room lights on
service: light.turn_on
data:
entity_id: group.living_room
```
### {% linkable_title Passing parameters in service calls %}
As part of the service, parameters can be passed in that will be made available to the script as variables within templates.
There are two ways to activate scripts. One is using the generic `script.turn_on` service. To pass variables to the script with this service, call it using the following parameters:
```yaml
{
"entity_id": "script.wakeup",
"variables": {
"hello": "world",
"name": "Paulus"
}
}
```
If you are calling the script service directly, for example `script.wakeup`. All service data will be made available as variables.