Wake on Lan Switch , turn off now work!

Hi
I use this article to set a switch to wake on pc and turn it off

My Config:

wake_on_lan:

switch:
  - platform: wake_on_lan
    mac: 18:C0:4D:38:0E:89
    name: PC
    host: 10.0.0.200
    turn_off:
      service: shell_command.turn_off_remote_pc

shell_command:
  turn_off_remote_pc: /usr/bin/ssh [email protected] sudo poweroff

turn in is working fine, but not shutdown, frin HA terminal if i run command “/usr/bin/ssh [email protected] sudo poweroff” it’s working ~?

1 Like

My turn off isn’t working either, I might try the same thing - but -

@Aabayoumy can you share the source code for the below?

shell_command.turn_off_remote_pc

Thank you in advance…

shell_command:
  turn_off_remote_pc: /usr/bin/ssh [email protected] sudo poweroff

Sorry I misunderstood, you ssh into the PC (which is actually a linux box) with the ip address 10.0.0.200, userid “hass”, then sudo poweroff. Mine is actually a PC but that’s a clever workaround and I can probably do something similar.

Check out Hass.Agent. It has a lot of PC command functions

1 Like

This is just an SSH, so you should be able to test it outside of HA, I have an SSH key installed as root, so I can do a shutdown using:

/usr/bin/ssh -i /home/david/.ssh/id_rsa root@desktop /usr/sbin/shutdown -h now

Where I am fully qualifying every path including the path to the private key that will authorize shutdown.

Note: SSH can be locked down so that a particular key can only run a single command - in this case shutdown - however I would suggest getting it working first then locking it down.

1 Like