RPC Shutdown working on Windows 10 (windows remote shutdown)

I’ve been struggling a bit with the RPC shutdown, to get it working on Windows 10.

It’s this AddOn: https://github.com/home-assistant/addons/blob/d0cfdcee880db733dca24e1359d05256e26fbecd/rpc_shutdown/README.md
The docs for it are, well, short :slight_smile:

So I searched quite a bit on it, and found out the following.
Set a fixed IP on the workstation
Created a HomeAssistant user on my PC (local user account with administrator privileges), and given it a password.

This is entered into the config for the addon like this:
computers:

  • alias: KennethsPC
    address: 10.11.12.40
    credentials: HomeAssistant%SecretPassword
    delay: 30
    message: >-
    Computeren lukkes af Home Assistant, dette kan ikke afbrydes, gem dine
    ting!

You have to open the Windows Defender Firewall for ‘Remote shutdown’ (it’s called Fjernlukning in danish, so I hope that’s what it says in english).

At first I saw this error:
Could not initialise pipe winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND
To fix that, open the services.msc on you workstation, and set the service Remote Registry to Manual.

The next error I saw was
WERR_CALL_NOT_IMPLEMENTED
To fix that, I logged in as that user, and opened the registry (regedit.exe).
In there I had to create a key under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
The key is a 32-bit DWORD that is called
LocalAccountTokenFilterPolicy
And set that to the value of 1.

After that it works.

4 Likes

I use the Airytec switch off application (http://www.airytec.com/en/switch-off/) on my windows computers
It supports the hybernate option :slight_smile:

Simply send a html request to your windows computer from node-red or an automation and it will shutdown or hybernate.

Thanks for the alternative option. Will try it out.

Is there an option to force a restart like shutdown -f -r ?
I have a task scheduled for rebooting but was curious if this rpc addon can accept arguments like that.

Thanks

Hi Yonny,
have you a solution? Mein rpc shutdown add on works perfeklty, but i need the restartbutton to.

As a reference: https://stackoverflow.com/a/9781973/367765

I use plain ssh and shell_commands for that (+ wol for wakeups)

shell_command:
   mypc_turn_off_command_shell: "ssh -4 -o ConnectTimeout=3 -o StrictHostKeyChecking=no [email protected] 'rundll32.exe powrprof.dll,SetSuspendState 0,1,0'"

You have to have a SSH server enabled on the target (even window 10 has it), with key authentication.

I’ll probably look into the shell commands but at the moment my blue iris software has the built-in function of restarting my windows it is on.

could you provide a copy paste of mentioned automation?

Here is a great write up about RPC Shutdown from Home Assistant youtuber and guru, Kiril Peyansk, I followed his steps and it worked great.
https://peyanski.com/home-assistant-wake-on-lan-home-assistant-rpc-shutdown/#Home_Assistant_RPC_Shutdown_add-on

I have tried all the steps above Including turning off the firewall completely on the PC and I still get this error message in the log for the addon:

[15:32:32] INFO: Read alias: mypc
[15:32:32] INFO: Shutdown mypc → ###.###.###.###
could not connect to server ###.###.###.###
connection failed: NT_STATUS_CONNECTION_REFUSED
could not connect to server ###.###.###.###
connection failed: NT_STATUS_CONNECTION_REFUSED
[15:32:32] ERROR: Shutdown failed:

Nothing else shows in the log for the addon after that, except when I try it again, the same exact 7 lines (except the time is different if course).

I am able to ping the PC from the RPI running HA directly when I at a command prompt on the RPI host command line.

Thoughts?

It’s the RPC service that’s the hurdle (I think), I had to fiddle with local rights for it to work, on my machine it just worked, on my sons it took me a week.

I just changed all RPC (Remote Procedure Call) services on my machine to automatic and then staerted every single one, but I am still getting “NT_STATUS_CONNECTION_REFUSED”. Also I have checked from the RPI running HA and the PC in question - there are no firewall rules blocking connectivity between the two - and they are on the same vlan… What were the other things you tried on your son’s machine?

I ended up giving up on my sons machine, and switched both machines to use the HASS Agent instead.

The old from LAB02 is no longer supported, but this one works.

This is so freaking BOMB! Thank you for this!

  • BUT -

In order to run the installer that was downloaded, I had to go tinto properties and select “unblock” to unblock it from running. Then whenever I run the app, It instantly closes as soon as I run it - even if my firewall is completely turned off. Ideas?

I’ve never had any issues like that. What is your UAC level set to? Could be that you need to run the install as local admin (completely guessing here!).
But otherwise post it to the github: Issues · hass-agent/HASS.Agent · GitHub

I’d recommend the HASS Agent, I’ve used it in the past and you can do an absolute ton of things with it.