Configuring Wake on LAN for macOS Devices

Hello everyone, I wanted to share my journey and current challenges in setting up Wake on LAN (WoL) for my macOS devices. I’m running Home Assistant as a hass.io VM on ESXi, and I’ve been experimenting with integrating WoL into my setup. While I’ve made some progress, I’m still facing a few hurdles that I’d love to get some advice on.

My current setup involves using the wake_on_lan integration in Home Assistant, paired with a shell command to trigger a shutdown on my iMac. Here’s a snippet of my configuration:

yaml
wake_on_lan:
shell_command: iapple1_standby: “ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no lebernd@192.168.230.101 sudo shutdown -s now”

switch:

  • platform: wake_on_lan
    name: “WoL iapple1 Switch”
    mac: “00:11:22:33:44:55”
    host: “192.168.230.101”
    turn_off: service: shell_command.iapple1_standby

I’ve encountered some random error 255 in the logs, which I believe is related to SSH authentication. After some research, I adjusted my SSH configuration by removing a comment from my authorized_keys file, which seemed to resolve the issue temporarily. However, I’m still curious about the hostname of the container running the switch command and whether the -o StrictHostKeyChecking=no option is necessary in this context.

Another challenge I’m facing is determining how Home Assistant detects whether the device is truly asleep. Currently, the switch state remains ‘on’ even after the device has been put to sleep, which isn’t ideal. I’d love to find a way to accurately check the device’s status and update the switch state accordingly.

Additionally, waking the device up over my Opnsense router has been hit or miss. I’m wondering if there are specific firewall settings or configurations I should be checking to ensure the WoL packets are being routed correctly.

I’d greatly appreciate any insights or tips the community might have on these topics! Your experiences and solutions could really help me optimize this setup. Thanks in advance for your support!

Best regards,
Bernd