Networkhealth not working?

Hello,

I’m trying to configure networkhealth binding to detect when I’m in home or not depending if openhab detects my smartphone.

So I have configured an item:

Switch movil_amateo “Móvil AL” (G_moviles) { nh=“192.168.1.157” }

where 192.168.1.157 is the IP my dhcp assigns to my cell phone.

When I configured this I made a test and it worked, but now I’m turning my wifi off, but networkhealt still reports my phone as present:

2015-12-29 13:33:43.748 [DEBUG] [o.o.b.n.i.NetworkHealthBinding] - established connection [host ‘192.168.1.157’ port ‘0’ timeout ‘5000’]

but pinging to this IP doesn’t respond.

I have openhab 1.7.1 installed from packages in a raspberry pi 2, and networkhealth binding has its default configuration.

Any help?

I’ve found that it can take some minutes sometimes for NH to detect that a device is no longer on the network. Also, I’ve found it to frequently lose the connection to devices that are indeed connected to the network. How long do you wait for on NH to report that the device is no longer attached?

Also how are you verifying the switch state? I’ve found sometimes the web page doesn’t immediately refresh the current state of my presence switches and the Android app is even more hesitant to report the updated. If you aren’t looking at the logs it could be working but the UI is just not showing it yet. A refresh of the page or going into a subframe and back out again should refresh the page with the current states.

Finally, it is better to assign a static IP to your phone. If by “dhcp assigns to my cell phone” that your router always assigns the same IP to your phone’s mac address then you are good. If that is the IP that it happens to be assigning right now you may find that if your router ever gets rebooted that your phone gets a new IP address. You can set a static IP address in the advanced wifi settings on your phone.

Do you have the rule file setup so that it periodically checks ?

If you have NH bound to a Switch the Switch should move from OFF to ON and back without a rule to check. The purpose of that example is to not set the parent Present switch to OFF until all of the child NH Switches have been off for five minutes. That is a really important rule to be aware of but it doesn’t address OP’s problem that his NH switch is not reflecting that his phone is actually off the network.

I’ve been waiting for more than 30 minutes without any result.

I’m looking at log files

I know this. I have configure my firewall to always assign the same IP to the phone.

I have created my config from this post. My problem is not with rules, I’m looking in the log files.