Rpc shutdown switch

I have been trying to create a WOL / Shutdown switch for my PC.

I have been partly sucessful.

switch:
  - platform: wake_on_lan
    name: PC
    mac_address: "2c:xx:xx:xx:xx:xx"
    host: 192.168.1.112
    turn_off:
      service: hassio.addon_stdin
      data:
        addon: core_rpc_shutdown
        input: PC

With this code, I am able to turn off the PC, but the WOL wont work. If I remove the code from: turn_off: and all the code below it, I am able to turn the PC on, but of course not turning it off, since that part of the code is missing.

What do I need to do, to make both commands work?

Thanks in advance

1 Like

Why create two threads?

As far as I could see I had postede in the wrong forum. I am new here so wanted to correct that mistanke, but found out I couldnt delete my other post, after I made this one :frowning:

Still have the problem tho, if anyone is willing to help :slight_smile:

What does the log of the RPC Shutdown addon say?

The thing is, the shutdown works. But while the code for RPC shutdown is present, I am not able to turn it on. If I remove the RPC part, the WOL works without any problems.

[Info] Read alias: PC 
[Info] Shutdown PC -> 192.168.1.112

Appriciate the help :slight_smile:

Strange, the only difference I see with my setup is that i put the name and host in quotes. Like so;

switch:
  - platform: wake_on_lan
    name: "PC"
    mac_address: "2c:xx:xx:xx:xx:xx"
    host: "192.168.1.112"
    turn_off:
      service: hassio.addon_stdin
      data:
        addon: core_rpc_shutdown
        input: PC

I will try to see if that does the trick when I get home :slight_smile:
Thank you for your help.

I found the problem :slight_smile:
Name and input must be diffrent names.

Thank you for your help :slight_smile:


Seems like I was a bit to fast. Worked first time, but now it dosent work again :face_with_raised_eyebrow:

Good Evening

I have set up RPC Shutdwon PC .its working well through CALL SERVICE . Can you p-lease help me for how to create switch . i paste some code on my configuration.yaml .
but some error showing .find the below images
code

error
error

Use Mac not MAC address.

Always double check the docs when having issues.

Thank your Support

Actually i am first time in HA .And no more idea about coding .

I fixed the issue with your instruction . I believe i will get more helps in future …

Thank you again

Hi there,

I have some troubles trying to setup my WoL/RPC shutdown switch.

Here are my config.yaml :

switch:
  - platform: wake_on_lan
    mac: xx:xx:xx:xx:xx:xx
    host: 192.168.1.17
    name: PC
    turn_off:
      service: hassio.addon_stdin
      data:
        addon: core_rpc_shutdown
        input: pckevin

and the addon config :

computers:
  - alias: pckevin
    address: 192.168.1.17
    credentials: kboul%passw
    delay: 0
    message: Shutting down.

With this configuration, I am not even able to call the service core_rpc_shutdown, I get an error :

Required key not provided @data [‘input’].

One more thing : is it normal that the addon’ logs are empty after restarting it ?

And last but not least : I am able to shutdown my pc remotely via a Linux command. So everything seems ok on the Windows side.

Thank you for your help.

Edit : nevermind, dunno what I did but now it is working perfectly well.

I have exactly the same config (only other IP, MAC etc.) and it works

Hi everyone,

im struggling with this configuration too! The wake on lan is working and the pc turns on. But the switch on the home assistant is switching back to “off” after a few seconds. Therefore Ive no chance to execute the rpc shutdown. What type of button do you using on the dashboard or how you was able to keep the state to poweron?

anyone? :neutral_face:

Is this a Windows machine?

It is expected for it to turn on then off again if HA cannot determine that the computer is actually turned on. I don’t recall which method HA is using to determine this.

In the past I have needed to switch my network type in Windows from Public to Home/Private to get the state reporting to function properly.

To test the RPC shutdown command or use it in an automation you can always just use the developer tools or call the service in an automation, regardless of the switch state.

Actually, my switch stays ‘on’ as long as my PC is on

platform: wake_on_lan
name: PC switch
mac: "xx:xx:xx:xx:xx:xx"
host: 192.168.1.20
broadcast_address: 255.255.255.255
turn_off:
  service: hassio.addon_stdin
  data:
    addon: core_rpc_shutdown
    input: PC

I am using a Button card with

entity: switch.pc_switch

In config/switches.yaml

  - platform: wake_on_lan
    name: "Desktop PC Status"
    mac: xx:xx:xx:xx:xx:xx
    host: 192.168.1.2
    turn_off:
      service: hassio.addon_stdin
      data:
        addon: core_rpc_shutdown
        input: Merlin

In the Lovelace card I added the switch.desktop_pc_status entity that works as expected.

Switch Off => pc goes off
Switch On => pc boots

Supervisor => DashBoard => RPC Shutdown => Configuration is straight forward I think what you have to do

1 Like

My problem was the windows firewall :roll_eyes:

I could fix it to enable rpc and icmp for incoming connection. Now the status keeps online.

Thanks for your response :slight_smile:

Regards