Site updated at 2016-08-22 08:21:42 UTC
This commit is contained in:
parent
f9d65cbe57
commit
4acb07bf8e
559 changed files with 18878 additions and 21688 deletions
|
@ -91,18 +91,18 @@
|
|||
<hr class="divider">
|
||||
|
||||
|
||||
<p>The core of Home Assistant is the event bus. The event bus allows any component to fire or listen for events. It is the core of everything. For example, any state change will be announced on the event bus as a <code>state_changed</code> event containing the previous and the new state of an entity.</p>
|
||||
<p>The core of Home Assistant is the event bus. The event bus allows any component to fire or listen for events. It is the core of everything. For example, any state change will be announced on the event bus as a <code class="highlighter-rouge">state_changed</code> event containing the previous and the new state of an entity.</p>
|
||||
|
||||
<p>Home Assistant contains a few built-in events that are used to coordinate between various components.</p>
|
||||
|
||||
<h3><a class="title-link" name="event-homeassistant_start" href="#event-homeassistant_start"></a> Event <code>homeassistant_start</code></h3>
|
||||
<p>Event <code>homeassistant_start</code> is fired when all components from the configuration have been intitialized. This is the event that will start the timer firing off <code>time_changed</code> events.</p>
|
||||
<h3><a class="title-link" name="event-homeassistant_start" href="#event-homeassistant_start"></a> Event <code class="highlighter-rouge">homeassistant_start</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">homeassistant_start</code> is fired when all components from the configuration have been intitialized. This is the event that will start the timer firing off <code class="highlighter-rouge">time_changed</code> events.</p>
|
||||
|
||||
<h3><a class="title-link" name="event-homeassistant_stop" href="#event-homeassistant_stop"></a> Event <code>homeassistant_stop</code></h3>
|
||||
<p>Event <code>homeassistant_stop</code> is fired when Home Assistant is shutting down. It should be used to close any open connection or release any resources.</p>
|
||||
<h3><a class="title-link" name="event-homeassistant_stop" href="#event-homeassistant_stop"></a> Event <code class="highlighter-rouge">homeassistant_stop</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">homeassistant_stop</code> is fired when Home Assistant is shutting down. It should be used to close any open connection or release any resources.</p>
|
||||
|
||||
<h3><a class="title-link" name="event-state_changed" href="#event-state_changed"></a> Event <code>state_changed</code></h3>
|
||||
<p>Event <code>state_changed</code> is fired when a state changes. Both <code>old_state</code> and <code>new_state</code> are state objects. <a href="/topics/state_object/">Documentation about state objects.</a></p>
|
||||
<h3><a class="title-link" name="event-state_changed" href="#event-state_changed"></a> Event <code class="highlighter-rouge">state_changed</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">state_changed</code> is fired when a state changes. Both <code class="highlighter-rouge">old_state</code> and <code class="highlighter-rouge">new_state</code> are state objects. <a href="/topics/state_object/">Documentation about state objects.</a></p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -113,22 +113,22 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>entity_id</code></td>
|
||||
<td>Entity ID of the changed entity. Example: <code>light.kitchen</code></td>
|
||||
<td><code class="highlighter-rouge">entity_id</code></td>
|
||||
<td>Entity ID of the changed entity. Example: <code class="highlighter-rouge">light.kitchen</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>old_state</code></td>
|
||||
<td><code class="highlighter-rouge">old_state</code></td>
|
||||
<td>The previous state of the entity before it changed. This field is ommitted if the entity is new.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>new_state</code></td>
|
||||
<td><code class="highlighter-rouge">new_state</code></td>
|
||||
<td>The new state of the entity. This field is ommitted if the entity is removed from the state machine.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3><a class="title-link" name="event-time_changed" href="#event-time_changed"></a> Event <code>time_changed</code></h3>
|
||||
<p>Event <code>time_changed</code> is fired every second by the timer and contains the current time.</p>
|
||||
<h3><a class="title-link" name="event-time_changed" href="#event-time_changed"></a> Event <code class="highlighter-rouge">time_changed</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">time_changed</code> is fired every second by the timer and contains the current time.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -139,14 +139,14 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>now</code></td>
|
||||
<td><code class="highlighter-rouge">now</code></td>
|
||||
<td>A <a href="https://docs.python.org/3.4/library/datetime.html#datetime.datetime">datetime object</a> containing the current time in UTC.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3><a class="title-link" name="event-service_registered" href="#event-service_registered"></a> Event <code>service_registered</code></h3>
|
||||
<p>Event <code>service_registered</code> is fired when a new service has been registered within Home Assistant.</p>
|
||||
<h3><a class="title-link" name="event-service_registered" href="#event-service_registered"></a> Event <code class="highlighter-rouge">service_registered</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">service_registered</code> is fired when a new service has been registered within Home Assistant.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -157,18 +157,18 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>domain</code></td>
|
||||
<td>Domain of the service. Example: <code>light</code>.</td>
|
||||
<td><code class="highlighter-rouge">domain</code></td>
|
||||
<td>Domain of the service. Example: <code class="highlighter-rouge">light</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>service</code></td>
|
||||
<td>The service to call. Example: <code>turn_on</code></td>
|
||||
<td><code class="highlighter-rouge">service</code></td>
|
||||
<td>The service to call. Example: <code class="highlighter-rouge">turn_on</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3><a class="title-link" name="event-call_service" href="#event-call_service"></a> Event <code>call_service</code></h3>
|
||||
<p>Event <code>call_service</code> is fired to call a service.</p>
|
||||
<h3><a class="title-link" name="event-call_service" href="#event-call_service"></a> Event <code class="highlighter-rouge">call_service</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">call_service</code> is fired to call a service.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -179,26 +179,26 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>domain</code></td>
|
||||
<td>Domain of the service. Example: <code>light</code>.</td>
|
||||
<td><code class="highlighter-rouge">domain</code></td>
|
||||
<td>Domain of the service. Example: <code class="highlighter-rouge">light</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>service</code></td>
|
||||
<td>The service to call. Example: <code>turn_on</code></td>
|
||||
<td><code class="highlighter-rouge">service</code></td>
|
||||
<td>The service to call. Example: <code class="highlighter-rouge">turn_on</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>service_data</code></td>
|
||||
<td>Dictionary with the service call parameters. Example: <code>{ 'brightness': 120 }</code>.</td>
|
||||
<td><code class="highlighter-rouge">service_data</code></td>
|
||||
<td>Dictionary with the service call parameters. Example: <code class="highlighter-rouge"><span class="p">{</span><span class="w"> </span><span class="err">'brightness':</span><span class="w"> </span><span class="err">120</span><span class="w"> </span><span class="p">}</span></code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>service_call_id</code></td>
|
||||
<td>String with a unique call id. Example: <code>23123-4</code>.</td>
|
||||
<td><code class="highlighter-rouge">service_call_id</code></td>
|
||||
<td>String with a unique call id. Example: <code class="highlighter-rouge">23123-4</code>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3><a class="title-link" name="event-service_executed" href="#event-service_executed"></a> Event <code>service_executed</code></h3>
|
||||
<p>Event <code>service_executed</code> is fired by the service handler to indicate the service is done.</p>
|
||||
<h3><a class="title-link" name="event-service_executed" href="#event-service_executed"></a> Event <code class="highlighter-rouge">service_executed</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">service_executed</code> is fired by the service handler to indicate the service is done.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -209,14 +209,14 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>service_call_id</code></td>
|
||||
<td>String with the unique call id of the service call that was executed. Example: <code>23123-4</code>.</td>
|
||||
<td><code class="highlighter-rouge">service_call_id</code></td>
|
||||
<td>String with the unique call id of the service call that was executed. Example: <code class="highlighter-rouge">23123-4</code>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3><a class="title-link" name="event-platform_discovered" href="#event-platform_discovered"></a> Event <code>platform_discovered</code></h3>
|
||||
<p>Event <code>platform_discovered</code> is fired when a new platform has been discovered by the discovery component.</p>
|
||||
<h3><a class="title-link" name="event-platform_discovered" href="#event-platform_discovered"></a> Event <code class="highlighter-rouge">platform_discovered</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">platform_discovered</code> is fired when a new platform has been discovered by the discovery component.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -227,18 +227,18 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>service</code></td>
|
||||
<td>The service that is discovered. Example: <code>zwave</code>.</td>
|
||||
<td><code class="highlighter-rouge">service</code></td>
|
||||
<td>The service that is discovered. Example: <code class="highlighter-rouge">zwave</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>discovered</code></td>
|
||||
<td>Information that is discovered. Can be a dict, tuple etc. Example: <code>(192.168.1.10, 8889)</code>.</td>
|
||||
<td><code class="highlighter-rouge">discovered</code></td>
|
||||
<td>Information that is discovered. Can be a dict, tuple etc. Example: <code class="highlighter-rouge">(192.168.1.10, 8889)</code>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h3><a class="title-link" name="event-component_loaded" href="#event-component_loaded"></a> Event <code>component_loaded</code></h3>
|
||||
<p>Event <code>component_loaded</code> is fired when a new component has been loaded and initialized.</p>
|
||||
<h3><a class="title-link" name="event-component_loaded" href="#event-component_loaded"></a> Event <code class="highlighter-rouge">component_loaded</code></h3>
|
||||
<p>Event <code class="highlighter-rouge">component_loaded</code> is fired when a new component has been loaded and initialized.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -249,8 +249,8 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>component</code></td>
|
||||
<td>Domain of the component that has just been initialized. Example: <code>light</code>.</td>
|
||||
<td><code class="highlighter-rouge">component</code></td>
|
||||
<td>Domain of the component that has just been initialized. Example: <code class="highlighter-rouge">light</code>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -95,28 +95,24 @@
|
|||
|
||||
<h3><a class="title-link" name="entity-namespace" href="#entity-namespace"></a> Entity namespace</h3>
|
||||
|
||||
<p>By setting an entity namespace, all entities will be prefixed with that namespace. That way <code>light.bathroom</code> can become <code>light.holiday_house_bathroom</code>.</p>
|
||||
<p>By setting an entity namespace, all entities will be prefixed with that namespace. That way <code class="highlighter-rouge">light.bathroom</code> can become <code class="highlighter-rouge">light.holiday_house_bathroom</code>.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment"># Example configuration.yaml entry</span>
|
||||
<span class="key">light</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">hue</span></span>
|
||||
<span class="key">entity_namespace</span>: <span class="string"><span class="content">holiday_house</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry</span>
|
||||
<span class="s">light</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">hue</span>
|
||||
<span class="s">entity_namespace</span><span class="pi">:</span> <span class="s">holiday_house</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="scan-interval" href="#scan-interval"></a> Scan Interval</h3>
|
||||
|
||||
<p>Platforms that require polling will be polled in an interval specified by the main component. For example a light will check every 30 seconds for a changed state. It is possible to overwrite this scan interval for any platform that is being polled by specifying a <code>scan_interval</code> config key. In the example below we setup the Philips Hue lights but tell Home Assistant to poll the devices every 10 seconds instead of the default 30 seconds.</p>
|
||||
<p>Platforms that require polling will be polled in an interval specified by the main component. For example a light will check every 30 seconds for a changed state. It is possible to overwrite this scan interval for any platform that is being polled by specifying a <code class="highlighter-rouge">scan_interval</code> config key. In the example below we setup the Philips Hue lights but tell Home Assistant to poll the devices every 10 seconds instead of the default 30 seconds.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment"># Example configuration.yaml entry to poll Hue lights every 10 seconds.</span>
|
||||
<span class="key">light</span>:
|
||||
<span class="key">platform</span>: <span class="string"><span class="content">hue</span></span>
|
||||
<span class="key">scan_interval</span>: <span class="string"><span class="content">10</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry to poll Hue lights every 10 seconds.</span>
|
||||
<span class="s">light</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">hue</span>
|
||||
<span class="s">scan_interval</span><span class="pi">:</span> <span class="s">10</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -187,7 +183,7 @@
|
|||
|
||||
|
||||
<li class="post">
|
||||
<a href="/blog/2016/08/13/foursquare-fast-com-ffmpeg-gpsd/">0.26: Foursquare, Fast.com, FFMPEG and GPSD</a>
|
||||
<a href="/blog/2016/08/13/foursquare-fast.com-ffmpeg-gpsd/">0.26: Foursquare, Fast.com, FFMPEG and GPSD</a>
|
||||
</li>
|
||||
|
||||
|
||||
|
|
|
@ -91,74 +91,60 @@
|
|||
<hr class="divider">
|
||||
|
||||
|
||||
<p>The <code>configuration.yaml</code> file a plain-text file thus it is readable for everyone who has access to the file. The file contains passwords and API tokens which need to be redacted if you want to share your configuration. This separation can also help you to keep easier track of your passwords and API keys (as they are all stored at one place and no longer spread across the <code>configuration.yaml</code> file) if you don’t want to <a href="/topics/splitting_configuration/">split up your configuration</a>.</p>
|
||||
<p>The <code class="highlighter-rouge">configuration.yaml</code> file a plain-text file thus it is readable for everyone who has access to the file. The file contains passwords and API tokens which need to be redacted if you want to share your configuration. This separation can also help you to keep easier track of your passwords and API keys (as they are all stored at one place and no longer spread across the <code class="highlighter-rouge">configuration.yaml</code> file) if you don’t want to <a href="/topics/splitting_configuration/">split up your configuration</a>.</p>
|
||||
|
||||
<h3><a class="title-link" name="using-secretsyaml" href="#using-secretsyaml"></a> Using secrets.yaml</h3>
|
||||
|
||||
<p>The workflow for the outsourcing in the <code>secrets.yaml</code> is very similar to the <a href="/topics/splitting_configuration/">splitting of the configuration</a>. Create a <code>secrets.yaml</code> file in your Home assistant configuration directory (The location of the folder differs between operating systems: on OS X and Linux it’s <code>~/.homeassistant</code> and on Windows it’s <code>%APPDATA%/.homeassistant</code>).</p>
|
||||
<p>The workflow for the outsourcing in the <code class="highlighter-rouge">secrets.yaml</code> is very similar to the <a href="/topics/splitting_configuration/">splitting of the configuration</a>. Create a <code class="highlighter-rouge">secrets.yaml</code> file in your Home assistant configuration directory (The location of the folder differs between operating systems: on OS X and Linux it’s <code class="highlighter-rouge">~/.homeassistant</code> and on Windows it’s <code class="highlighter-rouge">%APPDATA%/.homeassistant</code>).</p>
|
||||
|
||||
<p>The entries for password and API keys in the <code>configuration.yaml</code> file usually looks like the example below.</p>
|
||||
<p>The entries for password and API keys in the <code class="highlighter-rouge">configuration.yaml</code> file usually looks like the example below.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">http</span>:
|
||||
<span class="key">api_password</span>: <span class="string"><span class="content">YOUR_PASSWORD</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">http</span><span class="pi">:</span>
|
||||
<span class="s">api_password</span><span class="pi">:</span> <span class="s">YOUR_PASSWORD</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>Those entries need to be replaced with <code>!secret</code> and a identifier.</p>
|
||||
<p>Those entries need to be replaced with <code class="highlighter-rouge">!secret</code> and a identifier.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">http</span>:
|
||||
<span class="key">api_password</span>: <span class="type">!secret</span> <span class="string"><span class="content">http_password</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">http</span><span class="pi">:</span>
|
||||
<span class="s">api_password</span><span class="pi">:</span> <span class="kt">!secret</span> <span class="s">http_password</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>The <code>secrets.yaml</code> file contains the corresponding password assigned to the identifier.</p>
|
||||
<p>The <code class="highlighter-rouge">secrets.yaml</code> file contains the corresponding password assigned to the identifier.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">logger</span>: <span class="string"><span class="content">debug</span></span>
|
||||
<span class="key">http_password</span>: <span class="string"><span class="content">YOUR_PASSWORD</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">logger</span><span class="pi">:</span> <span class="s">debug</span>
|
||||
<span class="s">http_password</span><span class="pi">:</span> <span class="s">YOUR_PASSWORD</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="storing-passwords-in-a-keyring-managed-by-your-os" href="#storing-passwords-in-a-keyring-managed-by-your-os"></a> Storing passwords in a keyring managed by your OS</h3>
|
||||
|
||||
<p>Using <a href="http://pythonhosted.org/keyring/">Keyring</a> is an alternative way to <code>secrets.yaml</code>. They can be managed from the command line via the keyring script.</p>
|
||||
<p>Using <a href="http://pythonhosted.org/keyring/">Keyring</a> is an alternative way to <code class="highlighter-rouge">secrets.yaml</code>. They can be managed from the command line via the keyring script.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>$ hass --script keyring --help
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>hass --script keyring --help
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>To store a password in keyring, replace your password or API key with <code>!secret</code> and an identifier in <code>configuration.yaml</code> file.</p>
|
||||
<p>To store a password in keyring, replace your password or API key with <code class="highlighter-rouge">!secret</code> and an identifier in <code class="highlighter-rouge">configuration.yaml</code> file.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">http</span>:
|
||||
<span class="key">api_password</span>: <span class="type">!secret</span> <span class="string"><span class="content">http_password</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">http</span><span class="pi">:</span>
|
||||
<span class="s">api_password</span><span class="pi">:</span> <span class="kt">!secret</span> <span class="s">http_password</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>Create an entry in your keyring.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>$ hass --script keyring set http_password
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>hass --script keyring <span class="nb">set </span>http_password
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>If you launch home Assistant now, you will be prompted for the keyring password to unlock your keyring.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>$ hass
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>hass
|
||||
Config directory: /home/fab/.homeassistant
|
||||
Please enter password for encrypted keyring:
|
||||
</pre></div>
|
||||
</div>
|
||||
Please enter password <span class="k">for </span>encrypted keyring:
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p class="note warning">
|
||||
|
|
|
@ -97,477 +97,435 @@
|
|||
|
||||
<p>As commenting code doesn’t always happen, please read on for the details.</p>
|
||||
|
||||
<p>Now despite the logical assumption that the <code>configuration.yaml</code> will be replaced by this process it will in fact remain all be it in a much less cluttered form.</p>
|
||||
<p>Now despite the logical assumption that the <code class="highlighter-rouge">configuration.yaml</code> will be replaced by this process it will in fact remain all be it in a much less cluttered form.</p>
|
||||
|
||||
<p>In this lighter version we will still need what could be called the core snippet:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">homeassistant</span>:
|
||||
<span class="comment"># Name of the location where Home Assistant is running</span>
|
||||
<span class="key">name</span>: <span class="string"><span class="content">My Home Assistant Instance</span></span>
|
||||
<span class="comment"># Location required to calculate the time the sun rises and sets</span>
|
||||
<span class="key">latitude</span>: <span class="string"><span class="content">37</span></span>
|
||||
<span class="key">longitude</span>: <span class="string"><span class="content">-121</span></span>
|
||||
<span class="comment"># 'metric' for Metric, 'imperial' for Imperial</span>
|
||||
<span class="key">unit_system</span>: <span class="string"><span class="content">imperial</span></span>
|
||||
<span class="comment"># Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones</span>
|
||||
<span class="key">time_zone</span>: <span class="string"><span class="content">America/Los_Angeles</span></span>
|
||||
<span class="key">customize</span>: <span class="type">!include</span> <span class="string"><span class="content">customize.yaml</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">homeassistant</span><span class="pi">:</span>
|
||||
<span class="c1"># Name of the location where Home Assistant is running</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s">My Home Assistant Instance</span>
|
||||
<span class="c1"># Location required to calculate the time the sun rises and sets</span>
|
||||
<span class="s">latitude</span><span class="pi">:</span> <span class="s">37</span>
|
||||
<span class="s">longitude</span><span class="pi">:</span> <span class="s">-121</span>
|
||||
<span class="c1"># 'metric' for Metric, 'imperial' for Imperial</span>
|
||||
<span class="s">unit_system</span><span class="pi">:</span> <span class="s">imperial</span>
|
||||
<span class="c1"># Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones</span>
|
||||
<span class="s">time_zone</span><span class="pi">:</span> <span class="s">America/Los_Angeles</span>
|
||||
<span class="s">customize</span><span class="pi">:</span> <span class="kt">!include</span> <span class="s">customize.yaml</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>Note that each line after <code>homeassistant:</code> is indented two (2) spaces. Since the configuration files in Home Assistant are based on the YAML language, indentation and spacing are important. Also note that seemingly strange entry under <code>customize:</code>.</p>
|
||||
<p>Note that each line after <code class="highlighter-rouge">homeassistant:</code> is indented two (2) spaces. Since the configuration files in Home Assistant are based on the YAML language, indentation and spacing are important. Also note that seemingly strange entry under <code class="highlighter-rouge">customize:</code>.</p>
|
||||
|
||||
<p><code>!include filename.yaml</code> is the statement that tells Home Assistant to insert the contents of <code>filename.yaml</code> at that point. This is how we are going to break a monolithic and hard to read file (when it gets big) into more manageable chunks.</p>
|
||||
<p><code class="highlighter-rouge">!include filename.yaml</code> is the statement that tells Home Assistant to insert the contents of <code class="highlighter-rouge">filename.yaml</code> at that point. This is how we are going to break a monolithic and hard to read file (when it gets big) into more manageable chunks.</p>
|
||||
|
||||
<p>Now before we start splitting out the different components, let’s look at the other components (in our example) that will stay in the base file:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">history</span>:
|
||||
<span class="key">frontend</span>:
|
||||
<span class="key">logbook</span>:
|
||||
<span class="key">http</span>:
|
||||
<span class="key">api_password</span>: <span class="string"><span class="content">ImNotTelling!</span></span>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">history</span><span class="pi">:</span>
|
||||
<span class="s">frontend</span><span class="pi">:</span>
|
||||
<span class="s">logbook</span><span class="pi">:</span>
|
||||
<span class="s">http</span><span class="pi">:</span>
|
||||
<span class="s">api_password</span><span class="pi">:</span> <span class="s">ImNotTelling!</span>
|
||||
|
||||
<span class="key">ifttt</span>:
|
||||
<span class="key">key</span>: <span class="string"><span class="content">[nope]</span></span>
|
||||
<span class="s">ifttt</span><span class="pi">:</span>
|
||||
<span class="s">key</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">nope</span><span class="pi">]</span>
|
||||
|
||||
<span class="key">wink</span>:
|
||||
<span class="key">access_token</span>: <span class="string"><span class="content">[wouldn't you]</span></span>
|
||||
<span class="key">refresh_token</span>: <span class="string"><span class="content">[like to know]</span></span>
|
||||
<span class="s">wink</span><span class="pi">:</span>
|
||||
<span class="s">access_token</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">wouldn't you</span><span class="pi">]</span>
|
||||
<span class="s">refresh_token</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">like to know</span><span class="pi">]</span>
|
||||
|
||||
<span class="key">zwave</span>:
|
||||
<span class="key">usb_path</span>: <span class="string"><span class="content">/dev/ttyUSB0</span></span>
|
||||
<span class="key">config_path</span>: <span class="string"><span class="content">/usr/local/share/python-openzwave/config</span></span>
|
||||
<span class="key">polling_interval</span>: <span class="string"><span class="content">10000</span></span>
|
||||
<span class="s">zwave</span><span class="pi">:</span>
|
||||
<span class="s">usb_path</span><span class="pi">:</span> <span class="s">/dev/ttyUSB0</span>
|
||||
<span class="s">config_path</span><span class="pi">:</span> <span class="s">/usr/local/share/python-openzwave/config</span>
|
||||
<span class="s">polling_interval</span><span class="pi">:</span> <span class="s">10000</span>
|
||||
|
||||
<span class="comment">#zigbee:</span>
|
||||
<span class="comment"># device: /dev/ttyUSB1</span>
|
||||
<span class="comment"># baud: 115200</span>
|
||||
<span class="c1">#zigbee:</span>
|
||||
<span class="c1"># device: /dev/ttyUSB1</span>
|
||||
<span class="c1"># baud: 115200</span>
|
||||
|
||||
<span class="key">mqtt</span>:
|
||||
<span class="key">broker</span>: <span class="string"><span class="content">127.0.0.1</span></span>
|
||||
</pre></div>
|
||||
<span class="s">mqtt</span><span class="pi">:</span>
|
||||
<span class="s">broker</span><span class="pi">:</span> <span class="s">127.0.0.1</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
<p>As with the core snippet, indentation makes a difference. The component headers (<code>mqtt:</code>) should be fully left aligned (aka no indent), and the parameters (<code>port:</code>) should be indented two (2) spaces.</p>
|
||||
<p>As with the core snippet, indentation makes a difference. The component headers (<code class="highlighter-rouge">mqtt:</code>) should be fully left aligned (aka no indent), and the parameters (<code class="highlighter-rouge">port:</code>) should be indented two (2) spaces.</p>
|
||||
|
||||
<p>While some of these components can technically be moved to a separate file they are so small or “one off’s” where splitting them off is superfluous. Also, you’ll notice the # symbol (hash/pound). This represents a “comment” as far as the commands are interpreted. Put another way, any line prefixed with a <code>#</code> will be ignored. This makes breaking up files for human readability really convenient, not to mention turning off features while leaving the entry intact. (Look at the <code>zigbee:</code> entry above and the b entry further down)</p>
|
||||
<p>While some of these components can technically be moved to a separate file they are so small or “one off’s” where splitting them off is superfluous. Also, you’ll notice the # symbol (hash/pound). This represents a “comment” as far as the commands are interpreted. Put another way, any line prefixed with a <code class="highlighter-rouge">#</code> will be ignored. This makes breaking up files for human readability really convenient, not to mention turning off features while leaving the entry intact. (Look at the <code class="highlighter-rouge">zigbee:</code> entry above and the b entry further down)</p>
|
||||
|
||||
<p>Now, lets assume that a blank file has been created in the Home Assistant configuration directory for each of the following:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>automation.yaml
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code>automation.yaml
|
||||
zones.yaml
|
||||
sensors.yaml
|
||||
switches.yaml
|
||||
device_tracker.yaml
|
||||
customize.yaml
|
||||
</pre></div>
|
||||
</div>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><code>automation.yaml</code> will hold all the automation component details. <code>zones.yaml</code> will hold the zone component details and so forth. These files can be called anything but giving them names that match their function will make things easier to keep track of.</p>
|
||||
<p><code class="highlighter-rouge">automation.yaml</code> will hold all the automation component details. <code class="highlighter-rouge">zones.yaml</code> will hold the zone component details and so forth. These files can be called anything but giving them names that match their function will make things easier to keep track of.</p>
|
||||
|
||||
<p>Inside the base configuration file add the following entries:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">automation</span>: <span class="type">!include</span> <span class="string"><span class="content">automation.yaml</span></span>
|
||||
<span class="key">zone</span>: <span class="type">!include</span> <span class="string"><span class="content">zones.yaml</span></span>
|
||||
<span class="key">sensor</span>: <span class="type">!include</span> <span class="string"><span class="content">sensors.yaml</span></span>
|
||||
<span class="key">switch</span>: <span class="type">!include</span> <span class="string"><span class="content">switches.yaml</span></span>
|
||||
<span class="key">device_tracker</span>: <span class="type">!include</span> <span class="string"><span class="content">device_tracker.yaml</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">automation</span><span class="pi">:</span> <span class="kt">!include</span> <span class="s">automation.yaml</span>
|
||||
<span class="s">zone</span><span class="pi">:</span> <span class="kt">!include</span> <span class="s">zones.yaml</span>
|
||||
<span class="s">sensor</span><span class="pi">:</span> <span class="kt">!include</span> <span class="s">sensors.yaml</span>
|
||||
<span class="s">switch</span><span class="pi">:</span> <span class="kt">!include</span> <span class="s">switches.yaml</span>
|
||||
<span class="s">device_tracker</span><span class="pi">:</span> <span class="kt">!include</span> <span class="s">device_tracker.yaml</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>Note that there can only be one <code>!include:</code> for each component so chaining them isn’t going to work. If that sounds like greek, don’t worry about it.</p>
|
||||
<p>Note that there can only be one <code class="highlighter-rouge">!include:</code> for each component so chaining them isn’t going to work. If that sounds like greek, don’t worry about it.</p>
|
||||
|
||||
<p>Alright, so we’ve got the single components and the include statements in the base file, what goes in those extra files?</p>
|
||||
|
||||
<p>Let’s look at the <code>device_tracker.yaml</code> file from our example:</p>
|
||||
<p>Let’s look at the <code class="highlighter-rouge">device_tracker.yaml</code> file from our example:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>- <span class="string"><span class="content">platform: owntracks</span></span>
|
||||
- <span class="string"><span class="content">platform: nmap_tracker</span></span>
|
||||
<span class="key">hosts</span>: <span class="string"><span class="content">192.168.2.0/24</span></span>
|
||||
<span class="key">home_interval</span>: <span class="string"><span class="content">3</span></span>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">owntracks</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">nmap_tracker</span>
|
||||
<span class="s">hosts</span><span class="pi">:</span> <span class="s">192.168.2.0/24</span>
|
||||
<span class="s">home_interval</span><span class="pi">:</span> <span class="s">3</span>
|
||||
|
||||
<span class="key">track_new_devices</span>: <span class="string"><span class="content">yes</span></span>
|
||||
<span class="key">interval_seconds</span>: <span class="string"><span class="content">40</span></span>
|
||||
<span class="key">consider_home</span>: <span class="string"><span class="content">120</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<span class="s">track_new_devices</span><span class="pi">:</span> <span class="s">yes</span>
|
||||
<span class="s">interval_seconds</span><span class="pi">:</span> <span class="s">40</span>
|
||||
<span class="s">consider_home</span><span class="pi">:</span> <span class="s">120</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>This small example illustrates how the “split” files work. In this case, we start with a “comment block” identifying the file followed by two (2) device tracker entries (<code>owntracks</code> and <code>nmap</code>). These files follow <a href="/getting-started/devices/#style-2-list-each-device-separately">“style 1”</a> that is to say a fully left aligned leading entry (<code>- platform: owntracks</code>) followed by the parameter entries indented two (2) spaces.</p>
|
||||
<p>This small example illustrates how the “split” files work. In this case, we start with a “comment block” identifying the file followed by two (2) device tracker entries (<code class="highlighter-rouge">owntracks</code> and <code class="highlighter-rouge">nmap</code>). These files follow <a href="/getting-started/devices/#style-2-list-each-device-separately">“style 1”</a> that is to say a fully left aligned leading entry (<code class="highlighter-rouge">- platform: owntracks</code>) followed by the parameter entries indented two (2) spaces.</p>
|
||||
|
||||
<p>This (large) sensor configuration gives us another example:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="comment">### sensors.yaml</span>
|
||||
<span class="comment">##############################################################</span>
|
||||
<span class="comment">### METEOBRIDGE ####</span>
|
||||
<span class="comment">##############################################################</span>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1">### sensors.yaml</span>
|
||||
<span class="c1">##############################################################</span>
|
||||
<span class="c1">### METEOBRIDGE ####</span>
|
||||
<span class="c1">##############################################################</span>
|
||||
|
||||
- <span class="string"><span class="content">platform: tcp</span></span>
|
||||
<span class="key">name</span>: <span class="string"><span class="content">'Outdoor Temp (Meteobridge)'</span></span>
|
||||
<span class="key">host</span>: <span class="string"><span class="content">192.168.2.82</span></span>
|
||||
<span class="key">timeout</span>: <span class="string"><span class="content">6</span></span>
|
||||
<span class="key">payload</span>: <span class="string"><span class="delimiter">"</span><span class="content">Content-type: text/xml; charset=UTF-8\n\n</span><span class="delimiter">"</span></span>
|
||||
<span class="key">value_template</span>: <span class="string"><span class="delimiter">"</span><span class="delimiter">"</span></span>
|
||||
<span class="key">unit</span>: <span class="string"><span class="content">C</span></span>
|
||||
- <span class="string"><span class="content">platform: tcp</span></span>
|
||||
<span class="key">name</span>: <span class="string"><span class="content">'Outdoor Humidity (Meteobridge)'</span></span>
|
||||
<span class="key">host</span>: <span class="string"><span class="content">192.168.2.82</span></span>
|
||||
<span class="key">port</span>: <span class="string"><span class="content">5556</span></span>
|
||||
<span class="key">timeout</span>: <span class="string"><span class="content">6</span></span>
|
||||
<span class="key">payload</span>: <span class="string"><span class="delimiter">"</span><span class="content">Content-type: text/xml; charset=UTF-8\n\n</span><span class="delimiter">"</span></span>
|
||||
<span class="key">value_template</span>: <span class="string"><span class="delimiter">"</span><span class="delimiter">"</span></span>
|
||||
<span class="key">unit</span>: <span class="string"><span class="content">Percent</span></span>
|
||||
- <span class="string"><span class="content">platform: tcp</span></span>
|
||||
<span class="key">name</span>: <span class="string"><span class="content">'Outdoor Dewpoint (Meteobridge)'</span></span>
|
||||
<span class="key">host</span>: <span class="string"><span class="content">192.168.2.82</span></span>
|
||||
<span class="key">port</span>: <span class="string"><span class="content">5556</span></span>
|
||||
<span class="key">timeout</span>: <span class="string"><span class="content">6</span></span>
|
||||
<span class="key">payload</span>: <span class="string"><span class="delimiter">"</span><span class="content">Content-type: text/xml; charset=UTF-8\n\n</span><span class="delimiter">"</span></span>
|
||||
<span class="key">value_template</span>: <span class="string"><span class="delimiter">"</span><span class="delimiter">"</span></span>
|
||||
<span class="key">unit</span>: <span class="string"><span class="content">C</span></span>
|
||||
<span class="comment">###################################</span>
|
||||
<span class="comment">#### STEAM FRIENDS ####</span>
|
||||
<span class="comment">##################################</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">tcp</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s1">'</span><span class="s">Outdoor</span><span class="nv"> </span><span class="s">Temp</span><span class="nv"> </span><span class="s">(Meteobridge)'</span>
|
||||
<span class="s">host</span><span class="pi">:</span> <span class="s">192.168.2.82</span>
|
||||
<span class="s">timeout</span><span class="pi">:</span> <span class="s">6</span>
|
||||
<span class="s">payload</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Content-type:</span><span class="nv"> </span><span class="s">text/xml;</span><span class="nv"> </span><span class="s">charset=UTF-8</span><span class="se">\n\n</span><span class="s">"</span>
|
||||
<span class="s">value_template</span><span class="pi">:</span> <span class="s2">"</span><span class="s">{{value.split</span><span class="nv"> </span><span class="s">('</span><span class="nv"> </span><span class="s">')[2]}}"</span>
|
||||
<span class="s">unit</span><span class="pi">:</span> <span class="s">C</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">tcp</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s1">'</span><span class="s">Outdoor</span><span class="nv"> </span><span class="s">Humidity</span><span class="nv"> </span><span class="s">(Meteobridge)'</span>
|
||||
<span class="s">host</span><span class="pi">:</span> <span class="s">192.168.2.82</span>
|
||||
<span class="s">port</span><span class="pi">:</span> <span class="s">5556</span>
|
||||
<span class="s">timeout</span><span class="pi">:</span> <span class="s">6</span>
|
||||
<span class="s">payload</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Content-type:</span><span class="nv"> </span><span class="s">text/xml;</span><span class="nv"> </span><span class="s">charset=UTF-8</span><span class="se">\n\n</span><span class="s">"</span>
|
||||
<span class="s">value_template</span><span class="pi">:</span> <span class="s2">"</span><span class="s">{{value.split</span><span class="nv"> </span><span class="s">('</span><span class="nv"> </span><span class="s">')[3]}}"</span>
|
||||
<span class="s">unit</span><span class="pi">:</span> <span class="s">Percent</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">tcp</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s1">'</span><span class="s">Outdoor</span><span class="nv"> </span><span class="s">Dewpoint</span><span class="nv"> </span><span class="s">(Meteobridge)'</span>
|
||||
<span class="s">host</span><span class="pi">:</span> <span class="s">192.168.2.82</span>
|
||||
<span class="s">port</span><span class="pi">:</span> <span class="s">5556</span>
|
||||
<span class="s">timeout</span><span class="pi">:</span> <span class="s">6</span>
|
||||
<span class="s">payload</span><span class="pi">:</span> <span class="s2">"</span><span class="s">Content-type:</span><span class="nv"> </span><span class="s">text/xml;</span><span class="nv"> </span><span class="s">charset=UTF-8</span><span class="se">\n\n</span><span class="s">"</span>
|
||||
<span class="s">value_template</span><span class="pi">:</span> <span class="s2">"</span><span class="s">{{value.split</span><span class="nv"> </span><span class="s">('</span><span class="nv"> </span><span class="s">')[4]</span><span class="nv"> </span><span class="s">}}"</span>
|
||||
<span class="s">unit</span><span class="pi">:</span> <span class="s">C</span>
|
||||
<span class="c1">###################################</span>
|
||||
<span class="c1">#### STEAM FRIENDS ####</span>
|
||||
<span class="c1">##################################</span>
|
||||
|
||||
- <span class="string"><span class="content">platform: steam_online</span></span>
|
||||
<span class="key">api_key</span>: <span class="string"><span class="content">[not telling]</span></span>
|
||||
<span class="key">accounts</span>:
|
||||
- <span class="string"><span class="content">76561198012067051</span></span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">steam_online</span>
|
||||
<span class="s">api_key</span><span class="pi">:</span> <span class="pi">[</span><span class="nv">not telling</span><span class="pi">]</span>
|
||||
<span class="s">accounts</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">76561198012067051</span>
|
||||
|
||||
<span class="comment">##################################</span>
|
||||
<span class="comment">#### TIME/DATE ####</span>
|
||||
<span class="comment">##################################</span>
|
||||
<span class="c1">##################################</span>
|
||||
<span class="c1">#### TIME/DATE ####</span>
|
||||
<span class="c1">##################################</span>
|
||||
|
||||
- <span class="string"><span class="content">platform: time_date</span></span>
|
||||
<span class="key">display_options</span>:
|
||||
- <span class="string"><span class="content">'time'</span></span>
|
||||
- <span class="string"><span class="content">'date'</span></span>
|
||||
- <span class="string"><span class="content">platform: worldclock</span></span>
|
||||
<span class="key">time_zone</span>: <span class="string"><span class="content">Etc/UTC</span></span>
|
||||
<span class="key">name</span>: <span class="string"><span class="content">'UTC'</span></span>
|
||||
- <span class="string"><span class="content">platform: worldclock</span></span>
|
||||
<span class="key">time_zone</span>: <span class="string"><span class="content">America/New_York</span></span>
|
||||
<span class="key">name</span>: <span class="string"><span class="content">'Ann Arbor'</span></span>
|
||||
- <span class="string"><span class="content">platform: worldclock</span></span>
|
||||
<span class="key">time_zone</span>: <span class="string"><span class="content">Europe/Vienna</span></span>
|
||||
<span class="key">name</span>: <span class="string"><span class="content">'Innsbruck'</span></span>
|
||||
- <span class="string"><span class="content">platform: worldclock</span></span>
|
||||
<span class="key">time_zone</span>: <span class="string"><span class="content">America/New_York</span></span>
|
||||
<span class="key">name</span>: <span class="string"><span class="content">'Ann Arbor'</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">time_date</span>
|
||||
<span class="s">display_options</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s1">'</span><span class="s">time'</span>
|
||||
<span class="pi">-</span> <span class="s1">'</span><span class="s">date'</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">worldclock</span>
|
||||
<span class="s">time_zone</span><span class="pi">:</span> <span class="s">Etc/UTC</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s1">'</span><span class="s">UTC'</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">worldclock</span>
|
||||
<span class="s">time_zone</span><span class="pi">:</span> <span class="s">America/New_York</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s1">'</span><span class="s">Ann</span><span class="nv"> </span><span class="s">Arbor'</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">worldclock</span>
|
||||
<span class="s">time_zone</span><span class="pi">:</span> <span class="s">Europe/Vienna</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s1">'</span><span class="s">Innsbruck'</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">worldclock</span>
|
||||
<span class="s">time_zone</span><span class="pi">:</span> <span class="s">America/New_York</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s1">'</span><span class="s">Ann</span><span class="nv"> </span><span class="s">Arbor'</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>You’ll notice that this example includes a secondary parameter section (under the steam section) as well as a better example of the way comments can be used to break down files into sections.</p>
|
||||
|
||||
<p>That about wraps it up.</p>
|
||||
|
||||
<p>If you have issues checkout <code>home-assistant.log</code> in the configuration directory as well as your indentations. If all else fails, head over to the <a href="https://gitter.im/balloob/home-assistant">Gitter Chatroom</a> and ask away.</p>
|
||||
<p>If you have issues checkout <code class="highlighter-rouge">home-assistant.log</code> in the configuration directory as well as your indentations. If all else fails, head over to the <a href="https://gitter.im/balloob/home-assistant">Gitter Chatroom</a> and ask away.</p>
|
||||
|
||||
<h3><a class="title-link" name="advanced-usage" href="#advanced-usage"></a> Advanced Usage</h3>
|
||||
|
||||
<p>We offer four advanced options to include whole directories at once.</p>
|
||||
|
||||
<p><code>!include_dir_list</code> will return content of a directory as a list with each file content being an entry in the list.</p>
|
||||
<p><code class="highlighter-rouge">!include_dir_list</code> will return content of a directory as a list with each file content being an entry in the list.</p>
|
||||
|
||||
<p><code>!include_dir_named</code> will return content of a directory as a dictionary which maps filename => content of file.</p>
|
||||
<p><code class="highlighter-rouge">!include_dir_named</code> will return content of a directory as a dictionary which maps filename => content of file.</p>
|
||||
|
||||
<p><code>!include_dir_merge_list</code> will return content of a directory as a list by merging all files (which should contain a list) into 1 big list.</p>
|
||||
<p><code class="highlighter-rouge">!include_dir_merge_list</code> will return content of a directory as a list by merging all files (which should contain a list) into 1 big list.</p>
|
||||
|
||||
<p><code>!include_dir_merge_named</code> will return content of a directory as a dictionary by loading each file and merging it into 1 big dictionary.</p>
|
||||
<p><code class="highlighter-rouge">!include_dir_merge_named</code> will return content of a directory as a dictionary by loading each file and merging it into 1 big dictionary.</p>
|
||||
|
||||
<h4><a class="title-link" name="example-include_dir_list" href="#example-include_dir_list"></a> Example: <code>!include_dir_list</code></h4>
|
||||
<h4><a class="title-link" name="example-include_dir_list" href="#example-include_dir_list"></a> Example: <code class="highlighter-rouge">!include_dir_list</code></h4>
|
||||
|
||||
<p><code>configuration.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">configuration.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">automation</span>:
|
||||
- <span class="string"><span class="content">alias: Automation 1</span></span>
|
||||
<span class="key">trigger</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.iphone</span></span>
|
||||
<span class="key">to</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">light.turn_on</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">light.entryway</span></span>
|
||||
- <span class="string"><span class="content">alias: Automation 2</span></span>
|
||||
<span class="key">trigger</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.iphone</span></span>
|
||||
<span class="key">from</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">light.turn_off</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">light.entryway</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">automation</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">alias</span><span class="pi">:</span> <span class="s">Automation 1</span>
|
||||
<span class="s">trigger</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">state</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">device_tracker.iphone</span>
|
||||
<span class="s">to</span><span class="pi">:</span> <span class="s1">'</span><span class="s">home'</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">light.turn_on</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">light.entryway</span>
|
||||
<span class="pi">-</span> <span class="s">alias</span><span class="pi">:</span> <span class="s">Automation 2</span>
|
||||
<span class="s">trigger</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">state</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">device_tracker.iphone</span>
|
||||
<span class="s">from</span><span class="pi">:</span> <span class="s1">'</span><span class="s">home'</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">light.turn_off</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">light.entryway</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>can be turned into:</p>
|
||||
|
||||
<p><code>configuration.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">configuration.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">automation</span>: <span class="type">!include_dir_list</span> <span class="string"><span class="content">automation/presence/</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">automation</span><span class="pi">:</span> <span class="kt">!include_dir_list</span> <span class="s">automation/presence/</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><code>automation/presence/automation1.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">automation/presence/automation1.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">alias</span>: <span class="string"><span class="content">Automation 1</span></span>
|
||||
<span class="key">trigger</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.iphone</span></span>
|
||||
<span class="key">to</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">light.turn_on</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">light.entryway</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">alias</span><span class="pi">:</span> <span class="s">Automation 1</span>
|
||||
<span class="s">trigger</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">state</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">device_tracker.iphone</span>
|
||||
<span class="s">to</span><span class="pi">:</span> <span class="s1">'</span><span class="s">home'</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">light.turn_on</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">light.entryway</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><code>automation/presence/automation2.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">automation/presence/automation2.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">alias</span>: <span class="string"><span class="content">Automation 2</span></span>
|
||||
<span class="key">trigger</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.iphone</span></span>
|
||||
<span class="key">from</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">light.turn_off</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">light.entryway</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">alias</span><span class="pi">:</span> <span class="s">Automation 2</span>
|
||||
<span class="s">trigger</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">state</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">device_tracker.iphone</span>
|
||||
<span class="s">from</span><span class="pi">:</span> <span class="s1">'</span><span class="s">home'</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">light.turn_off</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">light.entryway</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>It is important to note that each file must contain only <strong>one</strong> entry when using <code>!include_dir_list</code>.</p>
|
||||
<p>It is important to note that each file must contain only <strong>one</strong> entry when using <code class="highlighter-rouge">!include_dir_list</code>.</p>
|
||||
|
||||
<h4><a class="title-link" name="example-include_dir_named" href="#example-include_dir_named"></a> Example: <code>!include_dir_named</code></h4>
|
||||
<h4><a class="title-link" name="example-include_dir_named" href="#example-include_dir_named"></a> Example: <code class="highlighter-rouge">!include_dir_named</code></h4>
|
||||
|
||||
<p><code>configuration.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">configuration.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
<span class="key">alexa</span>:
|
||||
<span class="key">intents</span>:
|
||||
<span class="key">LocateIntent</span>:
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">notify.pushover</span></span>
|
||||
<span class="key">data</span>:
|
||||
<span class="key">message</span>: <span class="string"><span class="content">Your location has been queried via Alexa.</span></span>
|
||||
<span class="key">speech</span>:
|
||||
<span class="key">type</span>: <span class="string"><span class="content">plaintext</span></span>
|
||||
<span class="key">text</span>: <span class="string"><span class="delimiter">></span><span class="content">
|
||||
{%- for state in states.device_tracker -%}
|
||||
{%- if state.name.lower() == User.lower() -%}
|
||||
{{ state.name }} is at {{ state.state }}
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
I am sorry. Pootie! I do not know where {{User}} is.
|
||||
{%- endfor -%}</span></span>
|
||||
<span class="key">WhereAreWeIntent</span>:
|
||||
<span class="key">speech</span>:
|
||||
<span class="key">type</span>: <span class="string"><span class="content">plaintext</span></span>
|
||||
<span class="key">text</span>: <span class="string"><span class="delimiter">></span><span class="content">
|
||||
{%- if is_state('device_tracker.iphone', 'home') -%}
|
||||
iPhone is home.
|
||||
{%- else -%}
|
||||
iPhone is not home.
|
||||
{% endif %}</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code>
|
||||
<span class="s">alexa</span><span class="pi">:</span>
|
||||
<span class="s">intents</span><span class="pi">:</span>
|
||||
<span class="s">LocateIntent</span><span class="pi">:</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">notify.pushover</span>
|
||||
<span class="s">data</span><span class="pi">:</span>
|
||||
<span class="s">message</span><span class="pi">:</span> <span class="s">Your location has been queried via Alexa.</span>
|
||||
<span class="s">speech</span><span class="pi">:</span>
|
||||
<span class="s">type</span><span class="pi">:</span> <span class="s">plaintext</span>
|
||||
<span class="s">text</span><span class="pi">:</span> <span class="pi">></span>
|
||||
<span class="no">{%- for state in states.device_tracker -%}</span>
|
||||
<span class="no">{%- if state.name.lower() == User.lower() -%}</span>
|
||||
<span class="no">{{ state.name }} is at {{ state.state }}</span>
|
||||
<span class="no">{%- endif -%}</span>
|
||||
<span class="no">{%- else -%}</span>
|
||||
<span class="no">I am sorry. Pootie! I do not know where {{User}} is.</span>
|
||||
<span class="no">{%- endfor -%}</span>
|
||||
<span class="s">WhereAreWeIntent</span><span class="pi">:</span>
|
||||
<span class="s">speech</span><span class="pi">:</span>
|
||||
<span class="s">type</span><span class="pi">:</span> <span class="s">plaintext</span>
|
||||
<span class="s">text</span><span class="pi">:</span> <span class="pi">></span>
|
||||
<span class="no">{%- if is_state('device_tracker.iphone', 'home') -%}</span>
|
||||
<span class="no">iPhone is home.</span>
|
||||
<span class="no">{%- else -%}</span>
|
||||
<span class="no">iPhone is not home.</span>
|
||||
<span class="no">{% endif %}</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>can be turned into:</p>
|
||||
|
||||
<p><code>configuration.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">configuration.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">alexa</span>:
|
||||
<span class="key">intents</span>: <span class="type">!include_dir_named</span> <span class="string"><span class="content">alexa/</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">alexa</span><span class="pi">:</span>
|
||||
<span class="s">intents</span><span class="pi">:</span> <span class="kt">!include_dir_named</span> <span class="s">alexa/</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><code>alexa/LocateIntent.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">alexa/LocateIntent.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">notify.pushover</span></span>
|
||||
<span class="key">data</span>:
|
||||
<span class="key">message</span>: <span class="string"><span class="content">Your location has been queried via Alexa.</span></span>
|
||||
<span class="key">speech</span>:
|
||||
<span class="key">type</span>: <span class="string"><span class="content">plaintext</span></span>
|
||||
<span class="key">text</span>: <span class="string"><span class="delimiter">></span><span class="content">
|
||||
{%- for state in states.device_tracker -%}
|
||||
{%- if state.name.lower() == User.lower() -%}
|
||||
{{ state.name }} is at {{ state.state }}
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
I am sorry. Pootie! I do not know where {{User}} is.
|
||||
{%- endfor -%}</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">notify.pushover</span>
|
||||
<span class="s">data</span><span class="pi">:</span>
|
||||
<span class="s">message</span><span class="pi">:</span> <span class="s">Your location has been queried via Alexa.</span>
|
||||
<span class="s">speech</span><span class="pi">:</span>
|
||||
<span class="s">type</span><span class="pi">:</span> <span class="s">plaintext</span>
|
||||
<span class="s">text</span><span class="pi">:</span> <span class="pi">></span>
|
||||
<span class="no">{%- for state in states.device_tracker -%}</span>
|
||||
<span class="no">{%- if state.name.lower() == User.lower() -%}</span>
|
||||
<span class="no">{{ state.name }} is at {{ state.state }}</span>
|
||||
<span class="no">{%- endif -%}</span>
|
||||
<span class="no">{%- else -%}</span>
|
||||
<span class="no">I am sorry. Pootie! I do not know where {{User}} is.</span>
|
||||
<span class="no">{%- endfor -%}</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><code>alexa/WhereAreWeIntent.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">alexa/WhereAreWeIntent.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
<span class="key">speech</span>:
|
||||
<span class="key">type</span>: <span class="string"><span class="content">plaintext</span></span>
|
||||
<span class="key">text</span>: <span class="string"><span class="delimiter">></span><span class="content">
|
||||
{%- if is_state('device_tracker.iphone', 'home') -%}
|
||||
iPhone is home.
|
||||
{%- else -%}
|
||||
iPhone is not home.
|
||||
{% endif %}</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code>
|
||||
<span class="s">speech</span><span class="pi">:</span>
|
||||
<span class="s">type</span><span class="pi">:</span> <span class="s">plaintext</span>
|
||||
<span class="s">text</span><span class="pi">:</span> <span class="pi">></span>
|
||||
<span class="no">{%- if is_state('device_tracker.iphone', 'home') -%}</span>
|
||||
<span class="no">iPhone is home.</span>
|
||||
<span class="no">{%- else -%}</span>
|
||||
<span class="no">iPhone is not home.</span>
|
||||
<span class="no">{% endif %}</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h4><a class="title-link" name="example-include_dir_merge_list" href="#example-include_dir_merge_list"></a> Example: <code>!include_dir_merge_list</code></h4>
|
||||
<h4><a class="title-link" name="example-include_dir_merge_list" href="#example-include_dir_merge_list"></a> Example: <code class="highlighter-rouge">!include_dir_merge_list</code></h4>
|
||||
|
||||
<p><code>configuration.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">configuration.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">automation</span>:
|
||||
- <span class="string"><span class="content">alias: Automation 1</span></span>
|
||||
<span class="key">trigger</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.iphone</span></span>
|
||||
<span class="key">to</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">light.turn_on</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">light.entryway</span></span>
|
||||
- <span class="string"><span class="content">alias: Automation 2</span></span>
|
||||
<span class="key">trigger</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.iphone</span></span>
|
||||
<span class="key">from</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">light.turn_off</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">light.entryway</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">automation</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">alias</span><span class="pi">:</span> <span class="s">Automation 1</span>
|
||||
<span class="s">trigger</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">state</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">device_tracker.iphone</span>
|
||||
<span class="s">to</span><span class="pi">:</span> <span class="s1">'</span><span class="s">home'</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">light.turn_on</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">light.entryway</span>
|
||||
<span class="pi">-</span> <span class="s">alias</span><span class="pi">:</span> <span class="s">Automation 2</span>
|
||||
<span class="s">trigger</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">state</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">device_tracker.iphone</span>
|
||||
<span class="s">from</span><span class="pi">:</span> <span class="s1">'</span><span class="s">home'</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">light.turn_off</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">light.entryway</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>can be turned into:</p>
|
||||
|
||||
<p><code>configuration.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">configuration.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">automation</span>: <span class="type">!include_dir_merge_list</span> <span class="string"><span class="content">automation/</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">automation</span><span class="pi">:</span> <span class="kt">!include_dir_merge_list</span> <span class="s">automation/</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><code>automation/presence.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">automation/presence.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>- <span class="string"><span class="content">alias: Automation 1</span></span>
|
||||
<span class="key">trigger</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.iphone</span></span>
|
||||
<span class="key">to</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">light.turn_on</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">light.entryway</span></span>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="pi">-</span> <span class="s">alias</span><span class="pi">:</span> <span class="s">Automation 1</span>
|
||||
<span class="s">trigger</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">state</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">device_tracker.iphone</span>
|
||||
<span class="s">to</span><span class="pi">:</span> <span class="s1">'</span><span class="s">home'</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">light.turn_on</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">light.entryway</span>
|
||||
|
||||
- <span class="string"><span class="content">alias: Automation 2</span></span>
|
||||
<span class="key">trigger</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.iphone</span></span>
|
||||
<span class="key">from</span>: <span class="string"><span class="content">'home'</span></span>
|
||||
<span class="key">action</span>:
|
||||
<span class="key">service</span>: <span class="string"><span class="content">light.turn_off</span></span>
|
||||
<span class="key">entity_id</span>: <span class="string"><span class="content">light.entryway</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<span class="pi">-</span> <span class="s">alias</span><span class="pi">:</span> <span class="s">Automation 2</span>
|
||||
<span class="s">trigger</span><span class="pi">:</span>
|
||||
<span class="s">platform</span><span class="pi">:</span> <span class="s">state</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">device_tracker.iphone</span>
|
||||
<span class="s">from</span><span class="pi">:</span> <span class="s1">'</span><span class="s">home'</span>
|
||||
<span class="s">action</span><span class="pi">:</span>
|
||||
<span class="s">service</span><span class="pi">:</span> <span class="s">light.turn_off</span>
|
||||
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">light.entryway</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>It is important to note that when using <code>!include_dir_merge_list</code>, you must include a list in each file (each list item is denoted with a hyphen [-]). Each file may contain one or more entries.</p>
|
||||
<p>It is important to note that when using <code class="highlighter-rouge">!include_dir_merge_list</code>, you must include a list in each file (each list item is denoted with a hyphen [-]). Each file may contain one or more entries.</p>
|
||||
|
||||
<h4><a class="title-link" name="example-include_dir_merge_named" href="#example-include_dir_merge_named"></a> Example: <code>!include_dir_merge_named</code></h4>
|
||||
<h4><a class="title-link" name="example-include_dir_merge_named" href="#example-include_dir_merge_named"></a> Example: <code class="highlighter-rouge">!include_dir_merge_named</code></h4>
|
||||
|
||||
<p><code>configuration.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">configuration.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">group</span>:
|
||||
<span class="key">bedroom</span>:
|
||||
<span class="key">name</span>: <span class="string"><span class="content">Bedroom</span></span>
|
||||
<span class="key">entities</span>:
|
||||
- <span class="string"><span class="content">light.bedroom_lamp</span></span>
|
||||
- <span class="string"><span class="content">light.bedroom_overhead</span></span>
|
||||
<span class="key">hallway</span>:
|
||||
<span class="key">name</span>: <span class="string"><span class="content">Hallway</span></span>
|
||||
<span class="key">entities</span>:
|
||||
- <span class="string"><span class="content">light.hallway</span></span>
|
||||
- <span class="string"><span class="content">thermostat.home</span></span>
|
||||
<span class="key">front_yard</span>:
|
||||
<span class="key">name</span>: <span class="string"><span class="content">Front Yard</span></span>
|
||||
<span class="key">entities</span>:
|
||||
- <span class="string"><span class="content">light.front_porch</span></span>
|
||||
- <span class="string"><span class="content">light.security</span></span>
|
||||
- <span class="string"><span class="content">light.pathway</span></span>
|
||||
- <span class="string"><span class="content">sensor.mailbox</span></span>
|
||||
- <span class="string"><span class="content">camera.front_porch</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">group</span><span class="pi">:</span>
|
||||
<span class="s">bedroom</span><span class="pi">:</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s">Bedroom</span>
|
||||
<span class="s">entities</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">light.bedroom_lamp</span>
|
||||
<span class="pi">-</span> <span class="s">light.bedroom_overhead</span>
|
||||
<span class="s">hallway</span><span class="pi">:</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s">Hallway</span>
|
||||
<span class="s">entities</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">light.hallway</span>
|
||||
<span class="pi">-</span> <span class="s">thermostat.home</span>
|
||||
<span class="s">front_yard</span><span class="pi">:</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s">Front Yard</span>
|
||||
<span class="s">entities</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">light.front_porch</span>
|
||||
<span class="pi">-</span> <span class="s">light.security</span>
|
||||
<span class="pi">-</span> <span class="s">light.pathway</span>
|
||||
<span class="pi">-</span> <span class="s">sensor.mailbox</span>
|
||||
<span class="pi">-</span> <span class="s">camera.front_porch</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>can be turned into:</p>
|
||||
|
||||
<p><code>configuration.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">configuration.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">group</span>: <span class="type">!include_dir_merge_named</span> <span class="string"><span class="content">group/</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">group</span><span class="pi">:</span> <span class="kt">!include_dir_merge_named</span> <span class="s">group/</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><code>group/interior.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">group/interior.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">bedroom</span>:
|
||||
<span class="key">name</span>: <span class="string"><span class="content">Bedroom</span></span>
|
||||
<span class="key">entities</span>:
|
||||
- <span class="string"><span class="content">light.bedroom_lamp</span></span>
|
||||
- <span class="string"><span class="content">light.bedroom_overhead</span></span>
|
||||
<span class="key">hallway</span>:
|
||||
<span class="key">name</span>: <span class="string"><span class="content">Hallway</span></span>
|
||||
<span class="key">entities</span>:
|
||||
- <span class="string"><span class="content">light.hallway</span></span>
|
||||
- <span class="string"><span class="content">thermostat.home</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">bedroom</span><span class="pi">:</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s">Bedroom</span>
|
||||
<span class="s">entities</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">light.bedroom_lamp</span>
|
||||
<span class="pi">-</span> <span class="s">light.bedroom_overhead</span>
|
||||
<span class="s">hallway</span><span class="pi">:</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s">Hallway</span>
|
||||
<span class="s">entities</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">light.hallway</span>
|
||||
<span class="pi">-</span> <span class="s">thermostat.home</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><code>group/exterior.yaml</code></p>
|
||||
<p><code class="highlighter-rouge">group/exterior.yaml</code></p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">front_yard</span>:
|
||||
<span class="key">name</span>: <span class="string"><span class="content">Front Yard</span></span>
|
||||
<span class="key">entities</span>:
|
||||
- <span class="string"><span class="content">light.front_porch</span></span>
|
||||
- <span class="string"><span class="content">light.security</span></span>
|
||||
- <span class="string"><span class="content">light.pathway</span></span>
|
||||
- <span class="string"><span class="content">sensor.mailbox</span></span>
|
||||
- <span class="string"><span class="content">camera.front_porch</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">front_yard</span><span class="pi">:</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s">Front Yard</span>
|
||||
<span class="s">entities</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">light.front_porch</span>
|
||||
<span class="pi">-</span> <span class="s">light.security</span>
|
||||
<span class="pi">-</span> <span class="s">light.pathway</span>
|
||||
<span class="pi">-</span> <span class="s">sensor.mailbox</span>
|
||||
<span class="pi">-</span> <span class="s">camera.front_porch</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -106,31 +106,31 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>state.entity_id</code></td>
|
||||
<td>Entity ID. Format: <code><domain>.<object_id></code>. Example: <code>light.kitchen</code>.</td>
|
||||
<td><code class="highlighter-rouge">state.entity_id</code></td>
|
||||
<td>Entity ID. Format: <code class="highlighter-rouge"><domain>.<object_id></code>. Example: <code class="highlighter-rouge">light.kitchen</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>state.domain</code></td>
|
||||
<td>Domain of the entity. Example: <code>light</code>.</td>
|
||||
<td><code class="highlighter-rouge">state.domain</code></td>
|
||||
<td>Domain of the entity. Example: <code class="highlighter-rouge">light</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>state.object_id</code></td>
|
||||
<td>Object ID of entity. Example: <code>kitchen</code>.</td>
|
||||
<td><code class="highlighter-rouge">state.object_id</code></td>
|
||||
<td>Object ID of entity. Example: <code class="highlighter-rouge">kitchen</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>state.name</code></td>
|
||||
<td>Name of the entity. Based on <code>friendly_name</code> attribute with fall back to object ID. Example: <code>Kitchen Ceiling</code>.</td>
|
||||
<td><code class="highlighter-rouge">state.name</code></td>
|
||||
<td>Name of the entity. Based on <code class="highlighter-rouge">friendly_name</code> attribute with fall back to object ID. Example: <code class="highlighter-rouge">Kitchen Ceiling</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>state.last_updated</code></td>
|
||||
<td>Time the state was written to the state machine. Note that writing the exact same state including attributes will not result in this field being updated. Example: <code>14:10:03 13-03-2016</code>.</td>
|
||||
<td><code class="highlighter-rouge">state.last_updated</code></td>
|
||||
<td>Time the state was written to the state machine. Note that writing the exact same state including attributes will not result in this field being updated. Example: <code class="highlighter-rouge">14:10:03 13-03-2016</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>state.last_changed</code></td>
|
||||
<td>Time the state changed. This is not updated when there are only updated attributes. Example: <code>14:10:03 13-03-2016</code>.</td>
|
||||
<td><code class="highlighter-rouge">state.last_changed</code></td>
|
||||
<td>Time the state changed. This is not updated when there are only updated attributes. Example: <code class="highlighter-rouge">14:10:03 13-03-2016</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>state.attributes</code></td>
|
||||
<td><code class="highlighter-rouge">state.attributes</code></td>
|
||||
<td>A dictionary with extra attributes related to the current state.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
@ -138,7 +138,7 @@
|
|||
|
||||
<p>The attributes of an entity are optional. There are a few attributes that are used by Home Assistant for representing the entity in a specific way. Each component will also have it’s own attributes to represent extra state data about the entity. For example, the light component has attributes for the current brightness and color of the light. When an attribute is not available, Home Assistant will not write it to the state.</p>
|
||||
|
||||
<p>When using templates, attributes will be available by their name. For example <code>state.attributes.assumed_state</code>.</p>
|
||||
<p>When using templates, attributes will be available by their name. For example <code class="highlighter-rouge">state.attributes.assumed_state</code>.</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -149,33 +149,33 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>friendly_name</code></td>
|
||||
<td>Name of the entity. Example: <code>Kitchen Ceiling</code>.</td>
|
||||
<td><code class="highlighter-rouge">friendly_name</code></td>
|
||||
<td>Name of the entity. Example: <code class="highlighter-rouge">Kitchen Ceiling</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>icon</code></td>
|
||||
<td>Icon to use for the entity in the frontend. Example: <code>mdi:home</code>.</td>
|
||||
<td><code class="highlighter-rouge">icon</code></td>
|
||||
<td>Icon to use for the entity in the frontend. Example: <code class="highlighter-rouge">mdi:home</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>hidden</code></td>
|
||||
<td>Boolean if the entity should not be shown in the frontend. Example: <code>true</code>.</td>
|
||||
<td><code class="highlighter-rouge">hidden</code></td>
|
||||
<td>Boolean if the entity should not be shown in the frontend. Example: <code class="highlighter-rouge">true</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>entity_picture</code></td>
|
||||
<td>Url to a picture that should be used instead of showing the domain icon. Example: <code>http://example.com/picture.jpg</code>.</td>
|
||||
<td><code class="highlighter-rouge">entity_picture</code></td>
|
||||
<td>Url to a picture that should be used instead of showing the domain icon. Example: <code class="highlighter-rouge">http://example.com/picture.jpg</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>assumed_state</code></td>
|
||||
<td>Boolean if the current state is an assumption. <a href="https://home-assistant.io/blog/2016/02/12/classifying-the-internet-of-things/#classifiers">More info</a> Example: <code>True</code>.</td>
|
||||
<td><code class="highlighter-rouge">assumed_state</code></td>
|
||||
<td>Boolean if the current state is an assumption. <a href="https://home-assistant.io/blog/2016/02/12/classifying-the-internet-of-things/#classifiers">More info</a> Example: <code class="highlighter-rouge">True</code>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>unit_of_measurement</code></td>
|
||||
<td>The unit of measurement the state is expressed in. Used for grouping graphs or understanding the entity. Example: <code>°C</code>.</td>
|
||||
<td><code class="highlighter-rouge">unit_of_measurement</code></td>
|
||||
<td>The unit of measurement the state is expressed in. Used for grouping graphs or understanding the entity. Example: <code class="highlighter-rouge">°C</code>.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p>When an attribute contains spaces, you can retrieve it like this: <code>states.sensor.livingroom.attributes["Battery numeric"]</code>.</p>
|
||||
<p>When an attribute contains spaces, you can retrieve it like this: <code class="highlighter-rouge">states.sensor.livingroom.attributes["Battery numeric"]</code>.</p>
|
||||
|
||||
|
||||
</article>
|
||||
|
|
|
@ -115,20 +115,18 @@ The frontend has a template editor developer tool to help develop and debug temp
|
|||
|
||||
<p>Templates can get big pretty fast. To keep a clear overview, consider using YAML multiline strings to define your templates:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="key">script</span>:
|
||||
<span class="key">msg_who_is_home</span>:
|
||||
<span class="key">sequence</span>:
|
||||
- <span class="string"><span class="content">service: notify.notify</span></span>
|
||||
<span class="key">data</span>:
|
||||
<span class="key">message</span>: <span class="string"><span class="delimiter">></span><span class="content">
|
||||
{% if is_state('device_tracker.paulus', 'home') %}
|
||||
Ha, Paulus is home!
|
||||
{% else %}
|
||||
Paulus is at {{ states('device_tracker.paulus')) }}.
|
||||
{% endif %}</span></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">script</span><span class="pi">:</span>
|
||||
<span class="s">msg_who_is_home</span><span class="pi">:</span>
|
||||
<span class="s">sequence</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">service</span><span class="pi">:</span> <span class="s">notify.notify</span>
|
||||
<span class="s">data</span><span class="pi">:</span>
|
||||
<span class="s">message</span><span class="pi">:</span> <span class="pi">></span>
|
||||
<span class="no">{% if is_state('device_tracker.paulus', 'home') %}</span>
|
||||
<span class="no">Ha, Paulus is home!</span>
|
||||
<span class="no">{% else %}</span>
|
||||
<span class="no">Paulus is at {{ states('device_tracker.paulus')) }}.</span>
|
||||
<span class="no">{% endif %}</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p><a href="http://jinja.pocoo.org/">Jinja2</a> supports a width variety of operations:</p>
|
||||
|
@ -144,22 +142,22 @@ The frontend has a template editor developer tool to help develop and debug temp
|
|||
<p>Home Assistant adds extensions to allow templates to access all of the current states:</p>
|
||||
|
||||
<ul>
|
||||
<li>Iterating <code>states</code> will yield each state sorted alphabetically by entity ID.</li>
|
||||
<li>Iterating <code>states.domain</code> will yield each state of that domain sorted alphabetically by entity ID.</li>
|
||||
<li><code>states.sensor.temperature</code> returns the state object for <code>sensor.temperature</code>.</li>
|
||||
<li><code>states('device_tracker.paulus')</code> will return the state string (not the object) of the given entity or <code>unknown</code> if it doesn’t exist.</li>
|
||||
<li><code>is_state('device_tracker.paulus', 'home')</code> will test if the given entity is specified state.</li>
|
||||
<li><code>is_state_attr('device_tracker.paulus', 'battery', 40)</code> will test if the given entity is specified state.</li>
|
||||
<li><code>now</code> will be rendered as current time in your time zone.</li>
|
||||
<li><code>utcnow</code> will be rendered as UTC time.</li>
|
||||
<li><code>as_timestamp</code> will convert datetime object or string to UNIX timestamp</li>
|
||||
<li><code>distance()</code> will measure the distance in meters between home, entity, coordinates.</li>
|
||||
<li><code>closest()</code> will find the closest entity.</li>
|
||||
<li><code>relative_time(timestamp)</code> will format the date time as relative time vs now (ie 7 seconds)</li>
|
||||
<li><code>float</code> will format the output as float.</li>
|
||||
<li>Filter <code>round(x)</code> will convert the input to a number and round it to <code>x</code> decimals.</li>
|
||||
<li>Filter <code>timestamp_local</code> will convert an UNIX timestamp to local time/data.</li>
|
||||
<li>Filter <code>timestamp_utc</code> will convert an UNIX timestamp to UTC time/data.</li>
|
||||
<li>Iterating <code class="highlighter-rouge">states</code> will yield each state sorted alphabetically by entity ID.</li>
|
||||
<li>Iterating <code class="highlighter-rouge">states.domain</code> will yield each state of that domain sorted alphabetically by entity ID.</li>
|
||||
<li><code class="highlighter-rouge">states.sensor.temperature</code> returns the state object for <code class="highlighter-rouge">sensor.temperature</code>.</li>
|
||||
<li><code class="highlighter-rouge">states('device_tracker.paulus')</code> will return the state string (not the object) of the given entity or <code class="highlighter-rouge">unknown</code> if it doesn’t exist.</li>
|
||||
<li><code class="highlighter-rouge">is_state('device_tracker.paulus', 'home')</code> will test if the given entity is specified state.</li>
|
||||
<li><code class="highlighter-rouge">is_state_attr('device_tracker.paulus', 'battery', 40)</code> will test if the given entity is specified state.</li>
|
||||
<li><code class="highlighter-rouge">now</code> will be rendered as current time in your time zone.</li>
|
||||
<li><code class="highlighter-rouge">utcnow</code> will be rendered as UTC time.</li>
|
||||
<li><code class="highlighter-rouge">as_timestamp</code> will convert datetime object or string to UNIX timestamp</li>
|
||||
<li><code class="highlighter-rouge">distance()</code> will measure the distance in meters between home, entity, coordinates.</li>
|
||||
<li><code class="highlighter-rouge">closest()</code> will find the closest entity.</li>
|
||||
<li><code class="highlighter-rouge">relative_time(timestamp)</code> will format the date time as relative time vs now (ie 7 seconds)</li>
|
||||
<li><code class="highlighter-rouge">float</code> will format the output as float.</li>
|
||||
<li>Filter <code class="highlighter-rouge">round(x)</code> will convert the input to a number and round it to <code class="highlighter-rouge">x</code> decimals.</li>
|
||||
<li>Filter <code class="highlighter-rouge">timestamp_local</code> will convert an UNIX timestamp to local time/data.</li>
|
||||
<li>Filter <code class="highlighter-rouge">timestamp_utc</code> will convert an UNIX timestamp to UTC time/data.</li>
|
||||
</ul>
|
||||
|
||||
<h2><a class="title-link" name="examples" href="#examples"></a> Examples</h2>
|
||||
|
@ -167,36 +165,28 @@ The frontend has a template editor developer tool to help develop and debug temp
|
|||
<h3><a class="title-link" name="states" href="#states"></a> States</h3>
|
||||
<p>Next two statements result in same value if state exists. Second one will result in an error if state does not exist.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
{{ states('device_tracker.paulus') }}
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code>{{ states('device_tracker.paulus') }}
|
||||
{{ states.device_tracker.paulus.state }}
|
||||
</pre></div>
|
||||
</div>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="attributes" href="#attributes"></a> Attributes</h3>
|
||||
|
||||
<p>Print an attribute if state is defined</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
{% if states.device_tracker.paulus %}
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code>{% if states.device_tracker.paulus %}
|
||||
{{ states.device_tracker.paulus.attributes.battery }}
|
||||
{% else %}
|
||||
??
|
||||
{% endif %}
|
||||
</pre></div>
|
||||
</div>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="sensor-states" href="#sensor-states"></a> Sensor states</h3>
|
||||
|
||||
<p>Print out a list of all the sensor states.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
{% for state in states.sensor %}
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code>{% for state in states.sensor %}
|
||||
{{ state.entity_id }}={{ state.state }},
|
||||
{% endfor %}
|
||||
|
||||
|
@ -217,68 +207,54 @@ The frontend has a template editor developer tool to help develop and debug temp
|
|||
{{ as_timestamp(states.binary_sensor.garage_door.last_changed) }}
|
||||
|
||||
{{ as_timestamp(now) - as_timestamp(states.binary_sensor.garage_door.last_changed) }}
|
||||
|
||||
</pre></div>
|
||||
</div>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="distance-examples" href="#distance-examples"></a> Distance examples</h3>
|
||||
|
||||
<p>If only 1 location is passed in will measure the distance from home.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
Using Lat Lng coordinates: {{ distance(123.45, 123.45) }}
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code>Using Lat Lng coordinates: {{ distance(123.45, 123.45) }}
|
||||
|
||||
Using State: {{ distance(states.device_tracker.paulus) }}
|
||||
|
||||
These can also be combined in any combination:
|
||||
{{ distance(123.45, 123.45, 'device_tracker.paulus') }}
|
||||
{{ distance('device_tracker.anne_therese', 'device_tracker.paulus') }}
|
||||
</pre></div>
|
||||
</div>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="closest-examples" href="#closest-examples"></a> Closest examples</h3>
|
||||
|
||||
<p>Find entities closest to the Home Assistant location:</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
Query all entities: {{ closest(states) }}
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code>Query all entities: {{ closest(states) }}
|
||||
Query all entities of a specific domain: {{ closest('states.device_tracker') }}
|
||||
Query all entities in group.children: {{ closest('group.children') }}
|
||||
Query all entities in group.children: {{ closest(states.group.children) }}
|
||||
</pre></div>
|
||||
</div>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>Find entities closest to a coordinate or another entity. All previous arguments still apply for 2nd argument.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
Closest to a coordinate: {{ closest(23.456, 23.456, 'group.children') }}
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code>Closest to a coordinate: {{ closest(23.456, 23.456, 'group.children') }}
|
||||
Closest to an entity: {{ closest('zone.school', 'group.children') }}
|
||||
Closest to an entity: {{ closest(states.zone.school, 'group.children') }}
|
||||
</pre></div>
|
||||
</div>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="combined" href="#combined"></a> Combined</h3>
|
||||
<p>Since closest returns a state, we can combine it with distance too</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre>
|
||||
{{ closest(states).name }} is {{ distance(closest(states)) }} meters away.
|
||||
</pre></div>
|
||||
</div>
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code>{{ closest(states).name }} is {{ distance(closest(states)) }} meters away.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h2><a class="title-link" name="processing-incoming-data" href="#processing-incoming-data"></a> Processing incoming data</h2>
|
||||
|
||||
<p>The other part of templating is processing incoming data. It will allow you to modify incoming data and extract only the data you care about. This will work only for platforms and components that mentioned support for this in their documentation.</p>
|
||||
|
||||
<p>It depends per component or platform but it is common to be able to define a template using the <code>value_template</code> configuration key. When a new value arrives, your template will be rendered while having access to the following values on top of the usual Home Assistant extensions:</p>
|
||||
<p>It depends per component or platform but it is common to be able to define a template using the <code class="highlighter-rouge">value_template</code> configuration key. When a new value arrives, your template will be rendered while having access to the following values on top of the usual Home Assistant extensions:</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
|
@ -289,25 +265,24 @@ Closest to an entity: {{ closest(states.zone.school, 'group.children') }}
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>value</code></td>
|
||||
<td><code class="highlighter-rouge">value</code></td>
|
||||
<td>The incoming value.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>value_json</code></td>
|
||||
<td><code class="highlighter-rouge">value_json</code></td>
|
||||
<td>The incoming value parsed as JSON.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre># Incoming value:
|
||||
{"primes": [2, 3, 5, 7, 11, 13]}
|
||||
<div class="language-text highlighter-rouge"><pre class="highlight"><code># Incoming value:
|
||||
{"primes": [2, 3, 5, 7, 11, 13]}
|
||||
|
||||
# Extract third prime number
|
||||
{{ value_json.primes[2] }}
|
||||
|
||||
# Format output
|
||||
{{ "%+.1f" | value_json }}
|
||||
{{ "%+.1f" | value_json }}
|
||||
|
||||
# Math
|
||||
{{ value_json | float * 1024 }}
|
||||
|
@ -316,8 +291,7 @@ Closest to an entity: {{ closest(states.zone.school, 'group.children') }}
|
|||
# Timestamps
|
||||
{{ value_json.tst | timestamp_local }}
|
||||
{{ value_json.tst | timestamp_utc }}
|
||||
</pre></div>
|
||||
</div>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue