AlexGustafsson / homebridge-wol

A Wake on Lan plugin for Homebridge
MIT License
301 stars 30 forks source link

Cannot shut Mac mini down #97

Closed asbesto01 closed 4 years ago

asbesto01 commented 4 years ago

Installed and correctly launched the Homebridge-WOL plugin on my Windows Homebridge server in command prompt, with following instructions:

"accessory": "NetworkDevice", "name": "MacMini", "mac": "1234", "ip": "192.168.0.189", "pingInterval": 45, "wakeGraceTime": 5, "wakeCommand": "ssh stefano@192.168.0.189 caffeinate -u -t 300", "shutdownGraceTime": 60, "shutdownCommand": "ssh stefano@192.168.0.189 pmset sleepnow"

when I try to shut it down VIA LAN, I receive:

[2020-3-15 23:17:12] [MacMini] NetworkDevice shutdown cycle started for "MacMini" (192.168.0.189) [2020-3-15 23:17:12] [MacMini] NetworkDevice "MacMini" (192.168.0.189) went from status "Online" to "Shutting Down" [2020-3-15 23:17:12] [MacMini] Attempting to shut down "MacMini" (192.168.0.189) using "ssh" Password:

HERE I insert the password manually (is there a way to store it in the config.json?)

The Mac shuts down perfectly, however it wakes by itself after some seconds. Terminal shows:

[2020-3-15 23:17:20] [MacMini] Waiting for shutdown grace time (60000ms) for "MacMini" (192.168.0.189) [2020-3-15 23:18:20] [MacMini] NetworkDevice "MacMini" (192.168.0.189) went from status "Shutting Down" to "Online"

How to stop the auto turn-on? How to specify in the config.json the password ?

Thanks!!!

AlexGustafsson commented 4 years ago

What you're after is called ssh key authentication. That way you can setup a key which will act as your password, that way you'll never need to have your password in cleartext. I think it's mentioned in the README.

As for the automatic turn on, I can't say for sure what's happening. If you run the shutdown command manually in a terminal, does your Mac wake up afterwards as well? This doesn't really sound like something this plugin would cause.

asbesto01 commented 4 years ago

Ciao Alex, thank you so much for your reply.

two points:

1) is it possible to perform a ssh key auth from a Windows host (that's where my home bridge runs in a command prompt) towards a Mac? Or it is required for example a linux environment such as a raspberry pi?

2) if plugin is installed and I put my Mac asleep from it, then it wakes up back. If plugin not installed, it goes sleeping perfectly :(

AlexGustafsson commented 4 years ago

Any platform with SSH should support SSH keys. It’s a fundamental part of the software.

Does the Mac wake automatically every time? There are three possible reasons I can see:

  1. The plugin starts to ping again after shutting the Mac down, the Mac wakes up from pings. You’ll have to research this on your own as I’ve never seen it happen
  2. There is some undefined behaviour causing the plugin to execute the wake command after the shutdown command is done. If this would be the case, there would be plenty of logs in the debug mode telling you that it tries to wake the machine up every time after it’s been shutdown
  3. Some external factor such as the machine simply waking itself up due to USB activity or whatever. Try to disconnect all peripherals and see if it happens again
AlexGustafsson commented 4 years ago

Were you able to solve this issue?

AlexGustafsson commented 4 years ago

Closing due to inactivity. Feel free to reopen if the issue persists.