WOL Switch - Turn_off:

Here’s the total of what I have, which is now working for me:

Under switches.yaml:

- platform: wake_on_lan
  mac_address: "AA-BB-CC-11-22-33"
  host: 192.168.0.2
  name: "wol"
  turn_off:
    service: shell_command.wol_off

Then in my shell_commands.yaml:

wol_off: net rpc shutdown -I 192.168.0.2 -U <usenamer>%<password>

You can add -f and -t 0 to force shutdown and wait 0 seconds, if you want to make it shutdown super quick, but I didn’t bother.

I don’t believe you need to reference an entity_id, as the only relevant id belongs to the switch itself.

An important thing I’ve found, is that I could only get it to work when using the Windows machine’s ‘Administrator’ user account. It didn’t work to just use any user that has administrative rights, it had to be that user. In my case I had to enable the account, and set a password. Not the best solution tbh, but it definitely works.

I’m not sure, but I believe including the optional ‘host:’ parameter is what allows it to determine whether the machine is on or off. It’s probably pinging regularly, and using the response/lack of response to determine the power state. If it doesn’t have this state information, I believe that’s what causes the switch state to default to off.

In my case, When turning the machine off with the WoL switch, it will go to the off position as it sends the shutdown command, but then since the computer didn’t turn off straight away, and still responds to ICMP, the switch moves back to the on position. Once the PC has shutdown however, it notices and corrects the switch state.

Hope this helps.