ianperrin / MMM-NetworkScanner

A module for MagicMirror which determines the status of devices on the network based on their MAC or IP address
MIT License
107 stars 47 forks source link

keepalive does not work with device names which including spaces ["Nexus6P" vs. "Nexus 6P"] #20

Closed ndom91 closed 6 years ago

ndom91 commented 6 years ago

So after https://github.com/ianperrin/MMM-NetworkScanner/commit/6d5d1b198875bc298304d7624cbec08f90413f90 keepalive works as intended, but only when I name the device without a space in it, for example Nexus6P vs Nexus 6P

When I name the device Nexus 6P as soon as android does its sleep wifi business where MMM-NetworkScanner no longer finds it for a bit the screen turns off.

If I name it Nexus_6P this behavior is no longer seen. In fact, I see when android drops the wifi connection temporarily, because MMM-NetworkScanner now says NO DEVICES ONLINE, however because of the working keepalive is long enough it stays on until android decides to refresh some feed or pull emails or what have you where it needs an active wifi connection again

Btw - I've found 5min (300s) is an adequate time for Android phones to keep MMM-NetworkScanner to keep the screen on and not have intermittent screen off time due to Androids erratic wifi behavior.

Config:

        {
                module: "MMM-NetworkScanner",
                position: "bottom_left",
                config: {
                    devices: [
                            { macAddress: "A0:28:ED:69:8B:20", name: "Nokia_7P", icon: "mobile"},
                            { macAddress: "04:D6:AA:7C:B4:85", name: "Samsung_S8", icon: "mobile"}
                        ],
                    showUnknown: false,
                    showOffline: false,
                    keepAlive: 300,
                    updateInterval: 10,
                    residents: "Nokia_7P",
                    occupiedCMD: {notification: "REMOTE_ACTION", payload: {action: "MONITORON"}},
                    vacantCMD  : {notification: "REMOTE_ACTION", payload: {action: "MONITOROFF"}}
                }
        },

Now I do not have a degree in CS or anything, but my little experience with programming leads me to believe the variable for the device name just simply wasn't wrapped in quotes somewhere. Therefore the space breaks out of the variable too early and therefore breaks the keepalive functionality. Just my guess though. Thought it might at least lead someone onto the correct track..

leveneg commented 6 years ago

So just to be clear here- the issue is the monitor is turning off / on when it's not supposed to be?

If so- I suspect a mismatch between your devices & residents. With your current configuration, NetworkScanner will never realize any residents (Nico_7P) are on the network, because you don't have a device configured with the name "Nico_7P".

Personally, I don't use the occupiedCMD & vacantCMD options, but I have several devices configured with spaces in their name, and I haven't had issues otherwise.

ndom91 commented 6 years ago

Ah sorry that was a typo after I copied and pasted and did some editing, the devices and residents are the same.

EDIT: Hmm okay nevermind, keepalive still isn't working for me in general, I guess I was mistaken before haha.

EDIT2: Well I think I've found the culprit.. when manually running arp-scan I get segfaults haha. I'm going to close this issue and focus on getting arp-scan to run manually first.. Btw im running this on regular ol Raspberry Pi 3 with Raspbian Stretch, nothing fancy and no major changes.

EDIT3: arp-scan works when run with sudo - looks like you guys are executing it with sudo as well, so idk whats going on here haha. I'll keep looking, but again I think this issue is still, well, a non-issue :P