I run HA on a virtual machine. Is there a decent way to set up a hardware failover? For instance if the home assitance machine is down for more than 5 minutes, a raspi with home assistant will start up and take over? I am considering it for use when I am not home in case something happens.
You can use nginx. Not sure about actual config but you can try below link. It pretty much what I had in mind.
For sensors, mqtt or web switches this is ok…but you cannot failover zwave controller or other devices that use HA host as hub (not with nginx at least)
https://gist.github.com/ZoidQC/20b234cec147a4413117b929302d95b7
Just to be clear, than i would have to run a WEB-server (Nginx) to do this? Not sure if I have the machines for that. I have 2 servers, one with several virtual machines. But that is the one iwth HA, if that somehow fails, I wouldn’t want Nginx to be running on that one, and the second is just running regular windows server.
You can run second HA instance on separate IP and have it exposed as required and simply not use nginx. Pretty much same as above
I was thinking of failover accessible at same external web address but you could just run second instance. Hubs still cannot fail over. The windows server or a RasPi can host second instance
fail likely hood is low. Hardware fail is likely only reason for this need. In this case maybe best to plan for that case. Honestly the RasPi may fail before server and be down when finally needed.
I think you are right, software failure is much more likely, but it has happend to me with home assistant. But if i run a second instance, won’t a risk both instances working “over eachother”? I don’t want both instances to send signals to lights, switches and so on. And ideally it shouldn’t do anything while idle, because, as you mention, I don’t want the pi to fail. But i don’t know how to easiest detect a failure, and then shut down the (or disable) virtual machine and start the raspi
Sensor only display and retrieve so no
Switches require command be sent so no
Automations probably should be avoided in 2nd instance and only critical items.
So you could run a script that monitors first instance and performs actions when no connection>Xminutes
Reboot HA via ssh + notify result
Wait and test
Reboot server via ssh + notify result
Wait and test
Bring up instance_backup + notify result
If HA is not controlling critical items this may be big waste for small benefit
My worst case is I’m out of town and HA goes down and exterior lights not turn ON. This is not critical so I have no countermeasure against it. Even this case I can likely login if I care to and check it unless Power Outage or HDD fail/server down
I fail to see how that would work? For it to be even remotely functional you need automation like “when switch A is pressed, turn on light B”.
The SSH-idea isn’t to bad, is it possible to turn off HA also via SSH?
I am more considered if I am not available, and someone else is in the house.
if you are starting HA_backup after HA_main is down, automations are possible.
if you have 2 HA instances performing same automation based on an input you will get double trigger.
RECOMMENDATION 1
have an HA instace that functions as backup with basic functions available.
This can be started by a script or be a live failover using NGINX or other method
RECOMMENDATION 2
fully functing backup server (minus hubs) that performs all actions including automations
This requires main instance to be verified down to prevent double trigger
Yes, you can have scripts do actions over ssh, included shutdown HA. any command line action is available as well as possibility of bash/python scripts may be created and run
You may also use javascript to make a basic webpage that performs actions on the backup server or the main HA server or runs the bash/python scripts
QUESTION
Do you need full function when HA_main is down or will basic function be enough
I guess I only need basic functions, but things like light switches turning on lights is a pretty basic function I would say, so i need automations.