[Tutorial] Self-Healing Hubs

I've got a few hubs. Sometimes, during development, things go awry when I least expect it, and when that happens, I canā€™t have the household complaining that their lights didnā€™t fade up in the morning because a hub crashed :wink:

For normal users, you shouldnā€™t need to do anything like this. But, for power users, hereā€™s a multi-hub setup I use to keep my hubs online and reset when 500 errors occur.

Hereā€™s the summary of how it works:
(House hub) Sends an event to the other hub every minute to say that it can read its DB
(Backup hub) Reboots other hub if no response was received in the last 6 minutes

My backup hub has two switches:

  1. Is written to (via the maker API) every minute as a ā€˜health checkā€™.
  2. (Momentary: 5s) Is written to when the House Hub has rebooted.

My house hub has a Rule that sends an Off event every minute to the Health check switch, and an On event to the Momentary switch. This is all that needs to run on this hub

On the Backup hub, two rules exist:

  1. (Every 6 minutes) : If (Health Check is On >> Send reboot to other hub. Pause rule.) else( Turn health check on)
  2. (When Momentary switch is turned on) If (other rule is paused >> resume)

This keeps my hub alive, and I figured other people may find a good use for this :slight_smile:

I have an idea of how this could be implemented in a 1-hub setup, but havenā€™t gotten around to testing that yet.

7 Likes

If anyone would like to test my 1-Hub version of this, shoot me a DM! :cowboy_hat_face:

2 Likes

For those who were keeping tabs on this post, read more about self-healing your hubs on one hub here:

1 Like

This is interesting...

1 Like