Network Health Binding not working with Device Hostname


I have integrated network health binding to detect the presence of a nearby device.
I don’t have static ip so adding an ip to nh won’t help in my case.
So i tried putting the device hostname but it does not seem to work. It is always returning its state as OFF

Switch phone1 (gMobiles) {nh=“nexus4”}

I tried with assigning a static ip to my device and it worked properly. However, i need a solution which can be used with device host name.

Please Help me out!


I cant think of a way to make it work without setting up your own local dns server. Usually Windows machines can see eachother by hostname on a network, and they can even see Linux machines that t are running samba, but linux machines and mobile devices have to be in the hosts file (in which case they are static anyway) or you need to set up sone some of name server that keeps up with what ip your hosrs have been assigned. I just gave everything a static ip.

@rlkoshak Thank you for posting the solution however, i don’t want to set it up based on static ip. I thought of doing it based on mac addresses as i would not have to deal with ip’s and mac address stays unique in a dynamic ip scenario as well.
So i dig a little deeper and thought of writing a python script which could find out if the device is still connected. I came across a solution by doing an arp-scan on the network and comparing with the mac addresses of the device that i want to look for. And luckily it worked and now i want to set it up as a rule and execute the script at certain interval.
Is there any solution with which i can get the result from the script back into the rule?
I hope i am clear


You could set the mac address in the router to give always the same ip to your nexus, this is possible in almost every router and very easy.

@Udo_Hartmann Thanks. I have already tried that solution and it works like a charm.
However, i am also interested in the finding solution to the dynamic scenario as well.

Look at the exec binding and / or the executeCommandLine action.