<p>This page will go into more detail about the various options the <code>automation</code> component offers. If you haven’t yet, read the <ahref="/getting-started/automation/">getting started page on automation</a>.</p>
<p>A configuration section of an automation requires a <code>trigger</code> and an <code>action</code> section. <code>condition</code> and <code>condition_type</code> are optional. To keep this page compact, all following sections will not show the full configuration but only the relevant part.</p>
<ul>
<li><ahref="#conditions">Jump to conditions</a></li>
<li><ahref="#actions">Jump to actions</a></li>
<li><ahref="#troubleshooting">Jump to troubleshooting</a></li>
<p>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.</p>
<p>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.</p>
Use quotes around your values for <code>from</code> and <code>to</code> to avoid the YAML parser interpreting values as booleans.
</p>
<h4><aclass="title-link"name="sun-trigger"href="#sun-trigger"></a> Sun trigger</h4>
<p>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.</p>
<p>Template triggers work by evaluating a <ahref="/topics/templating/">template</a> 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 (<code>{{ is_state('device_tracker.paulus', 'home') }}</code>) or by having the template render ‘true’ (example below).</p>
<spanclass="key">value_template</span>: <spanclass="string"><spanclass="content">'{% if is_state('device_tracker.paulus', 'home') %}true{% endif %}'</span></span>
</pre></div>
</div>
</div>
<h4><aclass="title-link"name="time-trigger"href="#time-trigger"></a> Time trigger</h4>
<p>Time can be triggered in many ways. The most common is to specify <code>after</code> 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 <code>/</code> to match whenever the value is divisible by that number. You cannot use <code>after</code> together with hour, minute or second.</p>
<h4><aclass="title-link"name="zone-trigger"href="#zone-trigger"></a> Zone trigger</h4>
<p>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 <ahref="/components/device_tracker.owntracks/">OwnTracks platform</a> as well as the <ahref="/components/device_tracker.icloud/">iCloud platform</a>.</p>
<p>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.</p>
<p>An automation rule can have multiple conditions. By default the action will only fire if all conditions pass. An optional key <code>condition_type: 'or'</code> 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 <em>OR</em> after 20:00.</p>
<p>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.</p>
<h4><aclass="title-link"name="numeric-state-condition"href="#numeric-state-condition"></a> Numeric state condition</h4>
<p>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. <br/>
Either <code>above</code> or <code>below</code>, or both need to be specified. If both are used, the condition is true when the value is >= <code>before</code> *and** <<code>after</code>. <br/>
You can optionally use a <code>value_template</code> to make the value of the entity the same type of value as the condition.</p>
<h4><aclass="title-link"name="sun-condition"href="#sun-condition"></a> Sun condition</h4>
<p>The sun condition can test if the sun has already set or risen when a trigger occurs. The <code>before</code> and <code>after</code> keys can only be set to <code>sunset</code> or <code>sunrise</code>. They have a corresponding optional offset value (<code>before_offset</code>, <code>after_offset</code>) that can be added, similar to the <ahref="#sun-trigger">sun trigger</a>.</p>
<p>The template condition will test if the <ahref="/topics/templating/">given template</a> 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’.</p>
<p>Valid values for <code>weekday</code> are (<code>sun</code>, <code>mon</code>, <code>tue</code>, <code>wed</code>, <code>thu</code>, <code>fri</code>&<code>sat</code>)</p>
<h4><aclass="title-link"name="zone-condition"href="#zone-condition"></a> Zone condition</h4>
<p>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 <ahref="/components/device_tracker.owntracks/">OwnTracks platform</a> as well as the <ahref="/components/device_tracker.icloud/">iCloud platform</a>.</p>
<p>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).</p>
<spanclass="key">message</span>: <spanclass="string"><spanclass="content">Something just happened, better take a look!</span></span>
</pre></div>
</div>
</div>
<p>If you want to specify multiple services to be called, or to include a delay, have a look at the <ahref="/components/script/">script component</a>. If you want to describe the desired state of certain entities, check out the <ahref="/components/scene/">scene component</a>.</p>
<p>You can verify that your automation rules are being initialized correctly by watching both the realtime logs (<code>homeassistant.log</code> in the configuration directory) and also the <ahref="/components/logbook/">Logbook</a>. The realtime logs will show the rules being initialized (once for each trigger), example:</p>
<divclass="code"><pre>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
</pre></div>
</div>
</div>
<p>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.</p>
<p>Please see the <ahref="/getting-started/automation/">getting started section</a> for in-depth documentation on how to use the automation compnoent.</p>
<li><strong>default_channel</strong> (<em>Required</em>): The default channel to post to if no channel is explicitly specified when sending the notification message.</li>
</ul>
<p>To use notifications, please see the <ahref="/components/automation/">getting started with automation page</a>.</p>
<p>To use notifications, please see the <ahref="/getting-started/automation/">getting started with automation page</a>.</p>
<p>For Google Mail (smtp.gmail.com) an additional step in the setup process is needed. Google has some extra layers of protection<br/>
which need special attention. By default, the usage by external applications, especially scripts, is limited. Visit the <ahref="https://www.google.com/settings/security/lesssecureapps">Less secure apps</a> page and enable it.</p>
<p>To use notifications, please see the <ahref="/components/automation/">getting started with automation page</a>.</p>
<p>To use notifications, please see the <ahref="/getting-started/automation/">getting started with automation page</a>.</p>
<p>For details about facility, option, and priority please consult the <ahref="http://en.wikipedia.org/wiki/Syslog">wikpedia article</a> and <ahref="http://tools.ietf.org/html/rfc3164">RFC 3164</a>.</p>
<p>To use notifications, please see the <ahref="/components/automation/">getting started with automation page</a>.</p>
<p>To use notifications, please see the <ahref="/getting-started/automation/">getting started with automation page</a>.</p>
<p>The notification component supports specifying <ahref="/topics/templating/">templates</a> for both the <code>message</code> and the <code>title</code>. This will allow you to use the current state of Home Assistant in your notifications.</p>
<p>In an <ahref="https://home-assistant.io/components/automation/#actions">action</a> of your <ahref="/components/automation/">automation setup</a> it could look like this with a customized subject.</p>
<p>In an <ahref="https://home-assistant.io/getting-started/automation-action/">action</a> of your <ahref="/getting-started/automation/">automation setup</a> it could look like this with a customized subject.</p>
<p>The <code>proximity</code> component allows you to monitor the proximity of devices to a particular <ahref="/components/zone/">zone</a> and the direction of travel. The result is an entity created in Home Assistant which maintains the proximity data.</p>
<p>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 <ahref="/components/automation/#zone-trigger">zone</a> and <ahref="/components/automation/#state-trigger">state</a> 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.</p>
<p>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 <ahref="/getting-started/automation-trigger/#zone-trigger">zone</a> and <ahref="/getting-started/automation-trigger/#state-trigger">state</a> 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.</p>
<p>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 <ahref="/components/automation/#sun-trigger">a trigger with an optional offset to simulate dawn/dusk</a>.</p>
<p>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 <ahref="/getting-started/automation-trigger/#sun-trigger">a trigger with an optional offset to simulate dawn/dusk</a>.</p>
<p>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 <ahref="/components/automation/#zone-trigger">trigger</a> or <ahref="/components/automation/#zone-condition">condition</a> inside automation setups.</p>
<p>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 <ahref="/getting-started/automation-trigger/#zone-trigger">trigger</a> or <ahref="/getting-started/automation-condition/#zone-condition">condition</a> inside automation setups.</p>
<p>Zones support the usual method to specify multiple zones, use keys <code>zone:</code>, <code>zone 2:</code> etc.</p>