AlexGustafsson / homebridge-wol

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

Plugin indicates PC is offline, but it responds to manual pings from the Homebridge device #174

Closed HammerAce42 closed 2 years ago

HammerAce42 commented 2 years ago

Backstory

I noticed my desktop is no longer detected as on, where as it previously it was.

Issue

The desktop's ip responds to pings sent via a terminal window in the same Homebridge instance, but the plugin's logs indicate the device is offline.

Furthermore when the PC is off / sleeping, it can still be correctly turned on using Homekit (but its status never remains on - it switches back to off after the 45 second wait period). Since the PC is never detected as on, I am unable to get it to shut down using Homekit.

Environment

Configuration

My configuration looks like this:

            "name":  "Desktop",
            "ip": "192.168.4.152",
            "pingInterval": 2,
            "pingsToChange": 5,
            "pingTimeout": 1,
            "pingCommandTimeout": 0,
            "mac": <mac-address>,
            "startCommandTimeout": 0,
            "wakeGraceTime": 45,
            "wakeCommandTimeout": 0,
            "shutdownCommand": <custom shutdown command>,
            "shutdownGraceTime": 15,
            "shutdownCommandTimeout": 0,
            "log": true,
            "logPinger": true,
            "debugLog": true,
            "returnEarly": true,
            "_bridge": {
                "username": <mac-address>,
                "port": <port>
            },
            "accessory": "NetworkDevice"

Log

When I follow these steps:

  1. Make sure logLevel is set to Debug on all NetworkDevice accessories
  2. Run homebridge
  3. Let it run for a couple of minutes
  4. Try to turn a device on or off using the plugin
  5. Wait one minute
  6. Repeat step 4

I get the following log (while sitting on the desktop PC filing the bug)

[10/5/2021, 9:46:21 PM] [Desktop] Got state change from pinger for "Desktop" (192.168.4.152): offline
[10/5/2021, 9:46:22 PM] [Desktop] Attempting to ping "Desktop" (192.168.4.152)
[10/5/2021, 9:46:23 PM] [Desktop] Result of pinging "Desktop" (192.168.4.152): offline
[10/5/2021, 9:46:24 PM] [Desktop] Attempting to ping "Desktop" (192.168.4.152)
[10/5/2021, 9:46:25 PM] [Desktop] Result of pinging "Desktop" (192.168.4.152): offline
[10/5/2021, 9:46:26 PM] [Desktop] Attempting to ping "Desktop" (192.168.4.152)
[10/5/2021, 9:46:27 PM] [Desktop] Result of pinging "Desktop" (192.168.4.152): offline
[10/5/2021, 9:46:28 PM] [Desktop] Attempting to ping "Desktop" (192.168.4.152)
[10/5/2021, 9:46:29 PM] [Desktop] Result of pinging "Desktop" (192.168.4.152): offline
[10/5/2021, 9:46:30 PM] [Desktop] Attempting to ping "Desktop" (192.168.4.152)
[10/5/2021, 9:46:31 PM] [Desktop] Result of pinging "Desktop" (192.168.4.152): offline
[10/5/2021, 9:46:31 PM] [Desktop] Got 0 positives out of 5

Here is the response to the ping command run via terminal in homebridge-ui-config (which should be running in the same networking context as the plugin)

/homebridge # ping 192.168.4.52
PING 192.168.4.52 (192.168.4.52) 56(84) bytes of data.
64 bytes from 192.168.4.52: icmp_seq=1 ttl=255 time=52.1 ms
64 bytes from 192.168.4.52: icmp_seq=2 ttl=255 time=3.97 ms
64 bytes from 192.168.4.52: icmp_seq=3 ttl=255 time=4.40 ms
64 bytes from 192.168.4.52: icmp_seq=4 ttl=255 time=3.73 ms
64 bytes from 192.168.4.52: icmp_seq=5 ttl=255 time=3.64 ms
64 bytes from 192.168.4.52: icmp_seq=6 ttl=255 time=5.54 ms
64 bytes from 192.168.4.52: icmp_seq=7 ttl=255 time=3.98 ms
AlexGustafsson commented 2 years ago

Your config specifies the IP address x.x.x.152 whilst you try to ping x.x.x.52 using the terminal. Is this a typo?

HammerAce42 commented 2 years ago

Doh. That is a sleep deprivation induced error :/

So, it turns out that the terminal is not responding to the ping either once I use the correct ip of 192.168.4.152.

Any ideas what might be causing a Windows 10 (and as of a couple of hours ago Windows 11) machine to not respond to pings but still respond correctly to a WoL packet?

HammerAce42 commented 2 years ago

Ah, the connection was configured as a public network instead of a private network. Changing that instantly fixed the issue. Apologies for the noise!

AlexGustafsson commented 2 years ago

Good that you solved it. Thanks for sharing the solution, it helps others with similar issues in the future.