Site updated at 2015-04-27 00:47:00 UTC
This commit is contained in:
parent
a215a57ace
commit
f137ead5cd
53 changed files with 2216 additions and 275 deletions
|
@ -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’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>
|
||||
|
||||
|
|
|
@ -286,10 +286,14 @@ You can append <code>?api_password=YOUR_PASSWORD</code> to any url to log in aut
|
|||
<span class='line-number'>3</span>
|
||||
<span class='line-number'>4</span>
|
||||
<span class='line-number'>5</span>
|
||||
<span class='line-number'>6</span>
|
||||
<span class='line-number'>7</span>
|
||||
</pre></td><td class='code'><pre><code class='json'><span class='line'><span class="p">{</span>
|
||||
</span><span class='line'> <span class="nt">"state"</span><span class="p">:</span> <span class="s2">"below_horizon"</span><span class="p">,</span>
|
||||
</span><span class='line'> <span class="nt">"next_rising"</span><span class="p">:</span> <span class="s2">"07:04:15 29-10-2013"</span><span class="p">,</span>
|
||||
</span><span class='line'> <span class="nt">"next_setting"</span><span class="p">:</span> <span class="s2">"18:00:31 29-10-2013"</span>
|
||||
</span><span class='line'> <span class="nt">"attributes"</span><span class="p">:</span> <span class="p">{</span>
|
||||
</span><span class='line'> <span class="nt">"next_rising"</span><span class="p">:</span> <span class="s2">"07:04:15 29-10-2013"</span><span class="p">,</span>
|
||||
</span><span class='line'> <span class="nt">"next_setting"</span><span class="p">:</span> <span class="s2">"18:00:31 29-10-2013"</span>
|
||||
</span><span class='line'> <span class="p">}</span>
|
||||
</span><span class='line'><span class="p">}</span>
|
||||
</span></code></pre></td></tr></table></div></figure>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue