Site updated at 2016-05-07 20:05:09 UTC

This commit is contained in:
Travis CI 2016-05-07 20:05:09 +00:00
parent 734e3c6515
commit 890a79eba3
300 changed files with 7312 additions and 1175 deletions

View file

@ -91,20 +91,6 @@
<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>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre><span class="key">automation</span>:
<span class="key">condition_type</span>: <span class="string"><span class="content">or</span></span>
<span class="key">condition</span>:
- <span class="string"><span class="content">platform: time</span></span>
<span class="key">before</span>: <span class="string"><span class="content">'05:00'</span></span>
- <span class="string"><span class="content">platform: time</span></span>
<span class="key">after</span>: <span class="string"><span class="content">'20:00'</span></span>
</pre></div>
</div>
</div>
<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>
<div class="highlighter-coderay"><div class="CodeRay">
@ -114,106 +100,8 @@
</div>
</div>
<h4><a class="title-link" name="numeric-state-condition" href="#numeric-state-condition"></a> Numeric state condition</h4>
<p>The available conditions for an automation are the same as for the script syntax. So see that page for a <a href="/getting-started/scripts-conditions/">full list of available conditions</a>.</p>
<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 &gt;= <code>before</code> *and** &lt; <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>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre><span class="key">automation</span>:
<span class="key">condition</span>:
<span class="key">platform</span>: <span class="string"><span class="content">numeric_state</span></span>
<span class="key">entity_id</span>: <span class="string"><span class="content">sensor.temperature</span></span>
<span class="key">above</span>: <span class="string"><span class="content">17</span></span>
<span class="key">below</span>: <span class="string"><span class="content">25</span></span>
</pre></div>
</div>
</div>
<h4><a class="title-link" name="state-condition" href="#state-condition"></a> State condition</h4>
<p>Tests if an entity is a specified state.</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre><span class="key">automation</span>:
<span class="key">condition</span>:
<span class="key">platform</span>: <span class="string"><span class="content">state</span></span>
<span class="key">entity_id</span>: <span class="string"><span class="content">device_tracker.paulus</span></span>
<span class="key">state</span>: <span class="string"><span class="content">not_home</span></span>
<span class="comment"># optional: trigger only if state was this for last X time.</span>
<span class="key">for</span>:
<span class="key">hours</span>: <span class="string"><span class="content">1</span></span>
<span class="key">minutes</span>: <span class="string"><span class="content">10</span></span>
<span class="key">seconds</span>: <span class="string"><span class="content">5</span></span>
</pre></div>
</div>
</div>
<h4><a class="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 <a href="#sun-trigger">sun trigger</a>.</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre><span class="key">automation</span>:
<span class="key">condition</span>:
<span class="key">platform</span>: <span class="string"><span class="content">sun</span></span>
<span class="key">after</span>: <span class="string"><span class="content">sunset</span></span>
<span class="comment"># Optional offset value</span>
<span class="key">after_offset</span>: <span class="string"><span class="delimiter">&quot;</span><span class="content">-1:00:00</span><span class="delimiter">&quot;</span></span>
</pre></div>
</div>
</div>
<h4><a class="title-link" name="template-condition" href="#template-condition"></a> Template condition</h4>
<p>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.</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre><span class="key">automation</span>:
<span class="key">condition</span>:
<span class="key">platform</span>: <span class="string"><span class="content">template</span></span>
<span class="key">value_template</span>: <span class="string"><span class="content">'{{ state.attributes.battery &gt; 50 }}'</span></span>
<span class="comment"># Or value_template could be:</span>
<span class="comment"># {% if state.attributes.battery &gt; 50 %}true{% else %}false{% endif %}</span>
</pre></div>
</div>
</div>
<h4><a class="title-link" name="time-condition" href="#time-condition"></a> Time condition</h4>
<p>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</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre><span class="key">automation</span>:
<span class="key">condition</span>:
<span class="key">platform</span>: <span class="string"><span class="content">time</span></span>
<span class="comment"># At least one of the following is required.</span>
<span class="key">after</span>: <span class="string"><span class="content">'15:00:00'</span></span>
<span class="key">before</span>: <span class="string"><span class="content">'23:00:00'</span></span>
<span class="key">weekday</span>:
- <span class="string"><span class="content">mon</span></span>
- <span class="string"><span class="content">wed</span></span>
- <span class="string"><span class="content">fri</span></span>
</pre></div>
</div>
</div>
<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> &amp; <code>sat</code>)</p>
<h4><a class="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 <a href="/components/device_tracker.owntracks/">OwnTracks platform</a> and the <a href="/components/device_tracker.icloud/">iCloud platform</a>.</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre><span class="key">automation</span>:
<span class="key">condition</span>:
<span class="key">platform</span>: <span class="string"><span class="content">zone</span></span>
<span class="key">entity_id</span>: <span class="string"><span class="content">device_tracker.paulus</span></span>
<span class="key">zone</span>: <span class="string"><span class="content">zone.home</span></span>
</pre></div>
</div>
</div>
</article>
@ -248,7 +136,7 @@ You can optionally use a <code>value_template</code> to make the value of the en
<li><a href='/getting-started/devices/'>Setting up devices </a></li>
<li><a href='/getting-started/customizing-devices/'>Customizing devices and services </a></li>
<li><a href='/getting-started/presence-detection/'>Presence Detection </a></li>
<li><a href='/getting-started/troubleshooting-configuration/'>Troubleshooting configuration.yaml </a></li>
<li><a href='/getting-started/troubleshooting-configuration/'>Troubleshooting </a></li>
</ul>
</li>
<li>
@ -258,6 +146,14 @@ You can optionally use a <code>value_template</code> to make the value of the en
<li><a href='/getting-started/automation-trigger/'>Triggers </a></li>
<li><a class='active' href='/getting-started/automation-condition/'>Conditions </a></li>
<li><a href='/getting-started/automation-action/'>Actions </a></li>
<li><a href='/getting-started/automation-templating/'>Templates </a></li>
</ul>
</li>
<li>
<a href='/getting-started/scripts/'>Scripts </a>
<ul>
<li><a href='/getting-started/scripts-service-calls/'>Service Calls </a></li>
<li><a href='/getting-started/scripts-conditions/'>Conditions </a></li>
</ul>
</li>
<li>