Site updated at 2016-02-22 15:17:46 UTC

This commit is contained in:
Travis CI 2016-02-22 15:17:46 +00:00
parent c3ae07fc4d
commit f390b84e87
15 changed files with 186 additions and 186 deletions

View file

@ -113,20 +113,20 @@
<hr class="divider">
<p>This is a simple hello world example to show the basics of registering a service. To use this example, create the file <code>&lt;config dir&gt;/custom_components/hello_service.py</code> and copy the below example code.</p>
<p>This is a simple hello world example to show the basics of registering a service. To use this example, create the file <code>&lt;config dir&gt;/custom_components/hello_service.py</code> and copy the below example code.</p>
<p>Services can be called from automation and from the service developer tools in the frontend.</p>
<p>Services can be called from automation and from the service “Developer tools” in the frontend.</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre><span class="comment"># The domain of your component. Should be equal to the name of your component</span>
DOMAIN = <span class="string"><span class="delimiter">&quot;</span><span class="content">hello_service</span><span class="delimiter">&quot;</span></span>
<div class="code"><pre><span class="comment"># The domain of your component. Should be equal to the name of your component.</span>
DOMAIN = <span class="string"><span class="delimiter">'</span><span class="content">hello_service</span><span class="delimiter">'</span></span>
ATTR_NAME = <span class="string"><span class="delimiter">'</span><span class="content">name</span><span class="delimiter">'</span></span>
DEFAULT_NAME = <span class="string"><span class="delimiter">'</span><span class="content">World</span><span class="delimiter">'</span></span>
<span class="keyword">def</span> <span class="function">setup</span>(hass, config):
<span class="docstring"><span class="delimiter">&quot;&quot;&quot;</span><span class="content"> Setup is called when Home Assistant is loading our component. </span><span class="delimiter">&quot;&quot;&quot;</span></span>
<span class="docstring"><span class="delimiter">&quot;&quot;&quot;</span><span class="content">Setup is called when Home Assistant is loading our component.</span><span class="delimiter">&quot;&quot;&quot;</span></span>
<span class="keyword">def</span> <span class="function">handle_hello</span>(call):
name = call.data.get(ATTR_NAME, DEFAULT_NAME)
@ -135,7 +135,7 @@ DEFAULT_NAME = <span class="string"><span class="delimiter">'</span><span class=
hass.services.register(DOMAIN, <span class="string"><span class="delimiter">'</span><span class="content">hello</span><span class="delimiter">'</span></span>, handle_hello)
<span class="comment"># return boolean to indicate that initialization was successful</span>
<span class="comment"># Return boolean to indicate that initialization was successfully.</span>
<span class="keyword">return</span> <span class="predefined-constant">True</span>
</pre></div>
</div>