home-assistant.io/source/developers/multiple_instances.markdown
KAMAL AWASTHI 404815fae0 Fixed typos in some of the pages (#1270)
* Update architecture.markdown

* Update component_discovery.markdown

* Update development_validation.markdown

* Update frontend.markdown

* Update maintenance.markdown

* Update multiple_instances.markdown

* Update python_api.markdown

* Update releasing.markdown

* Update rest_api.markdown

* Update server_sent_events.markdown

* Update website.markdown
2016-10-20 11:29:37 +02:00

44 lines
1.4 KiB
Markdown

---
layout: page
title: "Multiple Instances"
description: "Quick primer on how multiple instances work together."
date: 2016-04-16 14:24 -07:00
sidebar: true
comments: false
sharing: true
footer: true
---
Home Assistant supports running multiple synchronised instances using a master-slave model. Whenever `events.fire` or `states.set` 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 class='img'>
<a href='/images/architecture/architecture-remote.png'>
<img src='/images/architecture/architecture-remote.png' />
</a>
Overview of the Home Assistant architecture for multiple devices.
</p>
A slave instance can be started with the following code and has the same support for components as a master instance.
```python
import homeassistant.remote as remote
import homeassistant.bootstrap as bootstrap
# Location of the Master API: host, password, port.
# Password and port are optional.
remote_api = remote.API("127.0.0.1", "password", 8124)
# Initialize slave
hass = remote.HomeAssistant(remote_api)
# To add an interface to the slave on localhost:8123
bootstrap.setup_component(hass, 'frontend')
hass.start()
hass.block_till_stopped()
```
<p class='note'>
Because each slave maintains its own Service Registry it is possible to have multiple slaves respond to one service call.
</p>