Connect two instances of HASS together

Hi,

I would like to install two instances of Home Assistant at two different locations, one at home (already installed) and one at my cottage (yet to be installed). They are at two separate locations, using different Internet providers. I want to use only one app on my phone to be able to access and control both locations. Before I invest too much time, I want to know if this is possible. I looked at the Master/Slave configuration, but that’s not really what I need and the config has been deprecated anyway. There is also the MQTT Eventstream configuration. Would that work? Has anyone done it successfully? Can you share your configuration?

Thanks!

it depends on the type of communication / integration that you want both instances to have.
If you only want to have entities of both instances showing up in a single front end (and potentially some basic automation), I would probably use MQTT to send the state of ‘cottage’ to ‘home’ and potentially vice versa.
I don’t have such a setup but I have a pi running sensors (mainly PIRs) and I have a custom script that I use to send the status to HA. Because it’s so trivial I just make calls to the HA API:

if you’re interested, I can share the python function I use. let me know

Looking at this again, it seems the REST API is my easiest solution. I wish there would be a component to be able to do this easily. I will take on your offer if you want to share you configuration. That would probably help me quite a bit. Thanks a lot!

try this python script:

#!/usr/bin/python
# -*- coding: utf-8 -*-


import datetime
import json, requests, simplejson


# This is the function definition to change the state of an entity in HA
def HASS_API_State(Device_Id, Value, Unit):
	url = "https://homeassistant_address/api/states/" + str(Device_Id) + "?api_password=secret_password" 
	data={"state":"" + str(Value) + "", "attributes": {"unit_of_measurement": "" + str(Unit) + ""}}
	headers = {'Content-type':'application/json', 'Accept-Encoding': 'text/plain', 'Accept': 'text/plain'}
	r = requests.post(url, data=json.dumps(data), headers=headers)
	c = r.content
	result = simplejson.loads(c)
	#print result



# This would be the bit that you call to update the state by calling above function.
# I have a loop that checks the status of my Raspberry Pi GPIO Ports and calls the function to update HA when one port changes.
# Amend as you please to cater for your needs.

try:
	HASS_API_State("sensor.Temp_Lounge",20,"C")
except:
	print "%s - Can't access HASS!" % datetime.datetime.now().strftime("%d/%m/%y %H:%M")
	pass

1 Like