I don’t know about you, but every once in a while the server running my HomeAssistant container will crash (even if it is my own fault as I tinker with things remotely ). Unfortunately when it happens, it can often take out other services as well, even ssh access. This led me in search of another way to reboot the machine from a remote location.
The solution I came up with is the Shelly Uni. This handy little device offers a wide range of operational voltage, several inputs, and - most importantly for my use case - 2 controllable relay outputs. By wiring these two relays to the Power and Reset pins on the motherboard of the server (an ITX desktop build), I can essentially now “press” these buttons from anywhere in the world. (Operation of the physical buttons is maintained by the use of “Y” harnesses I fabricated for the project)
I chose to power the Uni from a 12v A/C adapter I had laying around, thereby keeping the device completely separate from the machine it lives inside of. Remote access is accomplished over VPN in my case, though it could also easily be done using Shelly’s cloud service; either way keeping the device secure and eliminating any need for port forwarding. Additionally, connecting its ADC input to something with switched power (an extra PCIe or Fan connector), allows you to remotely monitor the power state of an otherwise unresponsive server. A small 3D printed box I made provides it a nice little home within the server.
While I realize that this project isn’t exactly integrated into HomeAssistant, it’s definitely given me a little extra piece of mind about my instance. A system glitch, or loss & restoration of power, while we’re all away is no longer an issue for our home.
Hopefully someone else out there finds this useful as well
Personally i don’t like a hard reset, as it might corrupt the OS…
But i agree, it can be used as a last resort…
Is the server completely frozen , or does it still respond to some commands?
Maybe it is possible to initiate a remote shutdown from another device??
but i guess you already explored this
For what I read you are cutting power or? If that is the case then it is not a clean reboot with other consequences (see multiple cases on corrupted db 's). If it is indeed just a power cut, then why not use a cheap/easier wall-plug? e.g. one from HUE that you can AND control remote AND from HA
My HA server runs as a Virtual Machine using KVM hypervisor for Linux so this gives me control of my instance should I need to reboot it remotely since I can do this from an SSH login to the Linux hypervisor.
Linux running as a hypervisor is extremely stable, no reason one should loose access to the hypervisor and running HA as a VM gives me a lot of other benefits…the biggest is being able to take snapshots so I can revert back to a known working instance should I do something to mess up my HA config.
As one last precaution, I did configure my ROM to boot up on power should I for some reason shutdown the hypervisor instead of rebooting it, then just grabbed a cloud controlled smart plug that I can power cycle remotely.
I certainly understand the concerns over a hard reset, and you’re right, this setup is definitely not for maintenance or routine reboots. Those jobs are best handled using HomeAssistant’s “Restart Server” button, or ssh commands that allow the containers to be stopped properly. Rather, this setup is intended to provide a means of remote server reboot when all other hope (and normal communication) is lost.
Also, if the home loses and regains power, the network will restart without intervention - however this server will not until the Power button is pressed. This gives me a way to do that
Understood, my home/area sees occasional power cuts (<10 / year) and my NUC starts automatically when power comes on which indeed does not always apply to all devices. My main issue with these cases is my router which does come online but sometimes too early and then the connection with fiber is not restored…try to repair that when being remote
Speed is great when it works 5400-450Mb…and really, just two minutes after I posted above…a 15 min power cut …luckily still no damage but aforementioned issue occurred. Since I cannot control the router (it is from the provider), I am thinking of setting up a powerplug that HA can control.