Re-organisation Documentation and Getting started (#2055)

* 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
This commit is contained in:
Fabian Affolter 2017-02-23 11:09:41 +01:00 committed by GitHub
parent 0677895b5b
commit 481320128f
138 changed files with 1309 additions and 909 deletions

View file

@ -0,0 +1,179 @@
---
layout: page
title: "Conditions"
description: "Documentation about all available conditions."
date: 2016-04-24 08:30 +0100
sidebar: true
comments: false
sharing: true
footer: true
redirect_from: /getting-started/scripts-conditions/
---
Conditions can be used within a script or automation to prevent further execution. A condition will look at the system right now. For example a condition can test if a switch is currently turned on or off.
### {% linkable_title AND condition %}
Test multiple conditions in 1 condition statement. Passes if all embedded conditions are valid.
```yaml
condition:
condition: and
conditions:
- condition: state
entity_id: 'device_tracker.paulus'
state: 'home'
- condition: numeric_state
entity_id: 'sensor.temperature'
below: '20'
```
### {% linkable_title OR condition %}
Test multiple conditions in 1 condition statement. Passes if any embedded conditions is valid.
```yaml
condition:
condition: or
conditions:
- condition: state
entity_id: 'device_tracker.paulus'
state: 'home'
- condition: numeric_state
entity_id: 'sensor.temperature'
below: '20'
```
### {% linkable_title MIXED AND and OR conditions %}
Test multiple AND and OR conditions in 1 condition statement. Passes if any embedded conditions is valid.
This allows you to mix several AND and OR conditions together.
```yaml
condition:
condition: and
conditions:
- condition: state
entity_id: 'device_tracker.paulus'
state: 'home'
- condition: or
conditions:
- condition: state
entity_id: sensor.weather_precip
state: 'rain'
- condition: numeric_state
entity_id: 'sensor.temperature'
below: '20'
```
### {% linkable_title Numeric state condition %}
This type of condition attempts to parse the state of specified entity as a number and triggers if the value matches all of the above or below thresholds.
For above, the condition passes if `value >= above`. For below, the condition passes if `value <= below`. If both `below` and `above` are specified, both tests have to pass.
You can optionally use a `value_template` to process the value of the state before testing it.
```yaml
condition:
condition: numeric_state
entity_id: sensor.temperature
above: 17
below: 25
# If your sensor value needs to be adjusted
value_template: {% raw %}{{ float(state.state) + 2 }}{% endraw %}
```
### {% linkable_title State condition %}
Tests if an entity is a specified state.
```yaml
condition:
condition: state
entity_id: device_tracker.paulus
state: not_home
# optional: trigger only if state was this for last X time.
for:
hours: 1
minutes: 10
seconds: 5
```
### {% linkable_title Sun condition %}
The sun condition can test if the sun has already set or risen when a trigger occurs. The `before` and `after` keys can only be set to `sunset` or `sunrise`. They have a corresponding optional offset value (`before_offset`, `after_offset`) that can be added, similar to the [sun trigger][sun_trigger].
[sun_trigger]: /getting-started/automation-trigger/#sun-trigger
```yaml
condition:
condition: sun
after: sunset
# Optional offset value
after_offset: "-1:00:00"
```
### {% linkable_title Template condition %}
The template condition will test if the [given template][template] renders a value equal to true. This is achieved by having the template result in a true boolean expression or by having the template render 'true'.
```yaml
condition:
condition: template
value_template: '{% raw %}{{ states.device_tracker.iphone.attributes.battery > 50 }}{% endraw %}'
```
Within an automation, template conditions also have access to the `trigger` variable as [described here][automation-templating].
[template]: /topics/templating/
[automation-templating]: /getting-started/automation-templating/
### {% linkable_title Time condition %}
The time condition can test if it is after a specified time, before a specified time or if it is a certain day of the week
```yaml
condition:
condition: time
# At least one of the following is required.
after: '15:00:00'
before: '02:00:00'
weekday:
- mon
- wed
- fri
```
Valid values for `weekday` are `mon`, `tue`, `wed`, `thu`, `fri`, `sat`, `sun`.
Time condition windows can span across the midnight threshold. In the example above, the condition window is from 3pm to 2am.
### {% linkable_title Zone condition %}
Zone conditions test if an entity is in a certain zone. For zone automation to work, you need to have setup a device tracker platform that supports reporting GPS coordinates. Currently this is limited to the [OwnTracks platform](/components/device_tracker.owntracks/) and the [iCloud platform](/components/device_tracker.icloud/).
```yaml
condition:
condition: zone
entity_id: device_tracker.paulus
zone: zone.home
```
### {% linkable_title Examples %}
```yaml
condition:
- condition: numeric_state
entity_id: sun.sun
value_template: '{{ state.attributes.elevation }}'
below: 1
- condition: state
entity_id: light.living_room
state: 'off'
- condition: time
before: '23:00:00'
after: '14:00:00'
- condition: state
entity_id: script.light_turned_off_5min
state: 'off'
```

View file

@ -0,0 +1,85 @@
---
layout: page
title: "Service Calls"
description: "Instructions how to call services in Home Assistant."
date: 2016-03-12 12:00 -0800
sidebar: true
comments: false
sharing: true
footer: true
redirect_from: /getting-started/scripts-service-calls/
---
Various components allow calling services when a certain event occurs. The most common one is calling a service when an automation trigger happens. But a service can also be called from a script or via the Amazon Echo.
The configuration options to call a config are the same between all components and are described on this page.
Examples on this page will be given as part of an automation component configuration but different approaches can be used for other components too.
<p class='note'>
Use the <img src='/images/screenshots/developer-tool-services-icon.png' class='no-shadow' height='38' /> service developer tool in the frontend to discover available services.
</p>
### {% linkable_title The basics %}
Call the service `homeassistant.turn_on` on the entity `group.living_room`. This will turn all members of `group.living_room` on. You can also omit `entity_id` and it will turn on all possible entities.
```yaml
service: homeassistant.turn_on
entity_id: group.living_room
```
### {% linkable_title Passing data to the service call %}
You can also specify other parameters beside the entity to target. For example, the light turn on service allows specifying the brightness.
```yaml
service: light.turn_on
entity_id: group.living_room
data:
brightness: 120
rgb_color: [255, 0, 0]
```
### {% linkable_title Use templates to decide which service to call %}
You can use [templating] support to dynamically choose which service to call. For example, you can call a certain service based on if a light is on.
```yaml
service_template: >
{% raw %}{% if states.sensor.temperature | float > 15 %}
switch.turn_on
{% else %}
switch.turn_off
{% endif %}{% endraw %}
entity_id: switch.ac
```
### {% linkable_title Using the Services Developer Tool %}
You can use the Services Developer Tool to test data to pass in a service call.
For example, you may test turning on or off a 'group' (See [groups] for more info)
To turn a group on or off, pass the following info:
Domain: `homeassistant`
Service: `turn_on`
Service Data: `{ "entity_id": "group.kitchen" }`
### {% linkable_title Use templates to determine the attributes %}
Templates can also be used for the data that you pass to the service call.
```yaml
service: thermostat.set_temperature
data_template:
entity_id: >
{% raw %}{% if is_state('device_tracker.paulus', 'home') %}
thermostat.upstairs
{% else %}
thermostat.downstairs
{% endif %}{% endraw %}
temperature: {% raw %}{{ 22 - distance(states.device_tracker.paulus) }}{% endraw %}
```
[templating]: /topics/templating/