Two HA instances - how to communicate between them?

Hey all,

This is probably a stupid questions but how do I get two Home Assistant instances to talk to each other? I have my main instance as a VM, which works great. I want to add another on a Pi for my z-wave “hub” if you will. I need the main instance to receive states from the z-wave instance, and also be able to send commands to the z-wave instance to control things.

I’ve read a bit about MQTT but still don’t really know what it is, how it works, or even if that’s what I want. It also seems like you need some type of cloud broker which I absolutely don’t want. All control needs to stay local. I also found this but it says it’s depreciated: https://home-assistant.io/developers/multiple_instances/

Is this even possible? And if so how does one go about setting it up?

Thanks!

Dan

MQTT is the way I do it. I have a Hass.io instance in my bedroom controlling all other devices, and I installed Home Assistant on my Retropie unit so I can execute custom python code for Switchmate devices. I communicate via MQTT (where the Brokeris the Hass.io add on) and the Retropie connects to it.

It was daunting at first for me but if you take time to understand it, it’s super simple and straightforward.

Heh, daunting is an understatement, I still don’t understand even where to start. Do you have a guide of some sort that you used? I mean, I see that you can turn on an embeded instance with:

mqtt:

But then what? Do I do that on both? How do they talk? Do I have to setup something on both for a two-way communication? I’m totally lost as to what I’m supposed to do with it.

Is it Hass.io?

No, both are installed on-top of Debian/Raspbian.

If you’ve got 2 you need to communicate, then using MQTT and either MQTT statestream or MQTT eventstream (or both).

Statestream is likely what you’ll want.

2 Likes

@Tinkerer - So that appears to be one way, as in pushing state changes from the z-wave instance to the main instance. But how do I push the other way? I need to be able to control the z-wave devices on that instance from the main instance.

Furthermore, I’m still unclear what to do with MQTT other than turn on the embedded instance. Nor what needs done on both sides.

So maybe the better question, after doing an:

mqtt:

On each instance then what? Is that even the right thing to do?

You have to configure one MQTT server (either side, doesn’t matter) and configure both Home Assistant systems to use it for MQTT statestream. As long as you ensure that entity names are unique across systems you’ll have no problems.

If you can’t ensure that, you’ll need to use MQTT eventstream.

So on the one side I just…point it to itself? And the other side points to the first one? So this:

mqtt:
  broker: 127.0.0.1

Then the other side

mqtt:
  broker: 192.168.9.200

The names will be unique so that won’t be an issue.

Only use broker: 127.0.0.1 if you’re running Mosquitto. If you want to use the built in broker, just use mqtt:

So one side is just the mqtt: and the other points to the first side for it’s broker? And that’s it?

there are 2 ways you can “communicate” between 2 instances from hass.

  1. let both instances communicate with 1 hub or file or mqtt server.
    see that as 2 people updating 1 document online. both can look at it through a browser, change things, add things, and both see what the other does.
  2. use api from 1 hass instance to update the other. for some devices it is inpossible to connect to them with several hass instances. then you can create a sensor, switch or something in 1 hass instance that reads the value from the other instance and updates the other instance.

so option 1 is like:

device > file/mqtt server/hub > hass 1
device > file/mqtt server/hub > hass 2

option 2 is like:

device > hass 1 > hass 2

Pretty much. Obviously you then need to add the MQTT statestream configuration, but that should be it.

Hi,

I have the below configuration on the HASSIo (on a PI3) instance that has the (zwave stick) value to pass to the other HASSIO (on a NUC)
On the other instance how would I do this?

mqtt_statestream:
  base_topic: homeassistant
  include:
    domains:
      - sensor
      - binary_sensor
      - switch
      - zwave
    entities:
     ########### node 2 ENTRANCE
      - sensor.neo_coolcam_battery_powered_pir_sensor_luminance # node 2
      - binary_sensor.neo_coolcam_battery_powered_pir_sensor_sensor
      - zwave.neo_coolcam_battery_powered_pir_sensor

You need to add every single mqtt switch, sensor, binary_sensor, zwave entity to your master HA.

A post was split to a new topic: HomeKit, CBUS, MQTT, and loads of lights

did u get it working?

If you’re wanting to link two instances that can communicate with each other, look at this custom component.

1 Like