Multiple Instances - Why so difficult?

Is it just me or does it appear that support for multiple instances is lacking? The docs are severely lacking in detail and the few references I can find online do not seem to work.

I have 2 instances of HA (0.39.2) running on separate RPi3s. The slave instance will run fine when started via systemctl, but doesn’t work when configured according to the docs. The closest I have gotten is when configuring with the info found here… https://michaelkuty.com/howto/hass-slaves/

When I start the slave instance using the code from that post, the instance will stay running and the following is output to the logs…

DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.180
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.1.180:8123 "GET /api/ HTTP/1.1" 200 27
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 192.168.1.180
DEBUG:requests.packages.urllib3.connectionpool:http://192.168.1.180:8123 "GET /api/states HTTP/1.1" 200 4878

Slave IP ends in 181 and 180 is the master instance.

However, I am unable to get the frontend component working on the slave instance (for monitoring) and none of the events are being passed to my master instance.

Are there any better resources for getting a slave instance running on the current version of HA?

1 Like

Upon further investigation, I figured out the debug output from my original post is generated when the following line is called.

hass = remote.HomeAssistant(remote_api)

The script appears to be hanging there and does not proceed to the calls to setup_component further down in the script.

Anybody know what would cause this?

Edit: I believe this issue is the cause of my troubles: https://github.com/home-assistant/home-assistant/issues/3990#issuecomment-284143204

I had the same problem last time I tried, see here Master/slave configuration not working.

There is a link to an issue on github which explains why the slave instance isn’t working

I struggled with this for a few days too. I got really close by playing with the REST API directly, but ended up just taking the advice from Reddit and using MQTT event forwarding to do multiple instances. It’s been working pretty well.

Do you have a link to an example of how you setup the event forwarding? My use case requires 2 slave instances to send events to a master instance. If you are using eventstream then it is limited to just one slave… right?

I just used the example listed in the MQTT_Eventstream. Theoretically (at least to me) you should be able to set up multiple slaves on the same publish topic, then have them all listen for the master. the slaves won’t talk to each other, but the master should republish events it receives from the slaves.

Replied via email, but it didn’t show up here.

The docs aren’t very detailed. Do you know if it supports specifying a sub topic for the slaves to publish like slaves/slave1? Then simply subscribe to parent topic slaves on the master instance?

On your configuration how do the events show up for use in rules?

I believe I have found a possible solution to running multiple slaves when using mqtt_eventstream. I will post my config once I have confirmed it works as expected.

How is it working for you?

It is working pretty well.

You can check out my config here. There is a branch for the master controller and one for each of my 2 door controllers. You can see in the main config file how I subscribe to the multiple slave instances and how each slave publishes to the master instance using MQTT Eventstream.

The biggest issue I’m still trying to figure out is state persistence in the GUI. HA doesn’t know the state of the remote sensors until a message is published, but after some time, it seems to forget the state for some reason. The slave sensors just disappear from the master instance interface, but haven’t figured out why. This would likely cause the remote sensor value to be unusable as a rule condition on the master instance, but I haven’t verified. I’m only responding to state changes from the slave instances, so current state being available doesn’t really impact my use case. If the sensors updated on a regular interval, this would likely not be an issue either.

1 Like

I have been struggling with the same issue. I am thinking of setting up the slave with eventstream and then put the wanted sensors / switches in the master config manually using MQTT switch / MQTT sensor. This should prevent them from disappearing. I will use a MQTT client to view the messages and topics from eventstream so i can config the master properly.

I thought about doing the same. If it does work, I hate that it requires duplication of config between the instances. Please let me know if you have success with it.

The problem I have is eventstream puts the mqtt in a json while the MQTT switch / sensor don’t use json I don’t think. Another idea is to leave eventstream as is and mimic the mqtt messages that occur on slave restart at a certain interval to keep the mqtt eventstream sensors / switches alive.

In topic: /slaves/upstairs

{
  "event_type": "state_changed",
  "event_data": {
    "old_state": {
      "last_updated": "2017-05-06T03:06:37.872691+00:00",
      "attributes": {
        "last_triggered": "2017-05-06T03:06:37.872631+00:00",
        "friendly_name": "automation 30"
      },
      "entity_id": "automation.automation_30",
      "last_changed": "2017-05-05T03:48:07.728592+00:00",
      "state": "on"
    },
    "new_state": {
      "last_updated": "2017-05-06T03:06:52.906043+00:00",
      "attributes": {
        "last_triggered": "2017-05-06T03:06:52.905983+00:00",
        "friendly_name": "automation 30"
      },
      "entity_id": "automation.automation_30",
      "last_changed": "2017-05-05T03:48:07.728592+00:00",
      "state": "on"
    },
    "entity_id": "automation.automation_30"
  }
}

EDIT:
This might be a method to extract the json to mqtt

1 Like

@RobDYI
did you find a solution to keeping remote sensors alive in Master Frontend GUI

No , I haven’t

Hi,

I’m trying to solve a similar problem. See my post here:

1 Like