Site updated at 2015-04-27 00:47:00 UTC

This commit is contained in:
Paulus Schoutsen 2015-04-26 17:47:00 -07:00
parent a215a57ace
commit f137ead5cd
53 changed files with 2216 additions and 275 deletions

View file

@ -188,6 +188,32 @@ This option is currently limited to built-in components.
</p>
<h3><a class='title-link' name='creating-entities' href='#creating-entities'></a> Creating Entities</h3>
<p>Home Assistant will call a function with the following signature to initialize
your new platform. This function must exist in the platform module you create.</p>
<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='python'><span class='line'><span class="k">def</span> <span class="nf">setup_platform</span><span class="p">(</span><span class="n">hass</span><span class="p">,</span> <span class="n">config</span><span class="p">,</span> <span class="n">add_devices</span><span class="p">,</span> <span class="n">discovery_info</span><span class="o">=</span><span class="bp">None</span><span class="p">)</span>
</span></code></pre></td></tr></table></div></figure>
<p>In this function, your platform should create the appropriate entities and
register them with the Home Assistant core. Entities are Home Assistant&rsquo;s
representation of lights, switches, sensors, etc. It is best practice for all
new entities to inherit the
<a href="https://github.com/balloob/home-assistant/blob/master/homeassistant/helpers/entity.py#L18">Entity Abstract Class</a>.
This abstract class contains logic for integrating most standard features into
your entities, such as visibility, entity IDs, updates, and many more. That is
why it is best practice to reference the existing class.</p>
<p>A list of entities can be registered with Home Assitant using the <em>add_devices</em>
function that is provided as an input to <em>setup_platform</em>. Once entities are
registered with with Home Assistant their updates will be provided to the core
and the core will have control over them. For more information on how Entites
can be customized, take a look at the <a href="https://github.com/balloob/home-assistant/blob/master/homeassistant/helpers/entity.py#L18">Entity Abstract
Class</a>.</p>
</article>