Control your Windows computer directly from Home Assistant. Shut it down, restart it, or log off — with a button, an automation, or a service call.
- Shut down, restart, or log off via a button in the HA interface
- Online status sensor — always know if your PC is reachable
- Automatic discovery via mDNS/Zeroconf — no need to look up IP addresses
- Configurable delay — the PC waits a specified number of seconds before shutting down
- Service call — send a shutdown command from an automation
- Diagnostics — downloadable debug information for troubleshooting
- Reauth flow — renew the API key without reinstalling the integration
- Home Assistant 2024.1 or newer
- ha-windows-shutdown-agent running on the Windows computer you want to control
The agent is a small application that runs in the system tray and exposes a local HTTP API. Home Assistant communicates exclusively over your local network — nothing goes through the internet.
- Open HACS in Home Assistant
- Go to Integrations → click the menu in the top right → Custom repositories
- Add:
https://github.com/donserdal/ha-windows-shutdown— category Integration - Search for Windows Shutdown and click Download
- Restart Home Assistant
- Download the latest release
- Copy the
custom_components/windows_shutdownfolder to your HA configuration directory - Restart Home Assistant
If the agent is running on the same network and mDNS is enabled, Home Assistant will automatically detect the computer. You will receive a notification in the Home Assistant interface.
- Go to Settings → Devices & Services → Add Integration
- Search for Windows Shutdown
- Choose Manual entry and fill in the IP address and port
- Enter the API key generated by the agent
You can find the API key via the agent's system tray icon → Show connection info.
| Entity | Type | Description |
|---|---|---|
button.windows_pc_shut_down |
Button | Sends the shutdown command to the PC |
binary_sensor.windows_pc |
Binary sensor | on if the PC is online, off if it is offline |
The button is only available when the PC is online.
Via the Configure button (gear icon next to the integration), you can configure per device:
| Setting | Default | Description |
|---|---|---|
| Delay | 60 seconds | How many seconds the PC waits before shutting down |
| Action type | shutdown | Choose between shutdown, restart, or logoff |
Use this service in automations to target a specific PC (or all PCs).
action: windows_shutdown.shutdown
data:
shutdown_type: shutdown # shutdown | restart | logoff
delay: 30 # seconds (optional, default: 60)
entry_id: abc123 # optional — leave empty for all devicesautomation:
alias: "Shut down PC at 23:00"
trigger:
- platform: time
at: "23:00:00"
action:
- action: windows_shutdown.shutdown
data:
shutdown_type: shutdown
delay: 60automation:
alias: "Restart PC after Windows Update"
trigger:
- platform: state
entity_id: binary_sensor.windows_update_pending
to: "on"
condition:
- condition: time
after: "02:00:00"
before: "06:00:00"
action:
- action: windows_shutdown.shutdown
data:
shutdown_type: restart
delay: 10The integration polls the agent every 30 seconds via GET /status. If the PC is offline, a grace period of 30 seconds is observed to prevent temporary connection interruptions from causing state changes (anti-flapping).
Upon receiving a 401 or 403 response, Home Assistant automatically starts the reauthentication flow.
The button is greyed out (unavailable)
- The PC is offline or unreachable on the network
- Check that the agent is running (system tray icon)
- Check that port
8765is not blocked by a firewall
Cannot set up the integration — connection error
- Verify the IP address and port
- Ensure the agent is running and that HA is on the same network
Invalid API key
- Open the integration → click Reauthenticate and enter the correct key
- Find the key via the agent's system tray icon
Download diagnostics
- Go to the integration page → click the device → Download diagnostics
- Attach the download to a bug report
Pull requests are welcome. Please open an issue first to discuss the change.