Skip to content

Home Assistant custom integration to power on and off a Windows PC using Wake-on-LAN and SSH shutdown. Real-time status updates and automation-friendly.

Notifications You must be signed in to change notification settings

Timman70/home-assistant-pc-power

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ–ฅ๏ธ PC Power Control โ€“ Home Assistant Integration

Control the power state of a Windows PC from Home Assistant using:

  • ๐Ÿ”Œ Wake-on-LAN to turn it on
  • ๐Ÿ”’ SSH to safely shut it down
  • โš™๏ธ Full configuration from the Home Assistant UI

๐Ÿ”ง Features

  • Turn on your PC using Wake-on-LAN
  • Turn off your PC over SSH with proper shutdown command
  • Status detection using ping
  • Works with Windows PCs (SSH server required)
  • Configure and edit PC settings directly from Home Assistant UI
  • Supports multiple PCs as separate entries
  • Prevents duplicates based on IP and MAC address

๐Ÿงฐ Installation

You can install this integration using either HACS (recommended) or manual setup.


โœ… Option 1: Install via HACS (Custom Repository)

  1. Open Home Assistant and go to HACS โ†’ Integrations.

  2. Click the โ‹ฎ menu (top right) โ†’ Custom repositories.

  3. Add this repository:

    https://github.com/Timman70/home-assistant-pc-power
    
  4. Set category to Integration, then click Add.

  5. Go back to HACS โ†’ Integrations, search for PC Power Control, and install it.

  6. Restart Home Assistant.

  7. Go to Settings โ†’ Devices & Services โ†’ + Add Integration, then search for PC Power Control.


๐Ÿ›  Option 2: Manual Installation

If you donโ€™t use HACS:

  1. Download this repository as a ZIP:
    https://github.com/Timman70/home-assistant-pc-power/archive/refs/heads/main.zip

  2. Extract it.

  3. Copy the folder pc_power_control to your Home Assistant config:

    /config/custom_components/pc_power_control/
    

    You should now have files like:

    /config/custom_components/pc_power_control/__init__.py
    /config/custom_components/pc_power_control/manifest.json
    /config/custom_components/pc_power_control/switch.py
    
  4. Restart Home Assistant.

  5. Go to Settings โ†’ Devices & Services โ†’ + Add Integration, then search for PC Power Control.


โš™๏ธ Configuration

When adding the integration, you'll need:

Field Description
Name Friendly name for the PC
Host IP address of the PC
MAC MAC address for Wake-on-LAN
Username Windows user with SSH access
Password SSH password

โœ… Use 00:11:22:33:44:55 format for MAC address.


โœ๏ธ Editing PC Settings

After setup, click Configure on the integration to change:

  • IP address
  • MAC address
  • Username
  • Password
  • Name

All settings are editable directly in the Home Assistant UI.


๐Ÿ›  Requirements on Windows PC

  • Enable Wake-on-LAN in BIOS and network adapter settings.
  • Install and configure OpenSSH Server:
    1. Run Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 in PowerShell (as Admin)
    2. Start service: Start-Service sshd
    3. Run on boot: Set-Service -Name sshd -StartupType 'Automatic'
  • Allow SSH in Windows Firewall.

๐Ÿ“ก Entity Behavior

  • The switch entity reflects real-time power state using ping.
  • Turning on uses Wake-on-LAN magic packet
  • Turning off uses:
    C:\Windows\System32\shutdown.exe /s /f /t 0
  • Logging shows success/error for debugging.

๐Ÿงช Troubleshooting

If you see:

Config flow could not be loaded: 500 Internal Server Error

Make sure:

  • You deleted all __pycache__ folders from /config/custom_components/pc_power_control/
  • You're using the latest version of the integration
  • You restarted Home Assistant fully after installing

๐Ÿงผ Uninstall & Cleanup

To fully remove entities:

  1. Delete the integration from Home Assistant.
  2. Remove any leftover entities from Settings โ†’ Entities.
  3. Or use Developer Tools to disable/hide them.

๐Ÿ“˜ Example Automation

alias: Shut down PC at night
trigger:
  - platform: time
    at: "23:30:00"
condition: []
action:
  - service: switch.turn_off
    target:
      entity_id: switch.my_pc
mode: single

๐Ÿ‘ค Developer

Created by TimCloud
๐Ÿ”— github.com/Timman70


๐Ÿ” Disclaimer

Use at your own risk. Ensure your PCโ€™s SSH server and network access are securely configured.

About

Home Assistant custom integration to power on and off a Windows PC using Wake-on-LAN and SSH shutdown. Real-time status updates and automation-friendly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages