Git Product home page Git Product logo

Comments (6)

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

When the shutdown command is issued, the status is shown to be turned off and a timer starts to count down depending on the shutdown grace time configured. When the grace time is over, the actual status is shown once again.

Have you tried changing the shutdown grace time to a lower value in your configuration? Lowering the value will return the actual status of the device faster, but may also show the device as on during the shutdown process (when it works).

from homebridge-wol.

hawkefly avatar hawkefly commented on May 14, 2024

I config "shutdownCommand:date" to reproduce my issue(command execute successful but actually fail)
{ "accessory": "NetworkDevice", "name": "Mac", "mac": "00:11:22:33:44:55", "ip": "192.168.1.236", "pingInterval": 10, "shutdownCommand": "date", "shutdownGraceTime": 15, "logPinger": true }
Add this line in pingerCallback(newState) function to print more log
this.log('currentState: %s, newState: %s, this.status: %s', this.getValueOfSymbol(currentState), this.getValueOfSymbol(newState), this.getValueOfSymbol(this.status));

and this is the output

[3/3/2018, 10:13:19 PM] Homebridge is running on port 51826.
[3/3/2018, 10:13:19 PM] [Mac] currentState: false, newState: true, this.status: Offline
[3/3/2018, 10:13:19 PM] [Mac] Pinger toggled state change
[3/3/2018, 10:13:19 PM] [Mac] NetworkDevice "Mac" (192.168.1.236) went from status "Offline" to "Online"
[3/3/2018, 10:13:24 PM] [Mac] NetworkDevice shutdown cycle started for "Mac" (192.168.1.236)
[3/3/2018, 10:13:24 PM] [Mac] Stopping pinger
[3/3/2018, 10:13:24 PM] [Mac] Starting pinger again in 15000 milli seconds
[3/3/2018, 10:13:24 PM] [Mac] Attempting to shut down "Mac" (192.168.1.236) using "date"
[3/3/2018, 10:13:24 PM] [Mac] NetworkDevice "Mac" (192.168.1.236) went from status "Online" to "Shutting Down"
[3/3/2018, 10:13:39 PM] [Mac] Stopping pinger
[3/3/2018, 10:13:39 PM] [Mac] Starting pinger at an interval of 10000 milli seconds
[3/3/2018, 10:13:39 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:13:49 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:13:59 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:14:09 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:14:19 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:14:29 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:14:39 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:14:49 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:14:59 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:15:09 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:15:19 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:15:29 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:15:39 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:15:49 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:15:59 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:16:09 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:16:19 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:16:29 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:16:39 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:16:49 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down
[3/3/2018, 10:16:59 PM] [Mac] currentState: true, newState: true, this.status: Shutting Down

from homebridge-wol.

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

Now I see what you mean. In lib/network-device.js try to change lines 81-88 (pingerCallback(newState)) to the following:

pingerCallback(newState) {
   // The line under this comment has been changed - make sure both Offline and ShuttingDown is thought of as the host being down
    const currentState = this.status !== Status.Offline && this.status !== Status.ShuttingDown;
    // Debouncing - only react to a change if it has actually changed
    if (newState !== currentState) {
      this.pingLog('Pinger toggled state change');
      this.setStatus(newState ? Status.Online : Status.Offline);
    }
  }

The fault seems to be in the code thinking that everything that is not Offline is on. When the shutdownCommand is called, the host is put in the ShuttingDown mode. After 15 seconds the pinger starts to ping the host and realizes it is turned on. The pinger tells the server that the device is on, but it doesn't listen - it already thinks that the host is up since it's in ShuttingDown mode. This change makes the server listen to when the pinger says the host is up.

Please test the change and post any logs just like you did above.

from homebridge-wol.

hawkefly avatar hawkefly commented on May 14, 2024

Yes, this resolved my issue.Thanks.

[3/5/2018, 9:06:39 PM] Homebridge is running on port 51826.
[3/5/2018, 9:06:39 PM] [Mac] currentState: false, newState: true, this.status: Offline
[3/5/2018, 9:06:39 PM] [Mac] Pinger toggled state change
[3/5/2018, 9:06:39 PM] [Mac] NetworkDevice "Mac" (192.168.1.236) went from status "Offline" to "Online"
[3/5/2018, 9:06:46 PM] [Mac] NetworkDevice shutdown cycle started for "Mac" (192.168.1.236)
[3/5/2018, 9:06:46 PM] [Mac] Stopping pinger
[3/5/2018, 9:06:46 PM] [Mac] Starting pinger again in 15000 milli seconds
[3/5/2018, 9:06:46 PM] [Mac] Attempting to shut down "Mac" (192.168.1.236) using "date"
[3/5/2018, 9:06:46 PM] [Mac] NetworkDevice "Mac" (192.168.1.236) went from status "Online" to "Shutting Down"
[3/5/2018, 9:07:01 PM] [Mac] Stopping pinger
[3/5/2018, 9:07:01 PM] [Mac] Starting pinger at an interval of 10000 milli seconds
[3/5/2018, 9:07:01 PM] [Mac] currentState: false, newState: true, this.status: Shutting Down
[3/5/2018, 9:07:01 PM] [Mac] Pinger toggled state change
[3/5/2018, 9:07:01 PM] [Mac] NetworkDevice "Mac" (192.168.1.236) went from status "Shutting Down" to "Online"
[3/5/2018, 9:07:11 PM] [Mac] currentState: true, newState: true, this.status: Online
[3/5/2018, 9:07:21 PM] [Mac] currentState: true, newState: true, this.status: Online

from homebridge-wol.

AlexGustafsson avatar AlexGustafsson commented on May 14, 2024

Thank you, @hawkefly for helping me fix that bug! It's fixed in 3.2.1 which is now released to NPM so that you can safely use the latest available version.

from homebridge-wol.

cr3ative avatar cr3ative commented on May 14, 2024

Hi, this means that the status can never go from Shutting Down to Offline.
This means subsequent attempts to power it on are ignored as it's in an intermediate state.

I'm preparing a PR which should address this.

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.