Git Product home page Git Product logo

Comments (6)

perry-mitchell avatar perry-mitchell commented on May 14, 2024

Also, I'm not entirely sure but it looks like you haven't pushed a new version with pingCommand support?

from homebridge-wol.

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

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.

perry-mitchell avatar perry-mitchell commented on May 14, 2024

@AlexGustafsson Thanks for the details! I appreciate the effort. I'm looking forward to the 3.3 release :)

from homebridge-wol.

amaisano avatar amaisano commented on May 14, 2024

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.

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

@amaisano Yeah, that seems to work!

from homebridge-wol.

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

Closing. Feel free to open it again if you believe that the issue is not solved.

from homebridge-wol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.