Nmap not configuring

Hi all, I must start with saying I am new to this whole thing. So bear with me please. I am trying to set up the nmap component and it seems to not be loading. I tried using the Bluetooth tracker but had issues as well so Lets see what can be done.

This is on a Windows 10 installation of HA, Eventually I will set it up on a pi3, but am lacking the funds at the moment lol.

Thank you in adance!

this is the configuration I have.

#bluetooth tracker
device_tracker:

  • platform: bluetooth_tracker
    interval_seconds: 12
    track: true

  • platform: nmap_tracker
    hosts: 192.168.1.1-255
    track: true

This is my Known devices file. (the second one was added by the Bluetooth tracker. It shows me a different mac address than my router or the phone itself is showing. I left both in to see if either one starts working.

windows_phone:
hide_if_away: false
mac: BT_xx:xx:xx:xx:xx:xx
name: Noah’s Phone
picture:
track: true

windows_phone_2:
hide_if_away: false
mac: BT_xx:xx:xx:xx:xx:xx
name: Windows phone
picture:
track: true

So what is going wrong here? When I restart HA it will sometimes show Noah’s phone as home, even after turning off the phone or leaving for a while. About an hour AFTER restarting the server it turns my phone to “away” and there it stays.

Here is the log file from the last attempt.

16-11-30 22:08:51 homeassistant.components.device_tracker: Error setting up platform bluetooth_tracker
Traceback (most recent call last):
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker_init_.py”, line 145, in setup_platform
if not platform.setup_scanner(hass, p_config, tracker.see):
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker\bluetooth_tracker.py”, line 89, in setup_scanner
update_bluetooth(dt_util.utcnow())
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker\bluetooth_tracker.py”, line 79, in update_bluetooth
result = bluetooth.lookup_name(mac, timeout=5)
File “C:\Users\Mason\AppData\Roaming.homeassistant\deps\bluetooth\msbt.py”, line 33, in lookup_name
return bt.lookup_name (address)
OSError: The operation completed successfully.

16-11-30 22:08:51 homeassistant.components.device_tracker: Error setting up platform nmap_tracker
Traceback (most recent call last):
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker_init_.py”, line 136, in setup_platform
scanner = platform.get_scanner(hass, {DOMAIN: p_config})
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker\nmap_tracker.py”, line 42, in get_scanner
scanner = NmapDeviceScanner(config[DOMAIN])
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker\nmap_tracker.py”, line 75, in init
self.success_init = self.update_info()
File "C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\util_init
.py", line 296, in wrapper
result = method(*args, **kwargs)
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker\nmap_tracker.py”, line 103, in _update_info
scanner = PortScanner()
File “C:\Users\Mason\AppData\Roaming.homeassistant\deps\nmap\nmap.py”, line 131, in init
os.getenv(‘PATH’)
nmap.nmap.PortScannerError: ‘nmap program was not found in path. PATH is : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\;C:\Users\Mason\AppData\Local\Microsoft\WindowsApps;’

This is your problem, you either don’t have nmap installed, or hass can’t find it. I’m not sure nmap exists for windows, you’ll have to do some research. If you have installed it already, you need to add it to your path.

It’s been a long time since I ran HA on Windows; moving to Pi was one of the smartest things I ever did as I spent more time trying to get things to run than I did actually playing with HA. But I think I had to run the following to get NMap installed in Python for WIndows:

py -m pip install python-nmap

Thanks! I will give it a go this evening when I get home. I plan on moving up to a pi3 when funds allow. Too much things I want to do, not enough fundage to do them :slight_smile:

We all know that problem! If this doesn’t work let me know; I’ll try to see if I can remember anything else and see if I have any traces left of the old install on my Windows box.

Thank you for the help so far. I think I am getting closer. I did the install of the nmap package to python, and it was not installed.

It is however still not finding it. The package installed to:

\FAMILYPANEL\homeauto\Users\Mason\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\nmap
(I verified that it was there)

I wonder (as someone with no experience with this) if the program is not mapping to the correct path, and if there is a way I can force it to look at this path.

I am still getting this in the log file though.

16-12-01 18:28:47 homeassistant.components.device_tracker: Error setting up platform nmap_tracker
Traceback (most recent call last):
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker_init_.py”, line 136, in setup_platform
scanner = platform.get_scanner(hass, {DOMAIN: p_config})
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker\nmap_tracker.py”, line 42, in get_scanner
scanner = NmapDeviceScanner(config[DOMAIN])
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker\nmap_tracker.py”, line 75, in init
self.success_init = self.update_info()
File "C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\util_init
.py", line 296, in wrapper
result = method(*args, **kwargs)
File “C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\lib\site-packages\homeassistant\components\device_tracker\nmap_tracker.py”, line 103, in _update_info
scanner = PortScanner()
File “C:\Users\Mason\AppData\Roaming.homeassistant\deps\nmap\nmap.py”, line 131, in init
os.getenv(‘PATH’)
nmap.nmap.PortScannerError: ‘nmap program was not found in path. PATH is : C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\Mason\AppData\Local\Programs\Python\Python35-32\;C:\Users\Mason\AppData\Local\Microsoft\WindowsApps;’

You need ‘\FAMILYPANEL\homeauto\Users\Mason\AppData\Local\Programs\Python\Python35-32\Lib\site-packages’ to add to your path.

This link looks like it will show you how (but I haven’t followed it myself)

No go. I added the path to PATH, and it is coming back with the same error message. I even copied the nmap folder to one of the other paths just to see if it would somehow see it in there and well… nope :frowning:

That is odd. Can you run the nmap program from the command line?

Well if I did this correctly (still new to python) I get an error running it because it is a package and cannot be directly executed.

The exact error is
no module named nmap.__main; ‘nmap’ is a package and cannot be directly executed

I think the python package you installed was just a python interface to the nmap program, that doesn’t include the nmap program itself.

Try installing nmap from here and adding the location of it to your path.

To clean up, you should remove the other addition you made to the path, because I thought that was actually the program itself.

Absolutely correct - I missed this in my response, sorry.

BOOM!!

I installed nmap (did not know there was a program that needed to be installed) It did find everything and load nmap. I commented out all of the known devices to see if it would find my device again and sadly it has not.

so nmap is running, its just not finding my device. not sure where to go from here.

This was the only thing in the log file, and I am not sure if it has anything to do with nmap.

16-12-03 11:55:42 homeassistant.components.recorder: Error during query: (sqlite3.OperationalError) database is locked

Now to try to convince my wife to let me get the pi3 and what not lol, probably a loosing battle at the moment though.

Great news and again sorry for not pointing that out. I hate misreading things.

Not a problem, there is tons of stuff here, it seems to be pretty easy to miss something. Now to figure out why nmap is not discovering my phone.

1 Like

I have:
Windows 10
Python 3.6 (64bit)
Hass 0.44.2

I installed NMAP from here
and also installed:
pip3 install python-nmap
pip3 install python-libnmap

enviroment variables show nmap folder and opening CMD and typing nmap --version returns:
Nmap version 7.40 ( https://nmap.org )
Platform: i686-pc-windows-windows
Compiled with: nmap-liblua-5.3.3 openssl-1.0.2j nmap-libpcre-7.6 Npcap-0.78 r5 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: iocp poll select

I still get an error, which I pint point to nmap device tracker and so forth disabled it within hass conf.

My log, below…any ideas?

last line before error** e[32m2017-05-18 00:02:47 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=device_tracker.toyota_prius, old_state=None, new_state=<state device_tracker.toyota_prius=home; source_type=gps, latitude=here, longitude=there, gps_accuracy=15.17, fuel_level=None, friendly_name=Toyota Prius, entity_picture=/local/prius.jpg, icon=mdi:car @ 2017-05-18T00:02:47.764743-04:00>>e[0m
Traceback (most recent call last):
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\runpy.py”, line 193, in run_module_as_main
main”, mod_spec)
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\runpy.py”, line 85, in run_code
exec(code, run_globals)
File "C:\Users\aelg5\AppData\Local\Programs\Python\Python36\Scripts\hass.exe_main
.py", line 9, in
File "c:\users\aelg5\appdata\local\programs\python\python36\lib\site-packages\homeassistant_main
.py", line 396, in main
exit_code = setup_and_run_hass(config_dir, args)
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\site-packages\homeassistant_main_.py”, line 307, in setup_and_run_hass
log_rotate_days=args.log_rotate_days)
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\site-packages\homeassistant\bootstrap.py”, line 167, in from_config_file
config_path, hass, verbose, skip_pip, log_rotate_days)
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\asyncio\base_events.py”, line 454, in run_until_complete
self.run_forever()
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\asyncio\base_events.py”, line 421, in run_forever
self._run_once()
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\asyncio\base_events.py”, line 1389, in _run_once
event_list = self._selector.select(timeout)
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\asyncio\windows_events.py”, line 419, in select
self._poll(timeout)
File “c:\users\aelg5\appdata\local\programs\python\python36\lib\asyncio\windows_events.py”, line 670, in _poll
raise ValueError(“timeout too big”)
ValueError: timeout too big
e[32m2017-05-18 00:03:22 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x000002D8CA843B70>_4) [homeassistant.components.device_tracker.nmap_tracker] No MAC address found for 10.0.0.50e[0m
e[32m2017-05-18 00:03:22 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x000002D8CA843B70>_4) [homeassistant.components.device_tracker.nmap_tracker] nmap scan successfule[0m
e[32m2017-05-18 00:03:22 INFO (<concurrent.futures.thread.ThreadPoolExecutor object at 0x000002D8CA843B70>_4) [homeassistant.components.device_tracker.nmap_tracker] Scanner initializede[0m

I never could get it to work with Windows 10. Shortly after asking my initial post I moved HA over to a Raspberry pi 3 and have not looked back. I love windows 10, but with HA it is not that great of a server. I actually have now given up on NMAP on my pi3 as well. I have been using owntracks with mild success. (moved from my beloved 950xl, to an LG G6 android device)