Using MQTT to link two home assistant instances together

Hi guys,

I have two instances of home assistance running, one in my house, and one in my barn (could not figure out how to extend z-wave coverage all the way across the yard). I’m now trying to figure out a way to connect the two in a reasonable manner. Ideally I do not want to use the interface for the barn installation at all. I have around seven switches configured and a couple of temperature sensors.

I know I can use state stream to replicate the data reported by any device in the barn to the house system, but this approach does not seem to allow control the other way. I know there is something called MQTT event stream, but I haven’t been able to find much text around this to help me figure out how to use it correctly.

Ideally I want a set up where any state change in the barn is published with retain to the MQTT broker (probably already covered by state stream), and at the same time I want to be able to control these devices from the house installation.

I was thinking that the easiest would be to define MQTT lights in the house installation, but I would then need something on the barn side to both publish and consume information from the correct topics, and I do not think state stream does this. I guess the difficult part is taking incoming MQTT events and triggering actions on my switches in the barn. I would prefer not to have to write a specific automation for each device.

I hope I made myself clear.

Any suggestions?

1 Like

I use Mqtt statestream. It takes a bit of work to set up but works very well now. I do have automations that connect the two.

Also make sure you create another mqtt user for the second HA instance. I didn’t and was about ready to throw it in the bin until I realised that was my issue (mqtt would randomly miss changes).

Let my hijack this thread - I have just open a pull request that provides an alternative to mqtt_statestream / mqtt_eventstream, which uses the Websocket APIs directly. This should provide a reasonable solution to your use case.

I would be happy to hear your feedback if you try it out, the code is available here: https://github.com/home-assistant/home-assistant/pull/13876

1 Like

This looks very promising, exactly what I have been waiting for. Hope you get the pull request approved.

Dude, I’m putting a second Hass.io into my shed for bluetooth and better z-wave coverage. I’m not used to github. Was your project acceped? When or how can we test?

Thanks