Home Assistant config :
Generate id_rsa and id_rsa.pub in /config/
add Switch config :
- platform: wake_on_lan
mac: "DC:FB:48:XX:XX:XX"
name: XX
host: 192.168.0.XX
turn_off:
service: shell_command.turn_off_XX
add Shell Command config :
turn_off_XX: 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /config/id_rsa [email protected] shutdown /h /f'
Windows 10 config :
Manage optional features > Add a feature > OpenSSH Server > Install
Open “services.msc” , select “OpenSSH SSH Server” > Startup type > Automatic
Restart Windows 10.
Enable Wake-On-LAN in the BIOS
Enable Wake-On-LAN in the “Devices Manager”
Network Adapters > Select the WiFi card > right click Properties > Power Management > Allow this device to wake the computer + Only allow a magic packet to wake the computer -> CHECK BOTH
Allow HA to ping Windows, for HA to see the Windows state : Windows Defencer Firewall > Advanced settings > File and Printer Sharing (Echo Request - ICMPv4-In) (TWO RULES) > right click and “Enable rule”
Open Notepad as Administrator, add the content of id_rsa.pub in C:\ProgramData\ssh\administrators_authorized_keys
with no extension
Set the permissions with PowerShell as Admin :
$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys
$acl.SetAccessRuleProtection($true, $false)
$administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow")
$systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow")
$acl.SetAccessRule($administratorsRule)
$acl.SetAccessRule($systemRule)
$acl | Set-Acl