Shutdown windows remotely

I’m trying to set up a wake on lan switch for my windows desktop in hassio. The waking up part works without problems but the turning off part doesn’t. In my previous home assistent setup, I’ve used the following command line switch.

switch:
  - platform: command_line
    switches:
      pc:
        command_off: 'net rpc shutdown -I 192.168.x.x -U user%password'

But in hassio i get the error “Command failed: net rpc shutdown -I 192.168.x.x -U user%password”
My guess is that I need to install “samba-common” to run this command.
How can I do this in hass.io?

+1 same problems here

Try using “apk samba-common”. Hope that gets you going!

i did try “apk add samba-common” does not work and soon as you reboot the vm the install apk gets uninstall

Thank you for your response. “apk add samba-common” doesn’t seem to change anything. I still get the same error

   /bin/sh: net: not found
   2017-07-29 10:50:56 ERROR (SyncWorker_15) [homeassistant.components.switch.command_line] Command failed: net 
   rpc shutdown
1 Like

after installing the “apk add samba-common” the “net rpc shutdown” command only works from the CLI not from homeassistant im still waiting for a fix my self

Any update on this?

Stumbled upon this when researching the same thing, so… same question for me. Anyone figure it out yet?

I use a script to trigger a Join message:

The turn_off call:

turn_off:
  service: notify.join
  data:
    message: pc_sleep
    target:
    - ONEPLUS A3003

The script:

'1504007292204':
  alias: PC Sleep
  sequence:
  - alias: Put PC in Sleep Mode
    data:
      message: pc_sleep
      target:
      - ONEPLUS A3003
    service: notify.join

I then use Join plugin in Tasker to trigger a Unified Remote command.

I know it’s a bit op but it works for me. If anyone has a better way of doing this would love to know as my method can have its flaws.

Hey fellows I tried the ‘‘apk add samba-common’’ can anyone tell me why im getting this error below:

core-ssh:~# apk add samba-common
WARNING: Ignoring APKINDEX.84815163.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.24d64ab1.tar.gz: No such file or directory
ERROR: unsatisfiable constraints:
samba-common (missing):
required by: world[samba-common]

I was trying setup WOL but cant get this to install?

I really like Hass.io but not being able to do net rpc is making me want to go back to Hassbian :frowning:

I had to do “apk update” to get the “apk add” command to work. “apk search” shows what’s available to install.

I am able to get the “net rpc” command to run, but it just says “Connection failed: NT_STATUS_IO_TIMEOUT”. I assume I have to do something on my Windows machine to make it listen, but I’m not sure what.

There is a hassio add-on to handle this.

2 Likes

Can you post your yaml config file, as I am struggling to make this work
Cheers

1 Like

Here is my working switch:

switch:
  - platform: wake_on_lan    
    mac_address: "AA-AA-AA-AA-AA-AA"
    name: "Desktop"
    host: 192.168.1.21
    turn_off:
        service: hassio.addon_stdin
        data:
            addon: core_rpc_shutdown
            input: Desktop

This is the addon settings:

{
  "computers": [
    {
      "alias": "Desktop",
      "address": "192.168.1.21",
      "credentials": "user%pass"
    }
  ]
}

Make sure u set up windows correctly too.

  • Start remote registry service
  • Open firewal for WMI
  • In registry set HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy to 1 or add it.

I followed this guide http://blog.sip2serve.com/post/155565656901/shutdown-windows-10-remotely

8 Likes

Many Thanks off to try and replicate

Thanks for this!

Any idea if this can be used for sleep/hibernation instead of shutdown?

The rpc command has a hibernate option but i don’t think the addon allows you to set that option.

Still not go, it is a windows 10 issue I am sure.

I have firewalls off.

Get-NetConnectionProfile

Shows I am on a private network.
But telnet to port 445 shows Connection closed by foreign host

Remote registry is running, RPC is running. Both verified in services.msc panel. Avast disabled as well.

Netstat -ao shows the pc listening on 445 as well.

Oh the switch on the panel to activate shutdown turns off and back on when clicked. It does indicate that the service is being called.

Ideas?

So I have mine shutting down now but have needed to do the instructions as per Mosie 1 on Windows 10.

> 1. * Start remote registry service
> 2. * Open firewal for WMI
> 3. * In registry set HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\LocalAccountTokenFilterPolicy to 1 or add it.

However once shutdown I cant Wake on LAN. WOL only seems to work on hibernate or sleep as per the Microsoft article.

In Windows 8, 8.1 and Windows 10, the default shutdown behavior puts the system into the hybrid shutdown state (S4), and all devices are put into D3. WOL from S4 or S5 is unsupported. Network adapters are explicitly not armed for WOL in either S5 or S4 cases because users expect zero power consumption and battery drain in the shutdown state. This behavior removes the possibility of invalid wake-ups when an explicit shutdown is requested. Therefore, WOL is supported only from sleep (S3) or hibernation (S4) states in Windows 8, 8.1 and Windows 10.
ACPI sleep states S0 to S5 . 0 being awake.