WOL things for macos

Hello world,

(actually this should be the headline for the first post, but anyway, I didn’t think of it then)
Reading the docs, reading this forum here, reading on openssh, reading some RFCs I found out things I want to share but also have questions.

The home assistant system is a hassio-vm running on esxi. (It is somehow strange as a german to deal with this system and reading all the time: hate, hate, hateOS, hateIO… but anyway, german speaker should stick with fhem and openhab :no_mouth: )
My integration looks like this at the moment:

  • configuration.yaml:
wake_on_lan:

shell_command:
  iapple1_standby: "ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] sudo shutdown -s now"

switch:
  # Wake on LAN
  - 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 had some random error 255 in the logs, when I started this project.
All the good advice on ssh -i /path/to/cert and ssh -o StrictHostKeyChecking=no wasn’t enough. There is one post around this topic - there are quite some of them - dating 2017, where someone pointed to the fact, that the ssh-plugin is another container and thus another host than the system - hassio I guess - sending the switch commands.

So I checked the my authorized_keys file on the iThing and deleted the comment that is written by the ssh-copy-id command. RFC [some number] says that the ‘comment’ is really supposed to be just a comment but I guess the implementation of RFCs into software… Anyway: the comment was root@core-ssh and I have deleted it.

Question1: what is the hostname of the container running the actual switch command?
I would perhaps just have edited the part after the @-sign… But deleting the so called ‘comment’ on the mac-side did the error 255 trick for me.

Question2: who is running the switch-command?
I think it is root and that, at least in hassio, it is not necessary to use the -i and -o options as the key is used anyway when created and copied the standard ssh-way and the known_hosts-file is persistent now?!

Ah yes: I use sudo shutdown -s now and not pmset sleepnow But I’ve changed that in all the process of changing every single setting and every combination for my try and error procedure. Perhaps I should change that back. Anyway - I can set an iFruit to sleep.

But now… second, how will he wake up? And first: how is hassio knowing my iPro is sleeping?

To answer the first question posed second: it isn’t. My switch is always (that is after 30 sec or so) 'on'. The nics of the iPro2013 sending ping answers while sleeping. I mean those apple guys… really, while sleeping, and still :face_with_thermometer:
This answer - if it is right - leads to the question: can I change the check? And if the answer would be ‘yes’, then I would kindly ask ‘how’?

Well, the second question - waking up a not really sleeping, but still pretty much sleeping mac - is perhaps for another time. As hassio needs to send the magic over an opnsense router to reach the iContra, there might be some problem there. Sending the command from opnsense works, I’m positive that I will get this working from hassio too, some near day in this decade. But if someone would know what to check on the firewall-side! That would be awesome too :smiley:

If I’ve counted right, there are some four to five questions and one tipp. Thanks for reading

Best, Bernd

Edit1: try and error17: nevertheless -i option is needed - what about -o?

1 Like

Hey, I found this post because I am also running into the return code: 255 error. How did you fix that exactly?

I have officially announced my opnsense integration here: OPNsense Integration it includes a service to execute wol commands (among many other things) if that’s helpful.