Presence through wifi router

I was going through the tutorial on detecting the presence of a phone on the network:

In my case, my phone and tablets connect to my net via wifi router.

So, in a text diagram:

phone --> wifi router --> lan -->firewall --> wan

When the binding does a search it finds devices on the lan which is 192.168.xx.*. One of which is the lan facing side of the wifi router, say, 192.168.xx.145. And OH is at 192.168.xx.220. But the phone is on the rf facing side of the router and is at 192.168.yy.100.

Do I need to add port forwarding and, if so, what service/protocol/port needs to be configured?

I’m wondering how others handle this? Or am I making it too complicated?

Well, having two different subnets is indeed creating complications.

Can you ping any IPs in the yy subdomain from a device in the xx subdomain? If not then you probably will not be able to get this to work because you have set up the network so the two subdomains cannot talk.

If so, then the Network binding should work because all it does is issue pings. However, I think it will only automatically discover devices on the same subnetwork as your OH server which is why the phones are not appearing in the inbox. You can manually add a Thing for the devices in that subnet by going to the Inbox, click the blue circle with the +, choose Network, and fill in the requested information.

Well, the network binding’s discovery process is very simple. It scans on one network, with subnet mask 24, for 254 addresses. I think the discovery process can be improved for multi-homed OH installations and the ones with bigger netmask, 16 bit. What do you think @David_Graeff ?

Well, I guess I took the easy way out…

I simply switched my router over to an access point. Thus the phone is now on the same subnet.

1 Like

So the detection is working fine.

But, it only sees the phone when it is not in sleep mode (or whatever it’s called when it turns the screen off and you need to enter the access code again (in my case a swipe after touching any button (volume up/down, etc.).

I’d think this is the behavior for any phone? Makes it difficult to use it for useful presence detection…or am I not getting the use case?

This is a limitation of the basic settings for the Network binding. Most newer phones ignore pings when they go to sleep. This is why the arping config was added. This binding does some networking magic to force the phone to respond even when it goes to sleep.

@diyha, do you have the link to the big thread where you talked the PR you just submitted to improve the Network binding? I can’t seem to find it on my phone easily.


Here is fixed binding itself, PR will be in soon

Basically you need to uninstall default network binding from PaperUI. Then drop above jar into addons folder of your openHAB. And then delete your Thing, re-add it, there will be a new parameter in Thing config, called “mac”, set it to your phone’s wifi mac. If you run into probs paste your logs here, some people might miss the setuid root step while installing arping tool, although its documented clearly here

I would be more cautious of recommending to uninstall a repo binding and installing a jar. Future updates will break this setup (i.e. the package manager will install a newer network binding at some point additionally).

Cheers, David

Agreed. Its a temporary situation till we discuss and merge the fixes that worked for me.

Summary info here

Just wanted to check this out, since my phone is being detected.

When I first put this binding in it was just using ping and when the phone went to sleep it showed as not present.
I posted on the forum and was told the binding was being updated.

I am currently on openHAB 2.4.0~20181004001205-1 (Build #1380).

I looked at the binding in habmin/paperui and don’t see a revision.

So how do I tell which version I’m using and if it’s using the newer presence detection?

It’s not clear to me from what I see in the logs.

And, if it isn’t, how do I fix that?