mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-21 08:16:53 +00:00
Automation docs moved to getting started and split up
This commit is contained in:
parent
2cea0e718f
commit
f74237f582
@ -264,6 +264,7 @@ p.note {
|
||||
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
|
||||
.img-container {
|
||||
height: 50px;
|
||||
|
@ -11,354 +11,6 @@ logo: home-assistant.png
|
||||
ha_category: Automation
|
||||
---
|
||||
|
||||
This page will go into more detail about the various options the `automation` component offers. If you haven't yet, read the [getting started page on automation](/getting-started/automation/).
|
||||
Please see the [getting started section] for in-depth documentation on how to use the automation compnoent.
|
||||
|
||||
A configuration section of an automation requires a `trigger` and an `action` section. `condition` and `condition_type` are optional. To keep this page compact, all following sections will not show the full configuration but only the relevant part.
|
||||
|
||||
- [Jump to conditions](#conditions)
|
||||
- [Jump to actions](#actions)
|
||||
- [Jump to troubleshooting](#troubleshooting)
|
||||
|
||||
```yaml
|
||||
# Example of entry in configuration.yaml
|
||||
automation:
|
||||
# Turns on lights 1 hour before sunset if people are home
|
||||
# and if people get home between 16:00-23:00
|
||||
- alias: 'Rule 1 Light on in the evening'
|
||||
trigger:
|
||||
# Prefix the first line of each trigger configuration
|
||||
# with a '-' to enter multiple
|
||||
- platform: sun
|
||||
event: sunset
|
||||
offset: '-01:00:00'
|
||||
- platform: state
|
||||
entity_id: group.all_devices
|
||||
state: 'home'
|
||||
condition:
|
||||
# Prefix the first line of each condition configuration
|
||||
# with a '-'' to enter multiple
|
||||
- platform: state
|
||||
entity_id: group.all_devices
|
||||
state: 'home'
|
||||
- platform: time
|
||||
after: '16:00:00'
|
||||
before: '23:00:00'
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
entity_id: group.living_room
|
||||
|
||||
# Turn off lights when everybody leaves the house
|
||||
- alias: 'Rule 2 - Away Mode'
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: group.all_devices
|
||||
state: 'not_home'
|
||||
action:
|
||||
service: light.turn_off
|
||||
entity_id: group.all_lights
|
||||
|
||||
# Notify when Paulus leaves the house in the evening
|
||||
- alias: 'Leave Home notification'
|
||||
trigger:
|
||||
platform: zone
|
||||
event: leave
|
||||
zone: zone.home
|
||||
entity_id: device_tracker.paulus
|
||||
condition:
|
||||
platform: time
|
||||
after: '20:00'
|
||||
action:
|
||||
service: notify.notify
|
||||
data:
|
||||
message: 'Paulus left the house'
|
||||
```
|
||||
|
||||
## {% linkable_title Triggers %}
|
||||
|
||||
Triggers are what starts the processing of an automation rule. It is possible to specify multiple triggers for the same rule. Once a trigger starts, Home Assistant will validate the conditions, if any, and call the action.
|
||||
|
||||
#### {% linkable_title Event trigger %}
|
||||
Triggers when an event is being processed. Events are the raw building blocks of Home Assistant. You can match events on just the event name or also require specific event data to be present.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: event
|
||||
event_type: MY_CUSTOM_EVENT
|
||||
# optional
|
||||
event_data:
|
||||
mood: happy
|
||||
```
|
||||
|
||||
#### {% linkable_title MQTT trigger %}
|
||||
Triggers when a specific message is received on given topic. Optionally can match on the payload being sent over the topic.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: mqtt
|
||||
topic: living_room/switch/ac
|
||||
# Optional
|
||||
payload: 'on'
|
||||
```
|
||||
|
||||
#### {% linkable_title Numeric state trigger %}
|
||||
On state change of a specified entity, attempts to parse the state as a number and triggers if value is above and/or below a threshold.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: numeric_state
|
||||
entity_id: sensor.temperature
|
||||
# Optional
|
||||
value_template: '{% raw %}{{ state.attributes.battery }}{% endraw %}'
|
||||
# At least one of the following required
|
||||
above: 17
|
||||
below: 25
|
||||
```
|
||||
|
||||
#### {% linkable_title State trigger %}
|
||||
|
||||
Triggers when the state of an entity changes. If only entity_id given will match all state changes.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: device_tracker.paulus
|
||||
# Optional
|
||||
from: 'not_home'
|
||||
to: 'home'
|
||||
# If given, will trigger when state has been the to state for X time.
|
||||
for:
|
||||
hours: 1
|
||||
minutes: 10
|
||||
seconds: 5
|
||||
```
|
||||
|
||||
<p class='note warning'>
|
||||
Use quotes around your values for `from` and `to` to avoid the YAML parser interpreting values as booleans.
|
||||
</p>
|
||||
|
||||
#### {% linkable_title Sun trigger %}
|
||||
Trigger when the sun is setting or rising. An optional time offset can be given to have it trigger for example 45 minutes before sunset, when dusk is setting in.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: sun
|
||||
# Possible values: sunset, sunrise
|
||||
event: sunset
|
||||
# Optional time offset. This example is 45 minutes.
|
||||
offset: '-00:45:00'
|
||||
```
|
||||
|
||||
#### {% linkable_title Template trigger %}
|
||||
|
||||
Template triggers work by evaluating a [template] on each state change. The trigger will fire if the state change caused the template to render 'true'. This is achieved by having the template result in a true boolean expression (`{% raw %}{{ is_state('device_tracker.paulus', 'home') }}{% endraw %}`) or by having the template render 'true' (example below).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: template
|
||||
value_template: '{% raw %}{% if is_state('device_tracker.paulus', 'home') %}true{% endif %}{% endraw %}'
|
||||
```
|
||||
|
||||
#### {% linkable_title Time trigger %}
|
||||
|
||||
Time can be triggered in many ways. The most common is to specify `after` and trigger at a specific point in time each day. Alternatively, you can also match if the hour, minute or second of the current time has a specific value. You can prefix the value with a `/` to match whenever the value is divisible by that number. You cannot use `after` together with hour, minute or second.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: time
|
||||
# Matches every hour at 5 minutes past whole
|
||||
minutes: 5
|
||||
seconds: 0
|
||||
|
||||
automation 2:
|
||||
trigger:
|
||||
platform: time
|
||||
# When 'after' is used, you cannot also match on hour, minute, seconds.
|
||||
# Military time format.
|
||||
after: '15:32:00'
|
||||
|
||||
automation 3:
|
||||
trigger:
|
||||
platform: time
|
||||
# You can also match on interval. This will match every 5 minutes
|
||||
minutes: '/5'
|
||||
seconds: 0
|
||||
```
|
||||
|
||||
#### {% linkable_title Zone trigger %}
|
||||
|
||||
Zone triggers can trigger when an entity is entering or leaving the 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/) as well as the [iCloud platform](/components/device_tracker.icloud/).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: zone
|
||||
entity_id: device_tracker.paulus
|
||||
zone: zone.home
|
||||
# Event is either enter or leave
|
||||
event: enter
|
||||
```
|
||||
|
||||
## {% linkable_title Conditions %}
|
||||
|
||||
Conditions are an optional part of an automation rule and be used to prevent an action from happening when triggered. Conditions look very similar to triggers but are very different. A trigger will look at events happening in the system while a condition only looks at how the system looks right now. A trigger can observe that a switch is being turned on. A condition can only see if a switch is currently on or off.
|
||||
|
||||
An automation rule can have multiple conditions. By default the action will only fire if all conditions pass. An optional key `condition_type: 'or'` can be set on the automation rule to fire action if any condition matches. In the example below, the automation would trigger if the time is before 05:00 _OR_ after 20:00.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition_type: or
|
||||
condition:
|
||||
- platform: time
|
||||
before: '05:00'
|
||||
- platform: time
|
||||
after: '20:00'
|
||||
```
|
||||
|
||||
If your triggers and conditions are exactly the same, you can use a shortcut to specify conditions. In this case, triggers that are not valid conditions will be ignored.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition: use_trigger_values
|
||||
```
|
||||
|
||||
#### {% 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.
|
||||
Either `above` or `below`, or both need to be specified. If both are used, the condition is true when the value is >= `before` *and** < `after`.
|
||||
You can optionally use a `value_template` to make the value of the entity the same type of value as the condition.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition:
|
||||
platform: numeric_state
|
||||
entity_id: sensor.temperature
|
||||
above: 17
|
||||
below: 25
|
||||
```
|
||||
|
||||
#### {% linkable_title State condition %}
|
||||
|
||||
Tests if an entity is a specified state.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition:
|
||||
platform: 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).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition:
|
||||
platform: 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
|
||||
automation:
|
||||
condition:
|
||||
platform: template
|
||||
value_template: '{% raw %}{{ state.attributes.battery > 50 }}{% endraw %}'
|
||||
# Or value_template could be:
|
||||
# {% raw %}{% if state.attributes.battery > 50 %}true{% else %}false{% endif %}{% endraw %}
|
||||
```
|
||||
|
||||
#### {% 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
|
||||
automation:
|
||||
condition:
|
||||
platform: time
|
||||
# At least one of the following is required.
|
||||
after: '15:00:00'
|
||||
before: '23:00:00'
|
||||
weekday:
|
||||
- mon
|
||||
- wed
|
||||
- fri
|
||||
```
|
||||
|
||||
Valid values for `weekday` are (`sun`, `mon`, `tue`, `wed`, `thu`, `fri` & `sat`)
|
||||
|
||||
#### {% 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/) as well as the [iCloud platform](/components/device_tracker.icloud/).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition:
|
||||
platform: zone
|
||||
entity_id: device_tracker.paulus
|
||||
zone: zone.home
|
||||
```
|
||||
|
||||
## {% linkable_title Actions %}
|
||||
|
||||
When an automation rule fires, it calls a service. For this service you can specify the entity_id that it should apply to and optional service parameters (to specify for example the brightness).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
# Change the light in the kitchen and living room to 150 brightness and color red.
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
entity_id:
|
||||
- light.kitchen
|
||||
- light.living_room
|
||||
data:
|
||||
brightness: 150
|
||||
rgb_color: [255, 0, 0]
|
||||
```
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
# Notify me on my mobile phone of an event
|
||||
action:
|
||||
service: notify.notify
|
||||
data:
|
||||
message: Something just happened, better take a look!
|
||||
```
|
||||
|
||||
If you want to specify multiple services to be called, or to include a delay, have a look at the [script component](/components/script/). If you want to describe the desired state of certain entities, check out the [scene component](/components/scene/).
|
||||
|
||||
## {% linkable_title Troubleshooting %}
|
||||
|
||||
You can verify that your automation rules are being initialized correctly by watching both the realtime logs (`homeassistant.log` in the configuration directory) and also the [Logbook](/components/logbook/). The realtime logs will show the rules being initialized (once for each trigger), example:
|
||||
|
||||
```plain
|
||||
INFO [homeassistant.components.automation] Initialized rule Rainy Day
|
||||
INFO [homeassistant.components.automation] Initialized rule Rainy Day
|
||||
INFO [homeassistant.components.automation] Initialized rule Rainy Day
|
||||
INFO [homeassistant.components.automation] Initialized rule Rain is over
|
||||
```
|
||||
|
||||
The Logbook component will show a line entry when an automation is triggered. You can look at the previous entry to determine which trigger in the rule triggered the event.
|
||||
|
||||

|
||||
|
||||
[template]: /topics/templating/
|
||||
[getting started section]: /getting-started/automation/
|
||||
|
@ -146,7 +146,7 @@ Home Assistant will automatically load the correct certificate if you connect to
|
||||
- [MQTT Lock](/components/lock.mqtt/)
|
||||
- [MQTT Device Tracker](/components/device_tracker.mqtt/)
|
||||
- [OwnTracks Device Tracker](/components/device_tracker.owntracks/)
|
||||
- [MQTT automation rule](/components/automation/#mqtt-based-automation)
|
||||
- [MQTT automation rule](/getting-started/automation-trigger/#mqtt-trigger)
|
||||
|
||||
- Integrating it into own component. See the [MQTT example component](/cookbook/python_component_mqtt_basic/) how to do this.
|
||||
|
||||
|
@ -28,4 +28,4 @@ Configuration variables:
|
||||
- **name** (*Optional*): Setting the optional parameter `name` allows multiple notifiers to be created. The default value is `notify`. The notifier will bind to the service `notify.NOTIFIER_NAME`.
|
||||
- **command** (*Required*): The action to take.
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -30,4 +30,4 @@ Configuration variables:
|
||||
- **filename** (*Required*): Name of the file to use. The file will be created if it doesn't exist and saved in your `config/` folder.
|
||||
- **timestamp** (*Optional*): Setting `timestamp` to 1 adds a timestamp to every entry.
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -49,4 +49,4 @@ curl -X POST \
|
||||
```
|
||||
For further details, please check the [API](https://instapush.im/developer/rest).
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -37,7 +37,7 @@ Once loaded, the `notify` platform will expose a service that can be called to s
|
||||
|
||||
The notification component supports specifying [templates](/topics/templating/) for both the `message` and the `title`. This will allow you to use the current state of Home Assistant in your notifications.
|
||||
|
||||
In an [action](https://home-assistant.io/components/automation/#actions) of your [automation setup](/components/automation/) it could look like this with a customized subject.
|
||||
In an [action](https://home-assistant.io/getting-started/automation-action/) of your [automation setup](/getting-started/automation/) it could look like this with a customized subject.
|
||||
|
||||
```yaml
|
||||
action:
|
||||
|
@ -31,4 +31,4 @@ Configuration variables:
|
||||
|
||||
Details for the API : https://www.notifymyandroid.com/api.jsp
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -45,4 +45,4 @@ curl -X POST \
|
||||
|
||||
For further details, please check the [API](http://pushetta.com/pushetta-api/).
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -36,5 +36,5 @@ Configuration variables:
|
||||
- **title_param_name** (*Optional*): Parameter name for the title. Defaults to none.
|
||||
- **target_param_name** (*Optional*): Parameter name for the target. Defaults to none.
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
||||
|
@ -32,4 +32,4 @@ Configuration variables:
|
||||
- **sender** (*Required*): E-mail address of the sender.
|
||||
- **recipient** (*Required*): Recipient of the notification.
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -33,5 +33,5 @@ Configuration variables:
|
||||
- **api_key** (*Required*): The slack API token to use for sending slack messages. You can get your slack API token here https://api.slack.com/web?sudo=1
|
||||
- **default_channel** (*Required*): The default channel to post to if no channel is explicitly specified when sending the notification message.
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
||||
|
@ -50,4 +50,4 @@ Keep in mind that if the password contains a colon, it needs to be wrapped in ap
|
||||
For Google Mail (smtp.gmail.com) an additional step in the setup process is needed. Google has some extra layers of protection
|
||||
which need special attention. By default, the usage by external applications, especially scripts, is limited. Visit the [Less secure apps](https://www.google.com/settings/security/lesssecureapps) page and enable it.
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -57,4 +57,4 @@ The table contains values to use in your `configuration.yaml` file.
|
||||
|
||||
For details about facility, option, and priority please consult the [wikpedia article](http://en.wikipedia.org/wiki/Syslog) and [RFC 3164](http://tools.ietf.org/html/rfc3164).
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -64,4 +64,4 @@ Configuration variables:
|
||||
- **api_key** (*Required*): The API token of your bot.
|
||||
- **chat_id** (*Required*: The chat ID of your user.
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -35,4 +35,4 @@ Configuration variables:
|
||||
- **consumer_secret** (*Required*): Your "Consumer Secret" (API Secret) for the application.
|
||||
- **access_token_secret** (*Required*): Your "Access Token Secret" for the application.
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -36,4 +36,4 @@ Configuration variables:
|
||||
All Jabber IDs (JID) must include the domain. Make sure that the password matches the account provided as sender.
|
||||
|
||||
|
||||
To use notifications, please see the [getting started with automation page]({{site_root}}/components/automation/).
|
||||
To use notifications, please see the [getting started with automation page](/getting-started/automation/).
|
||||
|
@ -13,7 +13,7 @@ ha_category: Organization
|
||||
|
||||
The `proximity` component allows you to monitor the proximity of devices to a particular [zone](/components/zone/) and the direction of travel. The result is an entity created in Home Assistant which maintains the proximity data.
|
||||
|
||||
This component is useful to reduce the number of automation rules required when wanting to perform automations based on locations outside a particular zone. The [zone](/components/automation/#zone-trigger) and [state](/components/automation/#state-trigger) based triggers allow similar control but the number of rules grows exponentially when factors such as direction of travel need to be taken into account.
|
||||
This component is useful to reduce the number of automation rules required when wanting to perform automations based on locations outside a particular zone. The [zone](/getting-started/automation-trigger/#zone-trigger) and [state](/getting-started/automation-trigger/#state-trigger) based triggers allow similar control but the number of rules grows exponentially when factors such as direction of travel need to be taken into account.
|
||||
|
||||
Some examples of its use include:
|
||||
|
||||
|
@ -13,7 +13,7 @@ ha_category: Weather
|
||||
|
||||
The sun component will use your current location to track if the sun is above or below the horizon.The sun can be used within automation as [a trigger with an optional offset to simulate dawn/dusk][automation-trigger].
|
||||
|
||||
[automation-trigger]: /components/automation/#sun-trigger
|
||||
[automation-trigger]: /getting-started/automation-trigger/#sun-trigger
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
|
@ -11,7 +11,7 @@ logo: home-assistant.png
|
||||
ha_category: Organization
|
||||
---
|
||||
|
||||
Zones allow you to specify certain regions on earth (for now). When a device tracker sees a device to be within a zone, the state will take the name from the zone. Zones can also be used as a [trigger](/components/automation/#zone-trigger) or [condition](/components/automation/#zone-condition) inside automation setups.
|
||||
Zones allow you to specify certain regions on earth (for now). When a device tracker sees a device to be within a zone, the state will take the name from the zone. Zones can also be used as a [trigger](/getting-started/automation-trigger/#zone-trigger) or [condition](/getting-started/automation-condition/#zone-condition) inside automation setups.
|
||||
|
||||
Zones support the usual method to specify multiple zones, use keys `zone:`, `zone 2:` etc.
|
||||
|
||||
|
@ -21,10 +21,18 @@
|
||||
<li>{% active_link /getting-started/devices/ Setting up devices %}</li>
|
||||
<li>{% active_link /getting-started/customizing-devices/ Customizing devices and services %}</li>
|
||||
<li>{% active_link /getting-started/presence-detection/ Presence Detection %}</li>
|
||||
<li>{% active_link /getting-started/automation/ Automation %}</li>
|
||||
<li>{% active_link /getting-started/troubleshooting-configuration/ Troubleshooting configuration.yaml %}</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
{% active_link /getting-started/automation/ Automation %}
|
||||
<ul>
|
||||
<li>{% active_link /getting-started/automation-create-first/ Tutorial %}</li>
|
||||
<li>{% active_link /getting-started/automation-trigger/ Triggers %}</li>
|
||||
<li>{% active_link /getting-started/automation-condition/ Conditions %}</li>
|
||||
<li>{% active_link /getting-started/automation-action/ Actions %}</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
{% active_link /getting-started/autostart/ Auto-start Home Assistant %}
|
||||
<ul>
|
||||
|
@ -16,7 +16,7 @@ __MQTT Support__
|
||||
<img src='/images/supported_brands/mqtt.png' style='border:none; box-shadow: none; float: right;' height='50' /> The big new addition in this release is the support for the MQTT protocol by [@fabaff](https://github.com/fabaff) with some help from [@balloob](https://github.com/balloob). It will now be possible to integrate any IoT device that talks via MQTT. For the initial release we support connecting Home Assistant to a broker (no TLS yet). Components can now subscribe and publish to MQTT topics ([see the example][mqtt-example]) and also support for the automation component [has been added][mqtt-automation]. For more information, see [the MQTT component page][mqtt-component].
|
||||
|
||||
[mqtt-example]: https://github.com/home-assistant/home-assistant/blob/dev/config/custom_components/mqtt_example.py
|
||||
[mqtt-automation]: /components/automation/#mqtt-based-automation
|
||||
[mqtt-automation]: /getting-started/automation-trigger/#mqtt-trigger
|
||||
[mqtt-component]: /components/mqtt/
|
||||
|
||||
```yaml
|
||||
|
@ -35,7 +35,7 @@ Next it was just a matter of integrating everything with Home Assistant. I was
|
||||
Status of the dryer and washer in Home Assistant
|
||||
</p>
|
||||
|
||||
Next I wrote [scripts](/components/script/) that are run whenever the washer or dryer completes a load. This is triggered by the [automation component](/components/automation/). When the laundry is complete I have the lights in the house turn red and [notify me via PushBullet](/components/notify.pushbullet/). Once the laundry is taken care of another script runs that sets the lights back to normal. So far it has been very helpful and very reliable.
|
||||
Next I wrote [scripts](/components/script/) that are run whenever the washer or dryer completes a load. This is triggered by the [automation component](/getting-started/automation/). When the laundry is complete I have the lights in the house turn red and [notify me via PushBullet](/components/notify.pushbullet/). Once the laundry is taken care of another script runs that sets the lights back to normal. So far it has been very helpful and very reliable.
|
||||
|
||||
<p class='img'>
|
||||
<a href='/images/blog/2015-08-laundry-automation/moteino-and-sensors.jpg'>
|
||||
|
@ -21,7 +21,7 @@ We have added a new [getting started section][start-presence] to get up and runn
|
||||
|
||||
[platform-owntracks]: /components/device_tracker.owntracks/
|
||||
[component-zone]: /components/zone/
|
||||
[zone-automation]: /components/automation/#zone-trigger
|
||||
[zone-automation]: /getting-started/automation-trigger/#zone-trigger
|
||||
[start-presence]: /getting-started/presence-detection/
|
||||
|
||||
<p class='img'>
|
||||
|
@ -40,7 +40,7 @@ After two weeks of hard work I'm proud to announce the release of Home Assistant
|
||||
As part of this release we did some cleanup which introduced backwards incompatible changes:
|
||||
|
||||
**Heat Control thermostat no longer includes scheduling features.**
|
||||
This feature has been removed completely. Use the [automation component](/components/automation/) instead to control target temperature.
|
||||
This feature has been removed completely. Use the [automation component](/getting-started/automation/) instead to control target temperature.
|
||||
|
||||
**Config changed for calling a service from a script.**
|
||||
`execute_service:` has been replaced with `service:`. See [component page](/components/script/) for example. The old method will continue working for some time.
|
||||
|
@ -17,7 +17,7 @@ The idea was to anonymously collect some details about the usage of the differen
|
||||
<!--more-->
|
||||
Thanks to Python, users are running Home Assistant on the most popular Linux distributions and other operating systems including OS X and Microsoft Windows. One quarter of the operating systems are unknown which leads to the assumption that it is possible to run Home Assistant on most of the available operation systems today. We hope that *BSD users have fun too. The Hardware platform of choice seems to be x86_64 and ARM.
|
||||
|
||||
Of course most users are running with the [automation](/components/automation/) component otherwise it would make much sense to use Home Assistant. The [sun](/components/sun/) component is used a lot too. We hope that this is not because this component is enabled by default.
|
||||
Of course most users are running with the [automation](/getting-started/automation/) component otherwise it would make much sense to use Home Assistant. The [sun](/components/sun/) component is used a lot too. We hope that this is not because this component is enabled by default.
|
||||
|
||||
The [Alarm control panels](/components/alarm_control_panel/) and the [camera component](/components/camera/) are both used by around one third of the participants of the survey. It's safe to say that they cover a niche, but they will gain momentum when people discover how they can build alarm systems with Home Assistant.
|
||||
|
||||
|
@ -91,4 +91,4 @@ Affected components and platforms:
|
||||
[rollershutter.mqtt]: /components/rollershutter.mqtt/
|
||||
[light.mqtt]: /components/light.mqtt/
|
||||
[binary_sensor.mqtt]: /components/binary_sensor.mqtt/
|
||||
[automation-numeric-state]: /components/automation/#numeric-state-trigger
|
||||
[automation-numeric-state]: /getting-started/automation-trigger/#numeric-state-trigger
|
||||
|
@ -42,7 +42,7 @@ First release of 2016 and we are on 🔥! The [main repository][github-ha] has p
|
||||
[MySensors]: /components/mysensors/
|
||||
[YR]: /components/sensor.yr/
|
||||
[Locative]: /components/device_tracker.locative/
|
||||
[sun condition]: /components/automation/#sun-condition
|
||||
[sun condition]: /getting-started/automation-condition/#sun-condition
|
||||
[command_switch]: /components/switch.command_switch/
|
||||
[wemo]: /components/switch.wemo/
|
||||
[Telldus Live]: /components/tellduslive/
|
||||
|
@ -56,7 +56,7 @@ Example of the new views in the frontend. <a href='/components/group/'>Learn mor
|
||||
[Statsd]: /components/statsd/
|
||||
[Template]: /components/sensor.template/
|
||||
[Thermostat]: /components/thermostat/
|
||||
[time automation]: /components/automation/#time-trigger
|
||||
[time automation]: /getting-started/automation-trigger/#time-trigger
|
||||
[Twitter]: /components/notify.twitter/
|
||||
[Wink]: /components/wink/
|
||||
[Zigbee]: /components/zigbee/
|
||||
|
@ -57,8 +57,8 @@ It's been another two weeks which means it's time for release: 0.14!
|
||||
[sensor.tcp]: /components/sensor.tcp/
|
||||
[Neurio energy sensor]: /components/sensor.neurio_energy/
|
||||
[nx584]: /components/binary_sensor.nx584/
|
||||
[triggers]: /components/automation/#state-trigger
|
||||
[conditions]: /components/automation/#state-condition
|
||||
[triggers]: /getting-started/automation-trigger/#state-trigger
|
||||
[conditions]: /getting-started/automation-condition/#state-condition
|
||||
[Nest]: /components/sensor.nest/
|
||||
[Ubiquiti Unifi]: /components/device_tracker.unifi/
|
||||
[MySensors]: /components/binary_sensor.mysensors/
|
||||
|
@ -13,7 +13,7 @@ hide_github_edit: true
|
||||
|
||||
This is a community curated list of different ways to use Home Assistant. Most of these examples are using the [automation] component and other built-in [automation related][sec-automation] and [organization] components available.
|
||||
|
||||
[automation]: /components/automation/
|
||||
[automation]: /getting-started/automation/
|
||||
[sec-automation]: /components/#automation
|
||||
[organization]: /components/#organization
|
||||
|
||||
|
36
source/getting-started/automation-action.markdown
Normal file
36
source/getting-started/automation-action.markdown
Normal file
@ -0,0 +1,36 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Automation Actions"
|
||||
description: "Automations result in action."
|
||||
date: 2016-04-24 08:30 +0100
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
When an automation rule fires, it calls a service. For this service you can specify the entity_id that it should apply to and optional service parameters (to specify for example the brightness).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
# Change the light in the kitchen and living room to 150 brightness and color red.
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
entity_id:
|
||||
- light.kitchen
|
||||
- light.living_room
|
||||
data:
|
||||
brightness: 150
|
||||
rgb_color: [255, 0, 0]
|
||||
```
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
# Notify me on my mobile phone of an event
|
||||
action:
|
||||
service: notify.notify
|
||||
data:
|
||||
message: Something just happened, better take a look!
|
||||
```
|
||||
|
||||
If you want to specify multiple services to be called, or to include a delay, have a look at the [script component](/components/script/). If you want to describe the desired state of certain entities, check out the [scene component](/components/scene/).
|
121
source/getting-started/automation-condition.markdown
Normal file
121
source/getting-started/automation-condition.markdown
Normal file
@ -0,0 +1,121 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Automation Conditions"
|
||||
description: "Automations can test conditions when invoked."
|
||||
date: 2016-04-24 08:30 +0100
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
Conditions are an optional part of an automation rule and be used to prevent an action from happening when triggered. Conditions look very similar to triggers but are very different. A trigger will look at events happening in the system while a condition only looks at how the system looks right now. A trigger can observe that a switch is being turned on. A condition can only see if a switch is currently on or off.
|
||||
|
||||
An automation rule can have multiple conditions. By default the action will only fire if all conditions pass. An optional key `condition_type: 'or'` can be set on the automation rule to fire action if any condition matches. In the example below, the automation would trigger if the time is before 05:00 _OR_ after 20:00.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition_type: or
|
||||
condition:
|
||||
- platform: time
|
||||
before: '05:00'
|
||||
- platform: time
|
||||
after: '20:00'
|
||||
```
|
||||
|
||||
If your triggers and conditions are exactly the same, you can use a shortcut to specify conditions. In this case, triggers that are not valid conditions will be ignored.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition: use_trigger_values
|
||||
```
|
||||
|
||||
#### {% 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.
|
||||
Either `above` or `below`, or both need to be specified. If both are used, the condition is true when the value is >= `before` *and** < `after`.
|
||||
You can optionally use a `value_template` to make the value of the entity the same type of value as the condition.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition:
|
||||
platform: numeric_state
|
||||
entity_id: sensor.temperature
|
||||
above: 17
|
||||
below: 25
|
||||
```
|
||||
|
||||
#### {% linkable_title State condition %}
|
||||
|
||||
Tests if an entity is a specified state.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition:
|
||||
platform: 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).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
condition:
|
||||
platform: 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
|
||||
automation:
|
||||
condition:
|
||||
platform: template
|
||||
value_template: '{% raw %}{{ state.attributes.battery > 50 }}{% endraw %}'
|
||||
# Or value_template could be:
|
||||
# {% raw %}{% if state.attributes.battery > 50 %}true{% else %}false{% endif %}{% endraw %}
|
||||
```
|
||||
|
||||
#### {% 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
|
||||
automation:
|
||||
condition:
|
||||
platform: time
|
||||
# At least one of the following is required.
|
||||
after: '15:00:00'
|
||||
before: '23:00:00'
|
||||
weekday:
|
||||
- mon
|
||||
- wed
|
||||
- fri
|
||||
```
|
||||
|
||||
Valid values for `weekday` are (`sun`, `mon`, `tue`, `wed`, `thu`, `fri` & `sat`)
|
||||
|
||||
#### {% 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
|
||||
automation:
|
||||
condition:
|
||||
platform: zone
|
||||
entity_id: device_tracker.paulus
|
||||
zone: zone.home
|
||||
```
|
100
source/getting-started/automation-create-first.markdown
Normal file
100
source/getting-started/automation-create-first.markdown
Normal file
@ -0,0 +1,100 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Your First Automation"
|
||||
description: "Step by step guiding through making your first automation."
|
||||
date: 2016-04-24 08:30 +0100
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
Before we dive deeper into what every piece of automation _can_ do, let's look at a simple automation rule: **Turn on the lights when the sun sets**
|
||||
|
||||
In this example, we are defining a trigger to track the sunset and tell it to fire when the sun is setting. When this event is triggered, the service `light.turn_on` is called without any parameters. Because we specify no parameters, it will turn on all the lights.
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
automation:
|
||||
alias: Turn on light when sun sets
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
action:
|
||||
service: light.turn_on
|
||||
```
|
||||
|
||||
After a few days of running this automation rule you come to realize that this automation rule is not good enough. It was already dark when the lights went on and the one day you weren't home, the lights turned on anyway. Time for some tweaking. Let's add an offset to the sunset trigger and a condition to only turn on the lights if anyone is home.
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
automation:
|
||||
alias: Turn on light when sun sets
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
offset: "-01:00:00"
|
||||
condition:
|
||||
platform: state
|
||||
entity_id: group.all_devices
|
||||
state: home
|
||||
action:
|
||||
service: light.turn_on
|
||||
```
|
||||
|
||||
Now you're happy and all is good. You start to like this automation business and buy some more lights, this time you put them in the bedroom. But what you now realize is that when the sun is setting, the lights in the bedroom are also being turned on! Time to tweak the automation to only turn on the living room lights.
|
||||
|
||||
The first thing you do is to look at the entities in the developer tools (second icon) in the app. You see the names of your lights and you write them down: `light.table_lamp`, `light.bedroom`, `light.ceiling`.
|
||||
|
||||
Instead of hard coding the entity IDs of the lights in the automation rule, we will set up a group. This will allow us to see the living room separate in the app and be able to address it from automation rules.
|
||||
|
||||
So we tweak the config to add the group and have the automation rule only turn on the group.
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
group:
|
||||
living_room:
|
||||
- light.table_lamp
|
||||
- light.ceiling
|
||||
|
||||
automation:
|
||||
alias: Turn on light when sun sets
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
offset: "-01:00:00"
|
||||
condition:
|
||||
platform: state
|
||||
entity_id: group.all_devices
|
||||
state: home
|
||||
action:
|
||||
service: light.turn_on
|
||||
entity_id: group.living_room
|
||||
```
|
||||
|
||||
Christmas is coming along and you decide to buy a remote switch to control the Christmas lights from Home Assistant. You can't claim to live in the house of the future if you're still manually turning on your Christmas lights!
|
||||
|
||||
We hook the switch up to Home Assistant and grab the entity ID0 from the developer tools: `switch.christmas_lights`. We will update the group to include the switch and will change our action. We are no longer able to call `light.turn_on` because we also want to turn on a switch. This is where `homeassistant.turn_on` comes to the rescue. This service is capable of turning any entity on.
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
group:
|
||||
living_room:
|
||||
- light.table_lamp
|
||||
- light.ceiling
|
||||
- switch.christmas_lights
|
||||
|
||||
automation:
|
||||
alias: Turn on light when sun sets
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
offset: "-01:00:00"
|
||||
condition:
|
||||
platform: state
|
||||
entity_id: group.all_devices
|
||||
state: home
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
entity_id: group.living_room
|
||||
```
|
64
source/getting-started/automation-examples.markdown
Normal file
64
source/getting-started/automation-examples.markdown
Normal file
@ -0,0 +1,64 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Automation Examples"
|
||||
description: "Some automation examples to get you started."
|
||||
date: 2016-04-24 08:30 +0100
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
```yaml
|
||||
# Example of entry in configuration.yaml
|
||||
automation:
|
||||
# Turns on lights 1 hour before sunset if people are home
|
||||
# and if people get home between 16:00-23:00
|
||||
- alias: 'Rule 1 Light on in the evening'
|
||||
trigger:
|
||||
# Prefix the first line of each trigger configuration
|
||||
# with a '-' to enter multiple
|
||||
- platform: sun
|
||||
event: sunset
|
||||
offset: '-01:00:00'
|
||||
- platform: state
|
||||
entity_id: group.all_devices
|
||||
state: 'home'
|
||||
condition:
|
||||
# Prefix the first line of each condition configuration
|
||||
# with a '-'' to enter multiple
|
||||
- platform: state
|
||||
entity_id: group.all_devices
|
||||
state: 'home'
|
||||
- platform: time
|
||||
after: '16:00:00'
|
||||
before: '23:00:00'
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
entity_id: group.living_room
|
||||
|
||||
# Turn off lights when everybody leaves the house
|
||||
- alias: 'Rule 2 - Away Mode'
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: group.all_devices
|
||||
state: 'not_home'
|
||||
action:
|
||||
service: light.turn_off
|
||||
entity_id: group.all_lights
|
||||
|
||||
# Notify when Paulus leaves the house in the evening
|
||||
- alias: 'Leave Home notification'
|
||||
trigger:
|
||||
platform: zone
|
||||
event: leave
|
||||
zone: zone.home
|
||||
entity_id: device_tracker.paulus
|
||||
condition:
|
||||
platform: time
|
||||
after: '20:00'
|
||||
action:
|
||||
service: notify.notify
|
||||
data:
|
||||
message: 'Paulus left the house'
|
||||
```
|
140
source/getting-started/automation-trigger.markdown
Normal file
140
source/getting-started/automation-trigger.markdown
Normal file
@ -0,0 +1,140 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Automation Trigger"
|
||||
description: "All the different ways how automations can be triggered."
|
||||
date: 2016-04-24 08:30 +0100
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
Triggers are what starts the processing of an automation rule. It is possible to specify multiple triggers for the same rule. Once a trigger starts, Home Assistant will validate the conditions, if any, and call the action.
|
||||
|
||||
#### {% linkable_title Event trigger %}
|
||||
Triggers when an event is being processed. Events are the raw building blocks of Home Assistant. You can match events on just the event name or also require specific event data to be present.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: event
|
||||
event_type: MY_CUSTOM_EVENT
|
||||
# optional
|
||||
event_data:
|
||||
mood: happy
|
||||
```
|
||||
|
||||
#### {% linkable_title MQTT trigger %}
|
||||
Triggers when a specific message is received on given topic. Optionally can match on the payload being sent over the topic.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: mqtt
|
||||
topic: living_room/switch/ac
|
||||
# Optional
|
||||
payload: 'on'
|
||||
```
|
||||
|
||||
#### {% linkable_title Numeric state trigger %}
|
||||
On state change of a specified entity, attempts to parse the state as a number and triggers if value is above and/or below a threshold.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: numeric_state
|
||||
entity_id: sensor.temperature
|
||||
# Optional
|
||||
value_template: '{% raw %}{{ state.attributes.battery }}{% endraw %}'
|
||||
# At least one of the following required
|
||||
above: 17
|
||||
below: 25
|
||||
```
|
||||
|
||||
#### {% linkable_title State trigger %}
|
||||
|
||||
Triggers when the state of an entity changes. If only entity_id given will match all state changes.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: device_tracker.paulus
|
||||
# Optional
|
||||
from: 'not_home'
|
||||
to: 'home'
|
||||
# If given, will trigger when state has been the to state for X time.
|
||||
for:
|
||||
hours: 1
|
||||
minutes: 10
|
||||
seconds: 5
|
||||
```
|
||||
|
||||
<p class='note warning'>
|
||||
Use quotes around your values for `from` and `to` to avoid the YAML parser interpreting values as booleans.
|
||||
</p>
|
||||
|
||||
#### {% linkable_title Sun trigger %}
|
||||
Trigger when the sun is setting or rising. An optional time offset can be given to have it trigger for example 45 minutes before sunset, when dusk is setting in.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: sun
|
||||
# Possible values: sunset, sunrise
|
||||
event: sunset
|
||||
# Optional time offset. This example is 45 minutes.
|
||||
offset: '-00:45:00'
|
||||
```
|
||||
|
||||
#### {% linkable_title Template trigger %}
|
||||
|
||||
Template triggers work by evaluating a [template] on each state change. The trigger will fire if the state change caused the template to render 'true'. This is achieved by having the template result in a true boolean expression (`{% raw %}{{ is_state('device_tracker.paulus', 'home') }}{% endraw %}`) or by having the template render 'true' (example below).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: template
|
||||
value_template: '{% raw %}{% if is_state('device_tracker.paulus', 'home') %}true{% endif %}{% endraw %}'
|
||||
```
|
||||
|
||||
#### {% linkable_title Time trigger %}
|
||||
|
||||
Time can be triggered in many ways. The most common is to specify `after` and trigger at a specific point in time each day. Alternatively, you can also match if the hour, minute or second of the current time has a specific value. You can prefix the value with a `/` to match whenever the value is divisible by that number. You cannot use `after` together with hour, minute or second.
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: time
|
||||
# Matches every hour at 5 minutes past whole
|
||||
minutes: 5
|
||||
seconds: 0
|
||||
|
||||
automation 2:
|
||||
trigger:
|
||||
platform: time
|
||||
# When 'after' is used, you cannot also match on hour, minute, seconds.
|
||||
# Military time format.
|
||||
after: '15:32:00'
|
||||
|
||||
automation 3:
|
||||
trigger:
|
||||
platform: time
|
||||
# You can also match on interval. This will match every 5 minutes
|
||||
minutes: '/5'
|
||||
seconds: 0
|
||||
```
|
||||
|
||||
#### {% linkable_title Zone trigger %}
|
||||
|
||||
Zone triggers can trigger when an entity is entering or leaving the 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/) as well as the [iCloud platform](/components/device_tracker.icloud/).
|
||||
|
||||
```yaml
|
||||
automation:
|
||||
trigger:
|
||||
platform: zone
|
||||
entity_id: device_tracker.paulus
|
||||
zone: zone.home
|
||||
# Event is either enter or leave
|
||||
event: enter
|
||||
```
|
25
source/getting-started/automation-troubleshooting.markdown
Normal file
25
source/getting-started/automation-troubleshooting.markdown
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Troubleshooting Automations"
|
||||
description: "Tips on how to troubleshoot your automations."
|
||||
date: 2016-04-24 08:30 +0100
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
You can verify that your automation rules are being initialized correctly by watching both the realtime logs (`homeassistant.log` in the configuration directory) and also the [Logbook](/components/logbook/). The realtime logs will show the rules being initialized (once for each trigger), example:
|
||||
|
||||
```plain
|
||||
INFO [homeassistant.components.automation] Initialized rule Rainy Day
|
||||
INFO [homeassistant.components.automation] Initialized rule Rainy Day
|
||||
INFO [homeassistant.components.automation] Initialized rule Rainy Day
|
||||
INFO [homeassistant.components.automation] Initialized rule Rain is over
|
||||
```
|
||||
|
||||
The Logbook component will show a line entry when an automation is triggered. You can look at the previous entry to determine which trigger in the rule triggered the event.
|
||||
|
||||

|
||||
|
||||
[template]: /topics/templating/
|
@ -9,7 +9,7 @@ sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
When all your devices are set up it's time to put the cherry on the pie: automation. Home Assistant offers [a few built-in automations](/components/#automation) but mainly you'll be using [the automation component](/components/automation/) to set up your own rules.
|
||||
When all your devices are set up it's time to put the cherry on the pie: automation. Home Assistant offers [a few built-in automations](/components/#automation) but mainly you'll be using the automation component to set up your own rules.
|
||||
|
||||
### {% linkable_title The basics of automation %}
|
||||
|
||||
@ -37,104 +37,14 @@ Each device is represented in Home Assistant as an entity consisting of the foll
|
||||
|
||||
A service can be called to have Home Assistant perform an action. Turn on a light, run a script or enable a scene. Each service has a domain and a name. For example the service `light.turn_on` is capable of turning on any light device in your system. Services can be passed parameters to for example tell which device to turn on or what color to use.
|
||||
|
||||
## {% linkable_title Creating your first automation rule %}
|
||||
|
||||
Before we dive deeper into what every piece of automation _can_ do, let's look at a simple automation rule: **Turn on the lights when the sun sets**
|
||||
|
||||
In this example, we are defining a trigger to track the sunset and tell it to fire when the sun is setting. When this event is triggered, the service `light.turn_on` is called without any parameters. Because we specify no parameters, it will turn on all the lights.
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
automation:
|
||||
alias: Turn on light when sun sets
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
action:
|
||||
service: light.turn_on
|
||||
```
|
||||
|
||||
After a few days of running this automation rule you come to realize that this automation rule is not good enough. It was already dark when the lights went on and the one day you weren't home, the lights turned on anyway. Time for some tweaking. Let's add an offset to the sunset trigger and a condition to only turn on the lights if anyone is home.
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
automation:
|
||||
alias: Turn on light when sun sets
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
offset: "-01:00:00"
|
||||
condition:
|
||||
platform: state
|
||||
entity_id: group.all_devices
|
||||
state: home
|
||||
action:
|
||||
service: light.turn_on
|
||||
```
|
||||
|
||||
Now you're happy and all is good. You start to like this automation business and buy some more lights, this time you put them in the bedroom. But what you now realize is that when the sun is setting, the lights in the bedroom are also being turned on! Time to tweak the automation to only turn on the living room lights.
|
||||
|
||||
The first thing you do is to look at the entities in the developer tools (second icon) in the app. You see the names of your lights and you write them down: `light.table_lamp`, `light.bedroom`, `light.ceiling`.
|
||||
|
||||
Instead of hard coding the entity IDs of the lights in the automation rule, we will set up a group. This will allow us to see the living room separate in the app and be able to address it from automation rules.
|
||||
|
||||
So we tweak the config to add the group and have the automation rule only turn on the group.
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
group:
|
||||
living_room:
|
||||
- light.table_lamp
|
||||
- light.ceiling
|
||||
|
||||
automation:
|
||||
alias: Turn on light when sun sets
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
offset: "-01:00:00"
|
||||
condition:
|
||||
platform: state
|
||||
entity_id: group.all_devices
|
||||
state: home
|
||||
action:
|
||||
service: light.turn_on
|
||||
entity_id: group.living_room
|
||||
```
|
||||
|
||||
Christmas is coming along and you decide to buy a remote switch to control the Christmas lights from Home Assistant. You can't claim to live in the house of the future if you're still manually turning on your Christmas lights!
|
||||
|
||||
We hook the switch up to Home Assistant and grab the entity ID0 from the developer tools: `switch.christmas_lights`. We will update the group to include the switch and will change our action. We are no longer able to call `light.turn_on` because we also want to turn on a switch. This is where `homeassistant.turn_on` comes to the rescue. This service is capable of turning any entity on.
|
||||
|
||||
```yaml
|
||||
# Example configuration.yaml entry
|
||||
group:
|
||||
living_room:
|
||||
- light.table_lamp
|
||||
- light.ceiling
|
||||
- switch.christmas_lights
|
||||
|
||||
automation:
|
||||
alias: Turn on light when sun sets
|
||||
trigger:
|
||||
platform: sun
|
||||
event: sunset
|
||||
offset: "-01:00:00"
|
||||
condition:
|
||||
platform: state
|
||||
entity_id: group.all_devices
|
||||
state: home
|
||||
action:
|
||||
service: homeassistant.turn_on
|
||||
entity_id: group.living_room
|
||||
```
|
||||
|
||||
### {% linkable_title Further reading %}
|
||||
|
||||
We went over the basics of creating a home automation rule. Now, go automate!
|
||||
|
||||
- Learn about the available [automation triggers](/components/automation/#triggers)
|
||||
- Learn about the available [automation conditions](/components/automation/#conditions)
|
||||
- Learn about the available [automation triggers](/getting-started/automation-trigger/)
|
||||
- Learn about the available [automation conditions](/getting-started/automation-condition/)
|
||||
- Learn about [scripts](/components/script/) to help you trigger multiple actions and delays
|
||||
- Learn about [scenes](/components/scene/) to help you set many entities at once to your liking
|
||||
- Setup a [notification platform](/components/#notifications) to sent yourself messages
|
||||
|
@ -50,6 +50,6 @@ Home Assistant will know the location of your device if you are using OwnTracks.
|
||||
[mqtt-self]: /components/mqtt/#run-your-own
|
||||
[mqtt-cloud]: /components/mqtt/#cloudmqtt
|
||||
[zone]: /components/zone/
|
||||
[trigger]: /components/automation/#zone-trigger
|
||||
[condition]: /components/automation/#zone-condition
|
||||
[trigger]: /getting-started/automation-trigger/#zone-trigger
|
||||
[condition]: /getting-started/automation-condition/#zone-condition
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user