esp32.diy

ESPHome PC Power Control with ESP32 and Home Assistant

Oct 16, 2026 · 6 min read

Intermediate 396 stars 30 forks Python MIT Updated 2026-01-04

Home Assistant dashboard showing the three PC power control cards: power toggle, power state indicator, and force power off.

TL;DR Wire an ESP8266 or ESP32 to your ATX motherboard's system-panel header to get remote power-on, graceful shutdown, and force-off controls inside Home Assistant. Unlike Wake-On-LAN, this works from any power state and requires no running operating system.
What you need
  • ESP8266 NodeMCU
  • ESP8266 or ESP32 board (any)
  • ATX motherboard with 2x5 system-panel header
  • Transistor Q1
  • Resistor R1
BoardESP8266 / ESP32
FrameworkESPHome
LanguageYAML / Python
LicenseMIT
Latest Releasev1.0.1 (Oct 2024)
Stars396

What You Will Build

This project turns a spare ESP8266 or ESP32 into a hardware-level PC power controller that integrates directly into Home Assistant. Once wired to your motherboard's ATX system-panel header, Home Assistant gains three controls: a short press to power the machine on or trigger a graceful OS shutdown, a long press to force power off, and a binary sensor that reports whether the PC is currently on or off — all without any software running on the PC itself.

This is a practical upgrade for anyone running a home lab, NAS, or shared workstation that needs to be switched on or off remotely. Wake-On-LAN is the common alternative, but it carries real limitations: no authentication (any device on the LAN can send a magic packet), no shutdown capability, and it does not work until the OS has run at least once to arm the WOL hardware. Forwarding WOL packets through a Docker-based Home Assistant setup adds further complexity. The ESP approach bypasses all of that by acting as a physical finger on the power button. It works from any power state — off, suspended, or hibernated — and is protected by Home Assistant's own user authorization.

NodeMCU ESP8266 board used in the build, mounted on a custom breakout for the ATX system-panel header.\2
NodeMCU ESP8266 board used in the build, mounted on a custom breakout for the ATX system-panel header.
Wiring schematic showing connections between the ESP, transistor Q1, resistor R1, and the ATX system-panel and USB 2.0 headers.\2
Wiring schematic showing connections between the ESP, transistor Q1, resistor R1, and the ATX system-panel and USB 2.0 headers.
DIY breakout PCB wired to the motherboard's system-panel header for the power button and reset pin connections.\2
DIY breakout PCB wired to the motherboard's system-panel header for the power button and reset pin connections.
ESP8266 board mounted on a PCI slot bracket at the rear of the PC case, powered from the internal ATX USB header.\2
ESP8266 board mounted on a PCI slot bracket at the rear of the PC case, powered from the internal ATX USB header.

What You Need

Hardware

Software

The KiCad schematic file is also included in the repository if you want to fabricate a dedicated breakout PCB for the system-panel header.

Typical use cases

NAS Remote Power

Power a home NAS on and off from Home Assistant without relying on Wake-On-LAN or leaving the machine running continuously.

Home Lab Management

Control lab servers and workstations remotely from any power state, including when the OS is fully off or unresponsive.

Secure WOL Replacement

Replace unauthenticated Wake-On-LAN with a Home Assistant-protected control that also supports graceful shutdown and force-off.

Automated Power Scheduling

Combine with Home Assistant automations to boot or shut down machines on a schedule or based on presence and time-of-day rules.

How It Works

The ESP uses two GPIO pins to interface with the motherboard:

Pin D1 — power status input. This pin connects through resistor R1 to the motherboard's reset-button header pin (J2 pin 7). When the line is high, the PC is on; when low, it is off. R1 limits current in case D1 is accidentally configured as an output, protecting both the ESP and the motherboard.

Pin D2 — power button output. This pin drives transistor Q1, which in turn pulls the motherboard's power-button line (J2 pin 6) low. A brief pulse produces a short press, which powers the PC on or triggers a graceful OS shutdown depending on current state. Holding the line low longer produces a long press, forcing power off. The transistor provides secure electrical isolation between the ESP's 3.3 V logic and the motherboard circuit.

Power for the NodeMCU comes from the ATX USB 2.0 header (J1 pin 1), which supplies a constant +5 V even when the PC is completely off. The ESP's onboard regulator steps this down to 3.3 V. All ATX header pins and ESP pins operate at 3.3 V.

Importantly, all button timing — the difference between a short press and a long press — is controlled inside the ESPHome firmware, not by Home Assistant scripts. This was an explicit fix introduced in the February 2022 update after timing from HA scripts proved unreliable.

Build and Flash

Connect the ESP to the ATX headers following the schematic in images/Schematic.png:

The front-panel power and reset buttons remain fully functional alongside the ESP — they are wired in parallel, not replaced.

Edit pc-power.yaml to set your platform and board values, then fill in secrets.yaml with your WiFi SSID and passwords.

# Clone the repository
git clone [email protected]:Erriez/ESPHomePCPowerControlHomeAssistant.git

# Set up a Python virtual environment
sudo apt install python3-virtualenv
virtualenv venv
source venv/bin/activate

# Install ESPHome
pip install esphome

# Optional: grant serial port access (then reboot)
sudo usermod -a -G dialout <USERNAME>

# Compile and upload via USB
esphome run pc-power.yaml

# Monitor logs
esphome logs pc-power.yaml

Once the device is running, future firmware updates can be pushed over WiFi using ESPHome's OTA feature — no need to open the PC case again. If OTA fails (for example, after a WiFi credentials change), fall back to USB or configure the ap fallback access point in the YAML file.

Home Assistant Setup

Add the ESP to Home Assistant through Configuration → Integrations → Add Integration → ESPHome. Enter the hostname or IP address of the ESP device and the API password from your secrets.yaml.

Then open your dashboard, click Edit Dashboard → RAW Configuration Editor, and add the following card configuration:

title: Home
views:
  - title: PC
    path: pc
    badges: []
    cards:
      - type: button
        entity: switch.pc_power_toggle
        show_name: true
      - type: button
        tap_action:
          action: none
        entity: binary_sensor.pc_power_state
        hold_action:
          action: none
      - type: button
        tap_action:
          action: toggle
        entity: switch.pc_hard_power_off
        show_state: false
        show_name: true
        show_icon: true

This adds three dashboard cards: switch.pc_power_toggle (short-press the power button), binary_sensor.pc_power_state (live on/off indicator), and switch.pc_hard_power_off (long-press force shutdown). Restart Home Assistant and the controls are ready to use.

Extend It and Know the Limits

Ideas to go further

Limitations to keep in mind

Verdict

ESPHome PC Power Control is a well-documented, hardware-level solution for anyone who needs reliable remote power management without depending on Wake-On-LAN or a running operating system. The ESPHome YAML approach keeps configuration minimal and OTA updates practical. The main trade-off is that it requires careful wiring to your motherboard's system-panel header, which makes it intermediate rather than beginner territory — but the schematic and photos in the repository make that step approachable.

Sources

github.comErriez/ESPHomePCPowerControlHomeAssistant — repository & README

Facts in this article come from the project's public README and GitHub metadata at the time of writing. Images belong to their respective owners and link back to the original source.