AlexGustafsson / homebridge-wol

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

Couldn't get PC status to be up #136

Closed angelflames1337 closed 2 years ago

angelflames1337 commented 3 years ago

WOL and shutting down is working fine, but the plugin will not recognize the PC state (up). I've played around with the timeout, without any result. Below is the log:

[1/17/2021, 9:46:05 PM] [Alienware] Attempting to ping "Alienware" (192.168.1.109) [1/17/2021, 9:46:05 PM] [Alienware] Result of pinging "Alienware" (192.168.1.109): offline [1/17/2021, 9:46:07 PM] [Alienware] Attempting to ping "Alienware" (192.168.1.109) [1/17/2021, 9:46:07 PM] [Alienware] Result of pinging "Alienware" (192.168.1.109): offline [1/17/2021, 9:46:09 PM] [Alienware] Attempting to ping "Alienware" (192.168.1.109) [1/17/2021, 9:46:09 PM] [Alienware] Result of pinging "Alienware" (192.168.1.109): offline [1/17/2021, 9:46:09 PM] [Alienware] Got 0 positives out of 5

Pinging from homebridge terminal looks ok, so the IP seems to be reachable from homebridge:

/homebridge # ping -c 2 192.168.1.109 PING 192.168.1.109 (192.168.1.109) 56(84) bytes of data. 64 bytes from 192.168.1.109: icmp_seq=1 ttl=128 time=0.316 ms 64 bytes from 192.168.1.109: icmp_seq=2 ttl=128 time=0.422 ms

Below is the plugin and homebridge versions, everything is at the latest:

homebridge-config-ui-x v4.36.0 homebridge-wol v4.3.0

Below is my config.json.

{
    "bridge": {
        "name": "Homebridge",
        "username": "0E:D9:62:AD:1A:DD",
        "port": 51202,
        "pin": "040-11-804"
    },
    "accessories": [
        {
            "accessory": "SonoffTasmotaHTTP",
            "name": "Counter Bulb",
            "hostname": "192.168.1.80"
        },
        {
            "accessory": "SonoffTasmotaHTTP",
            "name": "Downlight",
            "hostname": "192.168.1.81"
        },
        {
            "accessory": "SonoffTasmotaHTTP",
            "name": "Hall Light",
            "relay": "1",
            "hostname": "192.168.1.82"
        },
        {
            "accessory": "SonoffTasmotaHTTP",
            "name": "Hall Fan",
            "relay": "2",
            "hostname": "192.168.1.82"
        },
        {
            "name": "Alienware",
            "ip": "192.168.1.109",
            "pingInterval": 2,
            "pingsToChange": 5,
            "pingTimeout": 2,
            "pingCommandTimeout": 0,
            "mac": <mac-address>,
            "broadcastAddress": "192.168.1.255",
            "startCommandTimeout": 0,
            "wakeGraceTime": 45,
            "wakeCommandTimeout": 0,
            "shutdownCommand": "wget http://192.168.1.109:5001",
            "shutdownGraceTime": 15,
            "shutdownCommandTimeout": 0,
            "log": true,
            "logPinger": true,
            "debugLog": true,
            "returnEarly": true,
            "accessory": "NetworkDevice"
        }
    ],
    "platforms": [
        {
            "name": "Config",
            "port": 8080,
            "auth": "none",
            "theme": "auto",
            "tempUnits": "c",
            "lang": "auto",
            "platform": "config"
        },
        {
            "platform": "BraviaOSPlatform",
            "name": "BraviaTVOS",
            "tvs": [
                {
                    "name": "Sony Bravia TV",
                    "ip": "192.168.1.74",
                    "port": 80,
                    "timeout": 5,
                    "psk": "04011804",
                    "apps": [
                        "Kodi",
                        "YouTube",
                        "Netflix"
                    ],
                    "channels": [
                        "[3@tv:dvbt] TV3 HD"
                    ],
                    "speaker": {
                        "increaseBy": 1,
                        "reduceBy": 1
                    }
                }
            ]
        }
    ]
}

Appreciate your help, thanks.

AlexGustafsson commented 3 years ago

Are you running Windows? It seems like if your computer is ignoring pings. Can you try to ping your computer from another host via a terminal?

If I remember correctly, you’ll need to enable some setting under printers and sharing.

angelflames1337 commented 3 years ago

Correct it is running Windows. I don’t have any other terminal, but the PC is pingable from literally everything else (phone, other pc, and from homebridge terminal itself). I allowed the network discovery and disable the firewall but issue still persists.

AlexGustafsson commented 3 years ago

I haven't seen this issue before. Basically the plugin uses the provided IP without alteration and that code has been the same since the first version. The only thing I could image it could be is that pinging could require elevated privileges. But since you're able to ping from the homebridge terminal itself, I think it's safe to say we can rule that one out.

For sanity's sake, could you try the new version (https://github.com/AlexGustafsson/homebridge-wol/issues/124)?

angelflames1337 commented 3 years ago

Tried the beta, same thing. If it makes any difference, I am running this from docker.

AlexGustafsson commented 3 years ago

Try the following on the server running Docker.

List all running containers (you may need sudo).

docker ps
CONTAINER ID        IMAGE                   COMMAND             CREATED             STATUS              PORTS               NAMES
...

Find the homebridge server (identified either by name, command or image. Make a note of it's container id. Enter the container by running the following code.

docker exec -it my-container-id sh

Now, try to ping the computer's IP, your router and some other devices on the network.

ping 192.168.1.1
ping 192.168.1.109
ping 192.168.1.80

Does this work? If it does, then there's still an issue. If it doesn't, then your container isn't able to see your local network.

Since I assume the rest of your plugins work, there likely isn't any issue here. But it's one thing we'll have to rule out first.

angelflames1337 commented 3 years ago

Yeah, I am able to ping the PC

root@omv:~# docker ps
CONTAINER ID   IMAGE                             COMMAND        CREATED      STATUS        PORTS                                                                        NAMES
c47f488dfb30   linuxserver/transmission:latest   "/init"        8 days ago   Up 17 hours   0.0.0.0:9091->9091/tcp, 0.0.0.0:51413->51413/tcp, 0.0.0.0:51413->51413/udp   transmission
29d4b787e2d8   oznu/homebridge:latest            "/init"        9 days ago   Up 17 hours                                                                                homebridge
f9f8ca9936b1   portainer/portainer-ce            "/portainer"   9 days ago   Up 17 hours   0.0.0.0:8000->8000/tcp, 0.0.0.0:9000->9000/tcp                               portainer
root@omv:~#
root@omv:~# docker ex
exec    export
root@omv:~# docker exec -it 29d4b787e2d8 sh
/homebridge # ping 192.168.1.109
PING 192.168.1.109 (192.168.1.109) 56(84) bytes of data.
64 bytes from 192.168.1.109: icmp_seq=1 ttl=128 time=1.12 ms
64 bytes from 192.168.1.109: icmp_seq=2 ttl=128 time=0.549 ms

Could it still possibly be docker issue, just not network issue? I used to run homebridge standalone on pi and it works fine.

AlexGustafsson commented 3 years ago

Although it could be a Docker issue, it seems unlikely. I'm running oznu/homebridge myself and it works. There are also tests for this plugin using the very same image.

Can you check that you've started homebridge with --network=host?

docker inspect 29d4b787e2d8 | grep "NetworkMode"

We want it to look like so:

            "NetworkMode": "host",

And not like this:

            "NetworkMode": "default",
angelflames1337 commented 3 years ago

Yeah it looks correct


root@omv:~# docker inspect 29d4b787e2d8 | grep "NetworkMode"
            "NetworkMode": "host",

I'll try grabbing work laptop tomorrow and test to verify it is not PC issue.

dragosde commented 3 years ago

I am pretty sure it has something to do with the machine you are trying to wake. I had the wol plugin from the very beginning, (Thanks Alex for the great job!) for waking up my main machine and it would “keep the state”. And still does. As long as the PC is on I can see it “lit”/on in the home app. I just added another win PC to the plugin today. Wakes fine, so obviously works, and pings. However, the Home app brielfly shows it on and then, a few seconds later it returns to OFF even though the PC is still up and running. Since I run the same homebridge instance for both but only one reflects the correct state I can only assume it is something with the PC or with my router. Nonetheless I am curious about a solution to this too.

AlexGustafsson commented 3 years ago

@dragosde Thank you for the kind words.

All platforms should support responding to pings. Can you validate that you've set up the target to respond to them? The procedure is different for every operating system.

AlexGustafsson commented 2 years ago

I'm closing this as it doesn't seem to be a bug in the plugin. If you've solved the issue, please write your solution here. If the issue persists, try open a discussion about it and we'll take it from there.