Comments (6)
Also, I'm not entirely sure but it looks like you haven't pushed a new version with pingCommand
support?
from homebridge-wol.
Hi!
Well, the examples for this project is pretty sparse, but I do keep the configuration in the README up to date. For the pingCommand
the following section is relevant:
pingCommand
Command to run in order to know if a host is up or not. If the command exits successfully (non-zero exit code) the host is considered up. If an error is thrown or the command exits with a non-zero exit code, the host is considered down.
As for examples, it's important to note that the ping command is any command that can be run in a shell. Therefore there are endless ways to use it. Unfortunately there's no go-to way for me to solve detection of a Mac being awake / asleep, so using the ping command to for example SSH into the machine and then doing the checks there is necessary. If I find a good way of doing it, I'll try to mention it or implement it into the plugin, but for now users will have to do some experimenting.
A good (untested) place to start is probably something like:
ssh [email protected] "[[ "$(ioreg -n IODisplayWrangler | grep IOPowerManagement | sed 's/.*DevicePowerState"=\([0-9]\).*/\1/')" != "4" ]] && exit 1"
The command SSHs into the machine and sees if the value IOPowerManagement
in the registry IODisplayWrangler
is not equal to 4 (considered on). If it is not on, it exits with an error as specified by the pingCommand
implementation.
Inspired by: https://apple.stackexchange.com/a/103346
The ping command feature is implemented but untested, therefore I have decided not to push the feature to NPM. There's still some work to be done. The idea is to take care of everything mentioned in the 3.3 milestone.
You can try the master version by following the steps outlined in the Development
section of the README.
If you got further questions, don't hesitate to reach out!
from homebridge-wol.
@AlexGustafsson Thanks for the details! I appreciate the effort. I'm looking forward to the 3.3 release :)
from homebridge-wol.
Here's my command in bash script form. It takes two args so it can be used for various Macs:
pingHostDisplay <user> <IP>
# anything less than 4 means display is off
STATE=$(ssh $1@$2 -i ~/.ssh/homebridge pmset -g powerstate IODisplayWrangler | tail -1 | cut -c29)
if [ "$STATE" != 4 ]; then
# host is "down"
exit 0
else
# host is "up"
exit 1
fi
@AlexGustafsson does this seem right to you? This has generally been working for me but took forever to figure out.
from homebridge-wol.
@amaisano Yeah, that seems to work!
from homebridge-wol.
Closing. Feel free to open it again if you believe that the issue is not solved.
from homebridge-wol.
Related Issues (20)
- 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
- Dont wake after shutdown HOT 6
- Wake on Lan is no longer working HOT 2
- This computer will be shut down shortly
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.