[userModule] Network Presence

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
Post Reply
Provo
Posts: 87
Joined: 19 Oct 2016 19:54

[userModule] Network Presence

Post by Provo » 06 Jan 2018 13:29

There already exists a userModule called Ping Presence that lets you ping an IP to track its presence on the network. However, this module is a singleton which means you can only have one instance of it, and it only lets you track a single IP. I needed to track several, and I wanted better control of parameters like time between pings, ping timeout, number of packets, etc. The creator of the Ping Presence module doesn't seem to be active anymore, so I created a new one with the features I need.

The way it works should be fairly self explanatory, but if you have questions, feel free to ask them here. Regarding bug reports and feature requests, please post them in this thread or as issues on the projects gitlab page.

To install through the app store, use the token kvolden_beta or wait until the ZWay team has verified it.

robbelt
Posts: 6
Joined: 27 May 2016 09:00

Re: [userModule] Network Presence

Post by robbelt » 11 Jan 2018 01:02

Works realy nice with my Android-Phone. But what about an iPhone which disables Wifi on Standby/Lockscreen?

Provo
Posts: 87
Joined: 19 Oct 2016 19:54

Re: [userModule] Network Presence

Post by Provo » 11 Jan 2018 09:15

Glad you liked it.

As I wrote in the description, many modern smart phones put their WiFi to sleep after the display is turned off. This is true for many Android phones as well. There's not really anything that can be done to prevent this on the module side, unfortunately. You will have to change the phone's WiFi/power settings, if possible, such that the WiFi remains on and the phone can reply to ping.

robbelt
Posts: 6
Joined: 27 May 2016 09:00

Re: [userModule] Network Presence

Post by robbelt » 11 Jan 2018 12:36

Maybe it is prossible to improve the presence detection using hping like mentioned here? https://community.openhab.org/t/iphone- ... rp/18171/9

Another great feature would be to have the possibility to configure a delay (in minutes) after that the presence is switched to "absent". So only if no ping was successfull in the last maybe 30 minutes switch to "absent". This can be very useful in some usecases to make the presence detection more robust. An easy way to implement this can be to make your "ping hysteresis" configurable (not only the last three pings).

Provo
Posts: 87
Joined: 19 Oct 2016 19:54

Re: [userModule] Network Presence

Post by Provo » 11 Jan 2018 15:23

robbelt wrote:
11 Jan 2018 12:36
Maybe it is prossible to improve the presence detection using hping like mentioned here? https://community.openhab.org/t/iphone- ... rp/18171/9
I'm not super familiar with hping, but I don't think hping itself will help. The solution you link to also uses arp, but in my experience that's not very reliable for device detection in general – for instance, it seems that Android devices are undiscoverable with arp. What seems to make that solution somewhat reliable, is something similar to what I called "ping hysteresis", only with 19 instead of 3 attempts.

It's fair to say that if the WiFi is turned off, it's not connected to the local network anymore, and it will not be discovered as such. But thanks for the suggestion, though.
robbelt wrote:
11 Jan 2018 12:36
Another great feature would be to have the possibility to configure a delay (in minutes) after that the presence is switched to "absent". So only if no ping was successfull in the last maybe 30 minutes switch to "absent". This can be very useful in some usecases to make the presence detection more robust. An easy way to implement this can be to make your "ping hysteresis" configurable (not only the last three pings).
Yes, I've actually been thinking about making the size of the hysteresis configurable, like you're suggesting. I'll see if I can get around to implementing that as soon as I find the time.

Thanks for your input, much appreciated.

Provo
Posts: 87
Joined: 19 Oct 2016 19:54

Re: [userModule] Network Presence

Post by Provo » 13 Jan 2018 13:25

Version 0.1 was just verified and can be installed without the token.

I have also updated the module to version 0.2. It is no longer a singleton, so if you want to add devices with different settings, you can now instantiate several instances each with different settings for their associated devices. I have also added configurability to the ping hysteresis size.

Beware, I just realized there is no sanity checking on the hysteresis size. Make sure this is 1 or more, or it will have strange side effects. I will get to fixing this as soon as I can.

Provo
Posts: 87
Joined: 19 Oct 2016 19:54

Re: [userModule] Network Presence

Post by Provo » 14 Jan 2018 12:05

Ping hysteresis size is now limited to no less than 2 (1 would not produce unexpected side effects, but is equivalent to no hysteresis). Version is bumped to 0.3 to make sure the update is pushed. This version is currently being verified, but it's available with the token mentioned in the first post.

Post Reply