Site updated at 2016-10-30 15:07:35 UTC
This commit is contained in:
parent
317f0569b8
commit
ea1e1d0895
24 changed files with 74 additions and 45 deletions
|
@ -133,10 +133,14 @@
|
|||
<li><strong>value_template</strong> (<em>Optional</em>): Defines a <a href="/topics/templating/">template</a> to extract the value.</li>
|
||||
<li><strong>payload</strong> (<em>Optional</em>): The payload to send with a POST request. Usualy formed as a dictionary.</li>
|
||||
<li><strong>verify_ssl</strong> (<em>Optional</em>): Verify the certification of the endpoint. Default to True.</li>
|
||||
<li><strong>authentication</strong> (<em>Optional</em>): Type of the HTTP authentication. <code class="highlighter-rouge">basic</code> or <code class="highlighter-rouge">digest</code>.</li>
|
||||
<li><strong>username</strong> (<em>Optional</em>): The username for accessing the REST endpoint.</li>
|
||||
<li><strong>password</strong> (<em>Optional</em>): The password for accessing the REST endpoint.</li>
|
||||
<li><strong>headers</strong> (<em>Optional</em>): The headers for the requests.</li>
|
||||
</ul>
|
||||
|
||||
<p class="note warning">
|
||||
Make sure that the URL matches exactly your endpoint or resource.
|
||||
Make sure that the URL exactly matches your endpoint or resource.
|
||||
</p>
|
||||
|
||||
<h2><a class="title-link" name="examples" href="#examples"></a> Examples</h2>
|
||||
|
@ -145,7 +149,7 @@ Make sure that the URL matches exactly your endpoint or resource.
|
|||
|
||||
<h3><a class="title-link" name="arest-sensor" href="#arest-sensor"></a> aREST sensor</h3>
|
||||
|
||||
<p>Instead of using an <a href="/components/binary_sensor.arest/">aREST</a> binary sensor could the value of a device supporting aREST directly retrieved with a REST binary sensor.</p>
|
||||
<p>Instead of using an <a href="/components/binary_sensor.arest/">aREST</a> binary sensor, you could retrieve the value of a device supporting aREST directly with a REST binary sensor.</p>
|
||||
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">binary_sensor</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">rest</span>
|
||||
|
@ -153,10 +157,35 @@ Make sure that the URL matches exactly your endpoint or resource.
|
|||
<span class="s">method</span><span class="pi">:</span> <span class="s">GET</span>
|
||||
<span class="s">name</span><span class="pi">:</span> <span class="s">Light</span>
|
||||
<span class="s">sensor_class</span><span class="pi">:</span> <span class="s">light</span>
|
||||
<span class="s">value_template</span><span class="pi">:</span> <span class="s1">'</span><span class="s">'</span>
|
||||
<span class="s">value_template</span><span class="pi">:</span> <span class="s1">'</span><span class="s">{{</span><span class="nv"> </span><span class="s">value_json.return_value</span><span class="nv"> </span><span class="s">}}'</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<h3><a class="title-link" name="accessing-an-http-authentication-protected-endpoint" href="#accessing-an-http-authentication-protected-endpoint"></a> Accessing an HTTP authentication protected endpoint</h3>
|
||||
|
||||
<p>The REST sensor supports HTTP authentication and customized headers.</p>
|
||||
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">binary_sensor</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">rest</span>
|
||||
<span class="s">resource</span><span class="pi">:</span> <span class="s">http://IP_ADDRESS:5000/binary_sensor</span>
|
||||
<span class="s">username</span><span class="pi">:</span> <span class="s">ha1</span>
|
||||
<span class="s">password</span><span class="pi">:</span> <span class="s">test1</span>
|
||||
<span class="s">authentication</span><span class="pi">:</span> <span class="s">basic</span>
|
||||
<span class="s">headers</span><span class="pi">:</span>
|
||||
<span class="s">User-Agent</span><span class="pi">:</span> <span class="s">Home Assistant</span>
|
||||
<span class="s">Content-Type</span><span class="pi">:</span> <span class="s">application/json</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>The headers will contain all relevant details. This will also give you the ability to access endpoints that are protected by tokens.</p>
|
||||
|
||||
<p>```bash
|
||||
Content-Length: 1024
|
||||
Host: IP_ADDRESS1:5000
|
||||
Authorization: Basic aGExOnRlc3Qx
|
||||
Accept-Encoding: identity
|
||||
Content-Type: application/json
|
||||
User-Agent: Home Assistant</p>
|
||||
|
||||
|
||||
</article>
|
||||
|
|
|
@ -129,10 +129,10 @@
|
|||
</ul>
|
||||
|
||||
<p class="note warning">
|
||||
Make sure that the URL matches exactly your endpoint or resource.
|
||||
Make sure that the URL exactly matches your endpoint or resource.
|
||||
</p>
|
||||
|
||||
<p><code class="highlighter-rouge">curl</code> could help you with the identification of the variable you want to display in your Home Assistant frontend. The example below show the JSON response of a device that is running with <a href="http://arest.io/">aREST</a>.</p>
|
||||
<p><code class="highlighter-rouge">curl</code> can help you identify the variable you want to display in your Home Assistant frontend. The example below shows the JSON response of a device that is running with <a href="http://arest.io/">aREST</a>.</p>
|
||||
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>curl -X GET http://192.168.1.31/temperature/
|
||||
<span class="o">{</span><span class="s2">"temperature"</span>: 77, <span class="s2">"id"</span>: <span class="s2">"sensor02"</span>, <span class="s2">"name"</span>: <span class="s2">"livingroom"</span>, <span class="s2">"connected"</span>: <span class="nb">true</span><span class="o">}</span>
|
||||
|
@ -198,14 +198,14 @@ Make sure that the URL matches exactly your endpoint or resource.
|
|||
<span class="s">password</span><span class="pi">:</span> <span class="s">test1</span>
|
||||
<span class="s">authentication</span><span class="pi">:</span> <span class="s">basic</span>
|
||||
<span class="s">headers</span><span class="pi">:</span>
|
||||
<span class="s">User-agent</span><span class="pi">:</span> <span class="s">Home Assistant</span>
|
||||
<span class="s">User-Agent</span><span class="pi">:</span> <span class="s">Home Assistant</span>
|
||||
<span class="s">Content-Type</span><span class="pi">:</span> <span class="s">application/json</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p>The header will contains all relevant details. This will give you the flexibility to access also endpoints wich are protected by Tokens.</p>
|
||||
<p>The headers will contain all relevant details. This will also give you the ability to access endpoints that are protected by tokens.</p>
|
||||
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code>Content-Length:
|
||||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code>Content-Length: 1024
|
||||
Host: IP_ADDRESS1:5000
|
||||
Authorization: Basic aGExOnRlc3Qx
|
||||
Accept-Encoding: identity
|
||||
|
@ -216,7 +216,7 @@ User-Agent: Home Assistant
|
|||
|
||||
<h3><a class="title-link" name="use-github-to-get-the-latest-release-of-home-assistant" href="#use-github-to-get-the-latest-release-of-home-assistant"></a> Use GitHub to get the latest release of Home Assistant</h3>
|
||||
|
||||
<p>This sample is very similar to the <a href="/components/updater/"><code class="highlighter-rouge">updater</code></a> component but the information are recieved from GitHub.</p>
|
||||
<p>This sample is very similar to the <a href="/components/updater/"><code class="highlighter-rouge">updater</code></a> component but the information is recieved from GitHub.</p>
|
||||
|
||||
<div class="language-yaml highlighter-rouge"><pre class="highlight"><code><span class="s">sensor</span><span class="pi">:</span>
|
||||
<span class="pi">-</span> <span class="s">platform</span><span class="pi">:</span> <span class="s">rest</span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue