Using ESPhome to detect if a computer is on

I have a server running Blue Iris at a remote office. For some reason, it sometimes shuts off, or is shut off, randomly. Id like to build an ESPhome device that monitors the computer, knows when its shut off, then triggers a relay that I’ll tap into the power button wires to turn the computer on.

Any ideas on how to monitor that the computer is turned on? If it helps, the computer is set to never sleep.

Hi

Well you don’t need an ESP to report the state as it exists some softwares you can install on the computer that repots at HA. I have one running here on my desktop linux that is GitHub - hjelev/rpi-mqtt-monitor: Raspberry Pi MQTT Monitor gathers system information and sends it to a MQTT server. (I work on Linux) and I’m quite sure something equivalent for windows if needed :wink:
If it’s a proper server hardware doesn’t it have IPMI ? IPMI have some API that allowr lot of things including power on/off, soft reboot…

Vincèn

It’s not a proper server, just a Windows 10 machine running Blue Iris.

I don’t have a Home Assistant installation at the remote location. I was hoping to just have a stand-alone ESP device installed on the computer that would detect the computer shut down then turn it back on.

Huh??
What is in the remote location?
Is the server in the remote office on the Internet?

Install the free Pulseway client on your PC and mobile. https://www.pulseway.com/

Sign up and set an alert to notify you if the PC goes offline.

You can send Wake on LAN over the internet to turn your PC on.

Are you sure that it’s not someone pulling out the power cord to use the power outlet for something else? E.g. a vacuum cleaner?

Happened to me once at university (long ago) where some “ordinary” looking PCs where located in an otherwise empty (small) office. But they were servers which ran 24/7.

You can most likely use a USB cable in one of the USB ports and have a voltage divider so that the EAP can sense ot safely.
I have this on my son’s TV and it works fine.
Not sure though how this should trigger the smart plug.
But you could have a ESP-Home flashed smart plug and just a couple of wires to the USB port on the computer.

1 Like

A smart plug with power monitoring can be used to track the current draw—if it drops to 0A, the PC is off, triggering a power-on action. Another approach is using a USB-connected ESP; if it becomes unavailable, it indicates the PC is off and needs to be turned on. Alternatively, a network-based tracker can ping the PC’s IP address to determine its status. Once any of these detection methods is set up, a small relay module connected to an ESP can be used to simulate a power button press and turn the PC on.

1 Like

The smart plug with power monitoring initially sounds like half the solution. But there’s some things to be mindful of there though that make me more hesitant.

It could reset/restart itself, so it could interrupt power to the server. Especially without (but even after) proper configuration. They also tend to be hard / illegal to break out extra gpios from for extra kit like relays. And you’re dealing with the high voltage side. These devices are also notoriously unreliable and prone to failure.

I’m liking the idea of monitoring the power via one of it’s usb ports. That way you’re just dealing with low voltage.
Power the esp separately via wall wart. Add your relay button press kit. Build the whole thing so it works locally offline (although that makes it hard to test /debug).

That’s all assuming you only need to do hard reset via your button press and don’t need to actually switch power from the wall.

Disclaimer: I’m by no means advanced on these areas so take my thoughts with a pinch of salt.

Edit: Hmm thinking more about it maybe monitoring the usb power isn’t going to tell you if it is “shut-off”…

I think smart plug with power monitoring is a good approach. Ive been using several for 4 1/2 years and no problem. I use tasmota on them. Its uptime will tell HA if power had failed to the socket or has been unplugged. The button on it will report if its been switched off by hand. You can restart it from HA using automation.
Have you suspicion its being deliberately turned off?

Yes it will, when a the pc is turned off the voltage of the usb will drop from 5v to 0v, you can test it with your phone charger.

First, is the computer OFF or sleeping? You need to determine HOW it is turning off. The reason will determine the fix. Do people at the remote office just notice the computer is off and they press the power button? Is there some kind of power interruption overnight?

Is the BIOS power-on state set to restart after a power fail?

1 Like

Yeah I think I’m unclear if the symptom /issue is power is totally off or if the os is down.

Possibly different approaches to monitoring/ fixing it.

The suggestion from op that they would reboot via power push-button suggests the latter to me.

I think there is no HA.

Not necessarily. Some can still provide power for charging devices, there’s usually a BIOS setting to enable/disable this functionality.

1 Like


No Ha.

What about esphome with wireguard back to HA in another location?

1 Like

Most modern PCs can be turned on by an USB device too.
Check the BIOS settings.

And most modern PC’s have 5V on the USB ports whether the PC is off or on.

It can usually be adjusted in the BIOS too.

It’s usually all or none.

The OP is not explaining his problem well enough. If he doesn’t know why the PC is powering down then any solution might make the situation worse.