Site updated at 2016-08-22 08:21:42 UTC
This commit is contained in:
parent
f9d65cbe57
commit
4acb07bf8e
559 changed files with 18878 additions and 21688 deletions
|
@ -89,7 +89,7 @@
|
|||
<hr class="divider">
|
||||
|
||||
|
||||
<p>Home Assistant supports running multiple synchronized instances using a master-slave model. Whenever <code>events.fire</code> or <code>states.set</code> is called on the slave it will forward it to the master. The master will replicate all events and changed states to its slaves.</p>
|
||||
<p>Home Assistant supports running multiple synchronized instances using a master-slave model. Whenever <code class="highlighter-rouge">events.fire</code> or <code class="highlighter-rouge">states.set</code> is called on the slave it will forward it to the master. The master will replicate all events and changed states to its slaves.</p>
|
||||
|
||||
<p class="img">
|
||||
<a href="/images/architecture/architecture-remote.png">
|
||||
|
@ -100,24 +100,22 @@
|
|||
|
||||
<p>A slave instance can be started with the following code and has the same support for components as a master instance.</p>
|
||||
|
||||
<div class="highlighter-coderay"><div class="CodeRay">
|
||||
<div class="code"><pre><span class="keyword">import</span> <span class="include">homeassistant.remote</span> <span class="keyword">as</span> remote
|
||||
<span class="keyword">import</span> <span class="include">homeassistant.bootstrap</span> <span class="keyword">as</span> bootstrap
|
||||
<div class="language-python highlighter-rouge"><pre class="highlight"><code><span class="kn">import</span> <span class="nn">homeassistant.remote</span> <span class="kn">as</span> <span class="nn">remote</span>
|
||||
<span class="kn">import</span> <span class="nn">homeassistant.bootstrap</span> <span class="kn">as</span> <span class="nn">bootstrap</span>
|
||||
|
||||
<span class="comment"># Location of the Master API: host, password, port.</span>
|
||||
<span class="comment"># Password and port are optional.</span>
|
||||
remote_api = remote.API(<span class="string"><span class="delimiter">"</span><span class="content">127.0.0.1</span><span class="delimiter">"</span></span>, <span class="string"><span class="delimiter">"</span><span class="content">password</span><span class="delimiter">"</span></span>, <span class="integer">8124</span>)
|
||||
<span class="c"># Location of the Master API: host, password, port.</span>
|
||||
<span class="c"># Password and port are optional.</span>
|
||||
<span class="n">remote_api</span> <span class="o">=</span> <span class="n">remote</span><span class="o">.</span><span class="n">API</span><span class="p">(</span><span class="s">"127.0.0.1"</span><span class="p">,</span> <span class="s">"password"</span><span class="p">,</span> <span class="mi">8124</span><span class="p">)</span>
|
||||
|
||||
<span class="comment"># Initialize slave</span>
|
||||
hass = remote.HomeAssistant(remote_api)
|
||||
<span class="c"># Initialize slave</span>
|
||||
<span class="n">hass</span> <span class="o">=</span> <span class="n">remote</span><span class="o">.</span><span class="n">HomeAssistant</span><span class="p">(</span><span class="n">remote_api</span><span class="p">)</span>
|
||||
|
||||
<span class="comment"># To add an interface to the slave on localhost:8123</span>
|
||||
bootstrap.setup_component(hass, <span class="string"><span class="delimiter">'</span><span class="content">frontend</span><span class="delimiter">'</span></span>)
|
||||
<span class="c"># To add an interface to the slave on localhost:8123</span>
|
||||
<span class="n">bootstrap</span><span class="o">.</span><span class="n">setup_component</span><span class="p">(</span><span class="n">hass</span><span class="p">,</span> <span class="s">'frontend'</span><span class="p">)</span>
|
||||
|
||||
hass.start()
|
||||
hass.block_till_stopped()
|
||||
</pre></div>
|
||||
</div>
|
||||
<span class="n">hass</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
|
||||
<span class="n">hass</span><span class="o">.</span><span class="n">block_till_stopped</span><span class="p">()</span>
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<p class="note">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue