Getting nmap to work on windows and also able to detect an android phone

Just wanted to offer the following tips for those wanting to get nmap working with windows 10 (including arp resolution).

  1. Create a separate nmap_tracker device_tracker. I called mine nmap_tracker2
  2. Change the arp option to be -a instead of -n in the _arp() function (you actually don’t need this however while debugging I figured this out)
  3. install nmap
  4. change the nmap options to be: “–disable-arp-ping -sn -n -PU1-10 --max-rate 100”

I found that the default local network arp-ping never detected an android phone. disabling arp-ping tends to yield more consistent results. note that at one point I tried -Pn -sn but that just incorrectly returns every device as always being there.

Finally, in your yaml file you can just list the hosts you explicitly want to scan for… in my case it looks like:

  hosts: 192.168.0.102 192.168.0.103 192.168.0.104 192.168.0.114 192.168.0.115
2 Likes

A word of caution with the above. If your local arp table isn’t populated, nmap will not successfully ping the devices with the above options. I hacked a fix by separately scheduling a ping every 5 minutes to force the arp resolution.

Works like a charm, kudos

With the current version of HA, the scan options can be specified directly in the config file.

It would be great if you could add this to the documentation of Nmap component.