Connecting two home assistants

I have a master instance of home assistant running on Ubuntu and another instance running on a raspberry pi that is used to control my garage doors.

I’d like to connect these together so I could control everything in one place, but have been unsuccessful so far. I’ve tried the master/slave setup found here and in a few posts with no luck. I’ve read some about using mqtt to talk between the two instances but have not found examples complete enough to put this together.

Is there anyone out there that has two instances talking that could share your config with me?

1 Like

I used the Eventstream Component to connect using MQTT. This works OK but sensors only show for short period.
I am currently looking for a better method.

I have HA running on RPi and inside docker container.
I use a seperate MQTT broker to ensure broker availability.(if it runs on HA server connections problems happen when rebooting)

I can share component and broker config details later.

Thanks,

I have a Mqtt broker running for my smart things bridge, so I think I’m good there. Seeing how you configured the mqtt components between the two instances would be great.

Synology Docker install is master with below in config

mqtt:
  broker: 10.17.134.96
  port: 1883
  client_id: HAmaster
  keepalive: 60
  #username: notused
  #password: notused
  #protocol: 3.1.1

mqtt_eventstream:
  publish_topic: HAmaster_eventstream
  subscribe_topic: HAslave_eventstream

Raspberry Pi is slave with below in config:

mqtt:
  broker: 10.17.134.96
  port: 1883
  client_id: HAmaster
  keepalive: 60
  #username: notused
  #password: notused
  #protocol: 3.1.1

mqtt_eventstream:
  publish_topic: HAslave_eventstream

I found that when I brought up the web interface, my motion and door contacts connected to GPIO on Raspberry pi didn’t show. Same for 1wire temp sensor. Motion/Door sensors only show after being tripped and would disappear afer about 5-10minutes if no change. This is good enough for automation but not idea for checking status or history.
I decided to use Template Sensor to make eventstream sensors persistant. I named Template Sensor on Synology, same as eventstream sensor coming from RasPI.

Sensor on RasPi:

- platform: rpi_gpio
  ports:
    18: Living Room Motion
    5: Mya Room Motion
  pull_mode: "UP"
  bouncetime: 50

Sensor on Synology:

- platform: template
  sensors:
    ###################### LIVING ROOM MOTION #############################  
living_room_motion:
      value_template: >-
        {% if is_state("binary_sensor.living_room_motion", "off") %}
        off
        {% elif is_state("binary_sensor.living_room_motion", "on") %}
        on
        {% endif %}
      friendly_name: 'Living Room Motion'
      sensor_class: motion
      entity_id:
        - binary_sensor.living_room_motion
    ######################### ROOM MOTION #############################    
    room_motion:
      value_template: >-
        {% if is_state("binary_sensor.room_motion", "off") %}
        off
        {% elif is_state("binary_sensor.room_motion", "on") %}
        on
        {% endif %}
      #friendly_name: 'Room Motion'
      #sensor_class: motion 
      entity_id:
        - binary_sensor.room_motion  

you will notice Friendly name and sensor class commented out for second sensor. I previously set these sensors up in customize.yaml and friendly name is passed from RasPi, so I decided to verify if that would be enough. It was. It is slightly cleaner to add this on template sensor but I preferred the icons i used for motions

NOTE:
I did not intend to name sensors on both RasPi and Synology the same. After trying to get it work other ways I found out by accident that this works and was kind of nice. I am not sure if this is idea or correct so I am currenly looking to verify that .

3 Likes

Hi @tmjpugh,

can you tell me a little bit more about your mqtt broker setup.
Do you have another docker container running the broker?

Thank Killsystem

Yes. I have mosquito running in seperate docker container.

HA has mosquito included but I constantly reboot HA server(testing and playing) and wanted MQTT to run independent…