Multiple Home Assistants watching each other?

Hi.
I am running HA on two computers in my home and I want to know the best way to setup for the following:

I have a problem where my main HA just stops running sometimes (Hass just stops sometimes - how do I find out why?).
I’ve now setup HA and a command_line sensor on my secondary, so I can run an automation when it sees that hass is no longer running (I tested this with turning on a switch, which worked fine).
I want the “restart if it crashed” action to work both ways - so each computer watches and fixes the other.

Since sometimes I do not want to instantly restart hass when it stops, I thought I’d make the secondary send me an iOS rich message with an option to restart it. I imagine I could get this to work by duplicating my notification settings in the secondary HA instance, but now I’m wondering if I can just link the instances…

Although, I know I can’t call an HA action on the remote computer if hass isn’t running.

Anyway, I’m wondering if anyone has any suggestions for how to set this up.
I’ve seen the doc at: https://home-assistant.io/developers/multiple_instances/ but it’s a developer doc and doesn’t talk about how to configure things.
Any suggestions are appreciated.

Use the eventstream component.
Uses mqtt to send messages.

You can have each HA instance publish heartbeat message every 15minutes or whatever you feel best.

Each instance can subscribe to message and show as sensor in frontend.

Why does HA stop? Curious?

Just periodically try to hit the rest api of the other home assistant and if it works then its good, if it fails then its down.

istall appdaemon on both machines.
crosslink the connections.
if appdaemon on device A doesnt find a connection with HA on device B, let it restart HA on device B.
and the other way around.

it is even possible to check if HA is down or the whole device is down and if the device is down and you have a controlable switch and a automated startup, you let appdaemon restart the other device.

you dont even need to have 2 HA running. could be 1 HA with 2 times appdaemon and if the device with HA is defective, let appdaemon start the backup HA on the other device.

Thanks for the replies, folks!

I added mqtt_eventstream and nearly everything from my main HA showed up in my secondary one… I wasn’t expecting that - nothing mentioned on https://home-assistant.io/components/mqtt_eventstream/ about it.
I’ve restarted a couple of times and now I only get a few extra sensors and an invalid config message…

I don’t need everything sent between them, so I’ll try with just MQTT messages as needed - that might be faster than the command_line sensors I’m using at the moment.

I’ll also try the REST API “ping” as that sounds neat too. I’d use sensor.rest I guess…
Although it takes a few minutes for hass to start up, which means the REST sensor might say the API is not responding, but the process is actually running, so the command_line sensor to check for the process is “more correct”.

I’ve got it working with command_line and automations (but I’m open to better ways). The thing that’s missing is user input between HA2 noticing that HA1 is down and restarting it. I don’t always want to restart.
What I might do is make HA2 visible at a public URL, so if I get a notice that HA1 is down, I can load HA2 and click the “restart HA1” script run button… or perhaps the notification could contain a link to a REST API action to run that script…

I posted a question about how to track this down - link in my original post in this thread. I have no idea!

(maybe a new topic, but…)

I’ve got a REST sensor checking if the API is running on the other HA instance, which works when it’s up, but when it’s down, I get Unable to fetch REST data in my log and the sensor doesn’t show up, which means it doesn’t have a value and I can’t use it in an automation. Is there a way to get this to show up as something, or do I need to use a template and is_state() or something?

Thanks for your input!

You can use a value template which says if sensor has a value, then state on, otherwise state off.

sensor:
  - platform: template
    sensors:
      glances:
        value_template: '{% if is_state("sensor.process_glances", "off") %}not running{% else %}running{% endif %}'
        friendly_name: 'Glances'

Right… this accounts for when the REST sensor doesn’t get setup… the template sensor still does exist.
Like this:

sensor:
  - platform: template
    sensors:
      rest_api:
        value_template: '{% if is_state("sensor.main_ha_running", "API running.") %}OK{% else %}Not running{% endif %}'
        friendly_name: 'Main HA API'

  - platform: rest
    resource: https://IPxxx/api/?api_password=xxx
    name: Main HA Running
    value_template: '{{ value_json.message }}'