Comments (33)
Hi Alex, thanks for replying. I’ve managed to ssh from within the docker, even with rsa key and no password. The trouble seems to be when I use off switch the command fails in the logs. I’m unable to tell “who” is using the command, but assumed that within the container it’s root. I might try the verbose flag in the Config to see what ssh is doing
If u are using "oznu/docker-homebridge" the user "abc" is running node and with this your ssh keys are at a different location.
If thats your problem u can go to /config/.ssh and put your keys there.
from homebridge-wol.
@amaisano Yes and no. Yes as this issue mostly has to do with Macs “lying” about their state. No as there’s most likely an issue with the internal state machine that has come up in other issues.
A PR came in yesterday mentioning pinging which may or may not be related.
I’d say that your best off following the milestone https://github.com/AlexGustafsson/homebridge-wol/milestones to follow progress.
from homebridge-wol.
Also just noticed that the iMac 5k accessory sets itself to “off” state even while I’m working on my iMac.
from homebridge-wol.
You don't seem to have ssh
installed on your Raspberry Pi. Could you try typing ssh 10.0.1.12 sudo shutdown -h now
on your Raspberry Pi and make sure it works? It seems like you're using docker, so you might have to run the command in that image. This package simply runs the shutdown command provided in the default shell, so you have to make sure that works. Note that you don't seem to have any means by authenticating yourself. Usually you will need to enter user and password for ssh, this is solved by using ssh keys.
As for the issue regarding your iMac being shown as offline even when it's on, it's possible that you need to adjust the ping interval. The package pings your iMac every now and then (as specified in the config). When 5 pings are returned with the same status (turned on or off) the status of the computer is considered changed. So basically it's possible that 5 pings fails in a row even when your iMac is on. Lowering pingInterval
should in theory return a more accurate state, but could fail more often resulting in a flicker of state. A higher value for pingInterval
makes the actual state change take longer to happen (i.e. your iMac will be shown as turned on some time after it has been turned off) but could lower the fail rate.
from homebridge-wol.
@VeniceNerd Have you been able to resolve the issue?
from homebridge-wol.
Hi Alex! Not yet. I haven’t had time to look back into it.
Also, I found out that apparently you can’t even wake up an iMac from shut off state. Only from sleep state.
Also, when you wake up a mac from sleep over WOL it only wakes up for a few seconds before going right back to sleep.
That seems to be a limitation of the Mac. Makes WOL less useful for me overall.
from homebridge-wol.
Yes, these are some limitations of iMacs and MacBooks. However a common opinion that I share is that usually one does not really turn an Apple computer completely off. That mitigates that shortcoming.
About the computer only being started for a minute or two before going back to sleep. That sounds like it could have to do with the computer not logging in. If possible, one mitigation could be to disable the login screen.
Thank you for sharing your findings! I hope this issue can be helpful for others stumbling upon this or similar issues.
from homebridge-wol.
In my (admittedly limited) testing, I've found that WOL will wake the computer from sleep (similar to if you attempt to ssh into it), but won't wake the screen. It likely explains why the computer doesn't stay awake for long, the system goes back to sleep after detecting no further activity (and the example wakeGraceTime
will usually completely miss this window).
Having the ability to issue a "wakeCommand" (in a similar vein to the existing shutdownCommand
) would effectively solve this issue, since you could then send a command to properly attempt to wake the computer, i.e. ssh 10.0.1.12 caffeinate -u -t 300
(which is simply telling macOS that the user is active and it shouldn't sleep for another 300 seconds).
Is there a chance this functionality could be added?
from homebridge-wol.
@jellybeansoup Thank you for reporting your findings! The feature was added in 3.2.0
published just now. The wake command is issued after the wake grace time has expired, see the example below.
{
"accessory": "NetworkDevice",
"name": "My Macbook",
"mac": "<mac-address>",
"ip": "192.168.1.51",
"pingInterval": 45,
"wakeGraceTime": 1,
"wakeCommand": "ssh 192.168.1.51 caffeinate -u -t 300",
"shutdownGraceTime": 15,
"shutdownCommand": "ssh 192.168.1.51 sudo shutdown -h now"
}
This configuration will wake up the computer using wake on lan and then wait one second before starting to ping the device and issuing the caffeinate command.
The readme has been updated to reflect the changes.
I hope this will solve your issue as well, @VeniceNerd.
Feel free to update me whether or not the feature works as expected.
from homebridge-wol.
Interesting. I may try this again. Question, though, will my iMac go to sleep if I turn the “outlet” off? Or does this not work on the Mac either?
from homebridge-wol.
Yes, that feature works. The configuration shown in your original post is correct. Make sure that SSH is enabled on the Mac.
from homebridge-wol.
I've done a few days of testing on this, and it appears to work as expected. Turning the device off via homekit causes my Macbook Pro to sleep, and the new wakeCommand
causes it to fully wake up, including the displays. Thanks for adding this so quickly, @AlexGustafsson!
I did find that too short a wakeGraceTime
would end up causing it to fail sending the wakeCommand
, for some reason. My suggestion would be setting the value somewhere between 5–10 seconds. It seems like that allows WOL to wake the machine enough for the ssh command to trigger successfully.
For reference, the settings I'm using are as follows:
{
"accessory": "NetworkDevice",
"name": "Macbook Pro",
"mac": "<mac-address>",
"ip": "mbp.local",
"shutdownGraceTime": 60,
"shutdownCommand": "ssh [email protected] pmset sleepnow",
"wakeGraceTime": 5,
"wakeCommand": "ssh [email protected] caffeinate -u -t 300"
}
It's worth noting that, in addition to having "Wake for network access" enabled, I've also disabled Power Nap, which tends to cause this plugin to think the device has turned on at random times (which is legitimate, the whole point is that it accesses the network to fetch things while sleeping). If you've got automation based on when the machine turns on, you might find disabling this will help at least reduce them (though I can't say if it disables the behaviour completely).
from homebridge-wol.
Thank you, @jellybeansoup for posting about all of your findings. It’s great for future reference!
from homebridge-wol.
@jellybeansoup thanks for the detailed post! Do you run homebridge on the same machine that you’re putting to sleep?
I’m running homebridge on a Pi3 and was wondering if that would still work the same to control my iMac on the same network?
from homebridge-wol.
@VeniceNerd I'm running homebridge from a Raspberry Pi Zero W, which uses SSH keys to log in to the Macbook Pro over Wifi. Your set up should totally work (I actually wouldn't suggest trying to run this from the iMac itself, or the bridge will go offline when the machine goes to sleep).
FYI, if you're running into login problems, it could be a couple of things. A dynamic IP, which I'm getting around by using the hostname found in System Preferences > Sharing (it'll be noted as <ComputerName>.local). Alternatively, the need for a password, which you can bypass by setting up SSH keys to log into your iMac from the Raspberry Pi 3.
from homebridge-wol.
@VeniceNerd Has your issue been solved?
from homebridge-wol.
Hello! I'm able to call the sleep mode on my macbook but i can't wake up it.
Here is my config:
{ "accessory": "NetworkDevice", "name": "Macbook Pro", "mac": "MACADDRESS", "ip": "MacBook-Pro-di-Michele.local", "pingInterval": 45, "wakeGraceTime": 5, "wakeCommand": "ssh [email protected] caffeinate -u -t 300", "shutdownGraceTime": 60, "shutdownCommand": "ssh [email protected] pmset sleepnow"
and the log:
[3/29/2018, 7:46:25 AM] [Macbook Pro] NetworkDevice shutdown cycle started for "Macbook Pro" (MacBook-Pro-di-Michele.local) [3/29/2018, 7:46:25 AM] [Macbook Pro] Attempting to shut down "Macbook Pro" (MacBook-Pro-di-Michele.local) using "ssh [email protected] pmset sleepnow" [3/29/2018, 7:46:25 AM] [Macbook Pro] NetworkDevice "Macbook Pro" (MacBook-Pro-di-Michele.local) went from status "Online" to "Shutting Down"
but no log when i try to wake up the Macbook...seems that no command get given to homebridge
from homebridge-wol.
Sorry update, with this configuration:
{ "accessory": "NetworkDevice", "name": "Macbook Pro", "mac": "MACADDRESS", "ip": "MacBook-Pro-di-Michele.local", "pingInterval": 10, "wakeGraceTime": 5, "wakeCommand": "ssh [email protected] caffeinate -u -t 300", "shutdownGraceTime": 45, "shutdownCommand": "ssh [email protected] pmset sleepnow" }
i can see an action in the logs:
[3/29/2018, 10:02:06 AM] [Macbook Pro] Attempting to shut down "Macbook Pro" (MacBook-Pro-di-Michele.local) using "ssh [email protected] pmset sleepnow" [3/29/2018, 10:02:06 AM] [Macbook Pro] NetworkDevice "Macbook Pro" (MacBook-Pro-di-Michele.local) went from status "Online" to "Shutting Down" [3/29/2018, 10:02:52 AM] [Macbook Pro] NetworkDevice "Macbook Pro" (MacBook-Pro-di-Michele.local) went from status "Shutting Down" to "Online" [3/29/2018, 10:04:14 AM] [Macbook Pro] NetworkDevice "Macbook Pro" (MacBook-Pro-di-Michele.local) went from status "Online" to "Offline" [3/29/2018, 10:08:26 AM] [Macbook Pro] NetworkDevice "Macbook Pro" (MacBook-Pro-di-Michele.local) went from status "Offline" to "Online"
But i can see that the command ssh [email protected] caffeinate -u -t 300 is missing
from homebridge-wol.
@bubez81 Hi! If this is a persisting problem, could you please open a separate issue? It makes it easier for me to follow and hopefully solve.
from homebridge-wol.
ok sorry for the delay it's not a good period for me.
i will make some test and then i will open a new post.
Michele.
from homebridge-wol.
@bubez81 No worries. Take your time!
from homebridge-wol.
Hello, I’m having the same issue at the OP. I get ssh not found and I’m using a docker container. Any advice on adding ssh to docker? I’ve included it in the docker-compose.yml as a package (openssh). I added this after the initial installation, so I’m not sure if I’m supposed to do anything more?
Cheers!
Edit: Discovered I need to add openssh to the docker-compose.yml file, then docker-compose down, docker-compose up and it installs.
from homebridge-wol.
@PerthSteve Also make sure that you’re running your container on the host network interface - otherwise the container won’t be able to find devices on your local network. If you’re unsure of what I’m talking about, take a look at the docker documentation. Feel free to come back whether it works or not!
from homebridge-wol.
from homebridge-wol.
Hi Alex, hope you can help me. I've also can't send my iMac to sleep or wake up.... when I send the ssh command to sleep to wake up from the console of the raspberry the iMac wakes up and go to sleep without any problem. When I try it over Homebridge it doesn't work....
in the logfile stands "An error occurred while trying to shut down "myimac"..... Error: Command failed: ssh myname@myimac pmset sleepnow
from homebridge-wol.
Does the command work if you run it yourself in the terminal? It seems like either you don’t have SSH installed on the pi or it couldn’t connect to the Mac.
from homebridge-wol.
Thanks for your quick response.... ssh on the raspberry should be installed. maybe my explanation was not detailed enough. for testing ssh I'm using the app Homebridge on my iPad. in the app I open the console on the raspberry pi and start the ssh comma as explained... when I send the ssh command from this console the iMac go to sleep or wake up. But not when I use Homekit... sorry for my bad explanation. But I'm al bloody beginner with raspberry... Can I give you further informations?
from homebridge-wol.
There was no issue with your explenation. The reason for me asking is that homebridge-wol basically copy and pasted the command you enter and run it as a command the same way you would. The idea is that if it works when you type it yourself, it works with homebridge-wol.
One difference, however, is that it inherits the user from homebridge. If you start homebridge as root, then SSH will also be run as root.
Do you start homebridge with sudo? If so, does sudo ssh yourname@mac... work?
from homebridge-wol.
changes nothing :-( I'm looking forward to run the home bridge in debug mode and will give you further informations....
from homebridge-wol.
changes nothing :-( I'm looking forward to run the home bridge in debug mode and will give you further informations....
same issue for me... issuing the caffeniate command directly in the terminal works fine, but the same command issued via the plugin does not
from homebridge-wol.
Same issues: shutdown works great with either pmset displaysleepnow
or pmset sleepnow
, but:
- When attempting to wake up, no command is shown in the console like when shutting down
- Nothing happens, even with shorter/longer wait/grace periods
- My Macs both keep switching back to "On" when they are off (I have disabled Power Nap)
Is this the latest information for this problem or is there another issue or PR open for it?
from homebridge-wol.
Locking this as there are many unrelated issues popping up now and then.
from homebridge-wol.
I've published 3.2.5 to NPM which contains many fixes. Please try it and open new issues for any problems you may face. Closing.
from homebridge-wol.
Related Issues (20)
- WOL doesn't work after extended time
- Network Device Ping Status every Time offline
- Settings for mac mini running Monterey
- Sleep-On-LAN (SOL)
- Can't shutdown my computer with the shutdown command
- WOL starts device, but no ping and no Online status HOT 9
- Homebridge running on docker no sambo-common
- Check if Windows PC is sleeping
- Samba Mac
- Ask for wake/start command
- Adding plugin to HomeKit
- ssh keeps asking for passphrase
- Feature Request: Add support for pingsToChange for ping commands HOT 2
- Please add icons if possible HOT 1
- Dont wake after shutdown HOT 15
- Add instruction for Enable Printer and File Sharing W10+ HOT 1
- magic packets sent not waking pc anymore HOT 14
- Unraid: setcap cap_net_raw=pe /path/to/bin/node
- Problems ssh to windows only from homebridge terminal
- Ping function for detecting the PC online not working recently HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homebridge-wol.