Site updated at 2017-07-29 22:06:40 UTC

This commit is contained in:
Travis CI 2017-07-29 22:06:40 +00:00
parent e55d4ce725
commit 59edc9bad6
744 changed files with 14665 additions and 3545 deletions

View file

@ -76,32 +76,11 @@
<hr class="divider">
<p>There are a few ways that you can use Amazon Echo and Home Assistant together.</p>
<ul>
<li><a href="#i-just-want-to-turn-devices-on-and-off-using-echo">Turning devices on and off</a></li>
<li><a href="#i-want-to-build-custom-commands-to-use-with-echo">Build custom commands to use</a></li>
<li><a href="#flash-briefing-skills">Create a new Flash Briefing source</a></li>
<li>Alternative: use the <a href="/components/emulated_hue/">Emulated Hue component</a> to trick Alexa to thinking Home Assistant is a Philips Hue hub.</li>
</ul>
<p>No matter which method(s) you decide to use, please remember that Amazon Echo requires an active Internet connection to function. If your Internet is down or experiencing issues (or Amazons infrastructure is having issues), none of these methods will work.</p>
<p>Amazon has released <a href="https://echosim.io/">Echosim</a>, a website that simulates the Alexa service in your browser. That way it is easy to test your skills without having access to a physical Amazon Echo.</p>
<h2><a class="title-link" name="i-just-want-to-turn-devices-on-and-off-using-echo" href="#i-just-want-to-turn-devices-on-and-off-using-echo"></a> I just want to turn devices on and off using Echo</h2>
<p>If you just want to be able to turn anything with a switch (like lights, switches, media players, etc) on and off, you should enable the <a href="https://home-assistant.io/components/emulated_hue/">Emulated Hue</a> component. It makes your Home Assistant appear as if it were a Phillips Hue bridge, which Echo works with natively.</p>
<p>Enabling the Emulated Hue component means you can turn things on and off by simply saying</p>
<blockquote>
<p>Alexa, turn the living room lights on.</p>
</blockquote>
<p>or</p>
<blockquote>
<p>Alexa, set the living room lights to twenty percent.</p>
</blockquote>
<p>instead of</p>
<blockquote>
<p>Alexa, tell Home Assistant to turn the living room lights on.</p>
</blockquote>
<p>or</p>
<blockquote>
<p>Alexa, tell Home Assistant to set the living room lights to twenty percent.</p>
</blockquote>
<p>In addition, you would need to build custom intents for each device and on/off combination using the below method, whereas everything just works without any extra work by using Emulated Hue.</p>
<p>Please note that you can use Emulated Hue and the built-in Alexa component side-by-side without issue if you wish.</p>
<h2><a class="title-link" name="i-want-to-build-custom-commands-to-use-with-echo" href="#i-want-to-build-custom-commands-to-use-with-echo"></a> I want to build custom commands to use with Echo</h2>
<p>The built-in Alexa component allows you to integrate Home Assistant into Alexa/Amazon Echo. This component will allow you to query information and call services within Home Assistant by using your voice. Home Assistant offers no built-in sentences but offers a framework for you to define your own.</p>
<div class="videoWrapper">
@ -164,48 +143,7 @@ WhereAreWeIntent where we are
<li>Alexa, ask Home Assistant where we are</li>
</ul>
<h2><a class="title-link" name="configuring-home-assistant" href="#configuring-home-assistant"></a> Configuring Home Assistant</h2>
<p>Out of the box, the component will do nothing. You have to teach it about all intents you want it to answer to. The way it works is that the answer for each intent is based on <a href="/topics/templating/">templates</a> that you define. Each template will have access to the existing states via the <code class="highlighter-rouge">states</code> variable but will also have access to all variables defined in the intent.</p>
<p>You can use <a href="/topics/templating/">templates</a> for the values of <code class="highlighter-rouge">speech/text</code>, <code class="highlighter-rouge">card/title</code> and <code class="highlighter-rouge">card/content</code>.</p>
<p>Actions are using the <a href="/getting-started/scripts/">Home Assistant Script Syntax</a> and also have access to the variables from the intent.</p>
<p>Configuring the Alexa component for the above intents would look like this:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="c1"># Example configuration.yaml entry</span>
<span class="s">alexa</span><span class="pi">:</span>
<span class="s">intents</span><span class="pi">:</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">&gt;</span>
<span class="no">{%- if is_state('device_tracker.paulus', 'home') and</span>
<span class="no">is_state('device_tracker.anne_therese', 'home') -%}</span>
<span class="no">You are both home, you silly</span>
<span class="no">{%- else -%}</span>
<span class="no">Anne Therese is at {{ states("device_tracker.anne_therese") }}</span>
<span class="no">and Paulus is at {{ states("device_tracker.paulus") }}</span>
<span class="no">{% endif %}</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.notify</span>
<span class="s">data_template</span><span class="pi">:</span>
<span class="s">message</span><span class="pi">:</span> <span class="s">The location of {{ User }} 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">&gt;</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">{%- elif loop.last -%}</span>
<span class="no">I am sorry, I do not know where {{ User }} is.</span>
<span class="no">{%- endif -%}</span>
<span class="no">{%- else -%}</span>
<span class="no">Sorry, I don't have any trackers registered.</span>
<span class="no">{%- endfor -%}</span>
<span class="s">card</span><span class="pi">:</span>
<span class="s">type</span><span class="pi">:</span> <span class="s">simple</span>
<span class="s">title</span><span class="pi">:</span> <span class="s">Sample title</span>
<span class="s">content</span><span class="pi">:</span> <span class="s">Some more content</span>
</code></pre>
</div>
<p>When activated, the Alexa component will have Home Assistants native intent support handle the incoming intents. If you want to run actions based on intents, use the <a href="/components/intent_script"><code class="highlighter-rouge">intent_script</code></a> component.</p>
<h3><a class="title-link" name="working-with-scenes" href="#working-with-scenes"></a> Working With Scenes</h3>
<p>One of the most useful applications of Alexa integrations is to call scenes directly. This is easily achieved with some simple setup on the Home Assistant side and by letting Alexa know which scenes you want to run.</p>
<p>First we will configure Alexa. In the Amazon Interaction module add this to the intent schema:</p>
@ -231,15 +169,16 @@ Custom slot type for scene support.
<div class="language-text highlighter-rouge"><pre class="highlight"><code>ActivateSceneIntent activate {Scene}
</code></pre>
</div>
<p>Then add the intent to your Alexa Section in your HA config file:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code> <span class="s">ActivateSceneIntent</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">scene.turn_on</span>
<span class="s">data_template</span><span class="pi">:</span>
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">scene.{{ Scene | replace(" ", "_") }}</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="s">OK</span>
<p>Then add the intent to your intent_script section in your HA config file:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">intent_script</span><span class="pi">:</span>
<span class="s">ActivateSceneIntent</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">scene.turn_on</span>
<span class="s">data_template</span><span class="pi">:</span>
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">scene.{{ Scene | replace(" ", "_") }}</span>
<span class="s">speech</span><span class="pi">:</span>
<span class="s">type</span><span class="pi">:</span> <span class="s">plain</span>
<span class="s">text</span><span class="pi">:</span> <span class="s">OK</span>
</code></pre>
</div>
<p>Here we are using <a href="/topics/templating/">templates</a> to take the name we gave to Alexa e.g. <code class="highlighter-rouge">downstairs on</code> and replace the space with an underscore so it becomes <code class="highlighter-rouge">downstairs_on</code> as Home Assistant expects.</p>
@ -267,15 +206,16 @@ Custom slot type for script support.
<div class="language-text highlighter-rouge"><pre class="highlight"><code>RunScriptIntent run {Script}
</code></pre>
</div>
<p>Then add the intent to your Alexa Section in your HA config file:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code> <span class="s">RunScriptIntent</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">script.turn_on</span>
<span class="s">data_template</span><span class="pi">:</span>
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">script.{{ Script | replace(" ", "_") }}</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="s">OK</span>
<p>Then add the intent to your intent_script section in your HA config file:</p>
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">intent_script</span><span class="pi">:</span>
<span class="s">RunScriptIntent</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">script.turn_on</span>
<span class="s">data_template</span><span class="pi">:</span>
<span class="s">entity_id</span><span class="pi">:</span> <span class="s">script.{{ Script | replace(" ", "_") }}</span>
<span class="s">speech</span><span class="pi">:</span>
<span class="s">type</span><span class="pi">:</span> <span class="s">plain</span>
<span class="s">text</span><span class="pi">:</span> <span class="s">OK</span>
</code></pre>
</div>
<p>Now say <code class="highlighter-rouge">Alexa ask homeassistant to run &lt;some script&gt;</code> and Alexa will run that script for you.</p>
@ -311,32 +251,6 @@ Custom slot type for script support.
</code></pre>
</div>
<p>Alexa will now respond with a random phrase each time. You can use the include for as many different intents as you like so you only need to create the list once.</p>
<p class="note">
As of April 2017, the random filter has been somewhat broken. Youll get a random response the first time this runs, but subsequent commands will reply with the same randomly-chosen phrase. On reboot, Home Assistant will pick a new random choice, but youre stuck with that choice till you reboot. To get around that, use the following code in alexa_confirm.yaml:
</p>
<div class="language-text highlighter-rouge"><pre class="highlight"><code> &gt;
{% set responses = [
"OK",
"Sure",
"If you insist",
"Done",
"No worries",
"I can do that",
"Leave it to me",
"Consider it done",
"As you wish",
"By your command",
"Affirmative",
"Yes oh revered one",
"I will",
"As you decree, so shall it be",
"No Problem"
] %}
{% set rindex = (range(0, (responses | length - 1) )|random) -%}
{{responses[rindex]}}
</code></pre>
</div>
<h2><a class="title-link" name="flash-briefing-skills" href="#flash-briefing-skills"></a> Flash Briefing Skills</h2>
<p>As of version <a href="/blog/2016/10/22/flash-briefing-updater-hacktoberfest/">0.31</a> Home Assistant supports the new <a href="https://developer.amazon.com/alexa-skills-kit/flash-briefing">Alexa Flash Briefing Skills API</a>. A Flash Briefing Skill adds a new Flash Briefing source that is generated by Home Assistant.</p>
<h3><a class="title-link" name="configuring-a-flash-briefing-skill-in-home-assistant" href="#configuring-a-flash-briefing-skill-in-home-assistant"></a> Configuring a Flash Briefing skill in Home Assistant</h3>