Site updated at 2018-02-13 16:47:08 UTC

This commit is contained in:
Travis CI 2018-02-13 16:47:08 +00:00
parent 3a61e6afb6
commit 923592f57d
29 changed files with 92 additions and 80 deletions

View file

@ -75,15 +75,15 @@
</h1>
</header>
<hr class="divider">
<p>Hass.io is a managed environment, which means that you cant install applications that can be embedded into Home Assistant using the <code class="highlighter-rouge">command_line</code> sensor/switch.</p>
<p>There are three options if you need to run a script to read data from a sensor or send commands to other devices on Hass.io.</p>
<p>The first option is to write a custom component for Home Assistant. Using Python, you can communicate with your device. For more information about developing a custom component, take a look at the <a href="/developers/component_loading/">developer documentation</a>.</p>
<p>The second option is to use STDIN inside add-on and use the service <code class="highlighter-rouge">hassio.addon_stdin</code> to send data. More about this options look into <a href="/developers/hassio/addon_communication/">developer documentation</a> for internal add-on communication. There is also describe how do you can easy access to Home-Assistant Rest API.</p>
<p>The third option is to make a local add-on for Hass.io that sends the data to Home Assistant via MQTT. Before we dive into this, read up on <a href="/developers/hassio/addon_tutorial/">Hass.io add-on development</a> first.</p>
<p>Hass.io is a managed environment, which means you cant install applications that can be embedded into Home Assistant using the <code class="highlighter-rouge">command_line</code> sensor/switch.</p>
<p>There are three options if you need to run a script which reads data from a sensor or sends commands to other devices on Hass.io.</p>
<p>The first option is to write a custom component for Home Assistant. This implies that you can communicate with your device using Python. For more information about developing a custom component, take a look at <a href="/developers/component_loading/">custom-component development</a>.</p>
<p>The second option is to use STDIN inside an add-on and use the service <code class="highlighter-rouge">hassio.addon_stdin</code> to send data. For more information, have a look at <a href="/developers/hassio/addon_communication/">internal add-on communication</a>. Here you will also find how you can easily access the Home Assistant Rest API.</p>
<p>The third option is to create a local add-on for Hass.io that sends the data to Home Assistant via MQTT. Before we dive into this, read up on <a href="/developers/hassio/addon_tutorial/">Hass.io add-on development</a> first.</p>
<p>For security and speed, Hass.io does not provide a way for containers to communicate directly. So the first step is to set up a communication channel. Were going to use MQTT for this using the <a href="/addons/mosquitto/">MQTT broker add-on</a>.</p>
<h3><a class="title-link" name="sensors" href="#sensors"></a> Sensors</h3>
<p>We loop in our script to fetch data and push it to MQTT and wait until the next process is ready. Here is a basic example and structure for that process.</p>
<p>Our Dockerfile need to install:</p>
<p>In our Dockerfile we need to install:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>RUN apk --no-cache add jq mosquitto-clients
</code></pre>
</div>
@ -117,7 +117,7 @@
</div>
<h3><a class="title-link" name="commands" href="#commands"></a> Commands</h3>
<p>We wait for incoming data from the MQTT broker. We can also use an <code class="highlighter-rouge">input_boolean</code> that triggers an automation to publish a custom command to MQTT topic that can process multiple things in one add-on.</p>
<p>Our Dockerfile need to install:</p>
<p>In our Dockerfile we need to install:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>RUN apk --no-cache add jq mosquitto-clients
</code></pre>
</div>