Core: Error setting up platform nmap_tracker

Created on 28 Mar 2016  路  18Comments  路  Source: home-assistant/core

Home Assistant release (hass --version):
0.16.0

Python release (python3 --version):
Python 3.5.1

Component/platform:
nmap_tracker

Description of problem:
nmap_tracker throws an error and won't work when using "hass --install-osx" to launch home assistant.

Expected:
Everything should work/load without errors

Problem-relevant configuration.yaml entries and steps to reproduce:

device_tracker:
- platform: nmap_tracker
  hosts: 10.0.1.0/24
  scan_interval: 10
  consider_home: 1000
  track_new_devices: no
  1. Start using "hass --install-osx"

Traceback (if applicable):

INFO:homeassistant.loader:Loaded device_tracker.nmap_tracker from homeassistant.components.device_tracker.nmap_tracker
INFO:homeassistant.components.device_tracker.nmap_tracker:Scanning
ERROR:homeassistant.components.device_tracker:Error setting up platform nmap_tracker
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/device_tracker/__init__.py", line 118, in setup_platform
    scanner = platform.get_scanner(hass, {DOMAIN: p_config})
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 36, in get_scanner
    scanner = NmapDeviceScanner(config[DOMAIN])
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 66, in __init__
    self.success_init = self._update_info()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 289, in wrapper
    result = method(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 121, in _update_info
    mac = info['addresses'].get('mac') or _arp(ipv4)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 46, in _arp
    arp = subprocess.Popen(cmd, stdout=subprocess.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 950, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1544, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'arp'
INFO:homeassistant.loader:Loaded device_tracker.owntracks from homeassistant.components.device_tracker.owntracks

Additional info:

Running OS X 10.11.4

Works without problems when started manually from the terminal with "hass"

bug problem in dependency

Most helpful comment

updated /etc/systemd/system/[email protected] file to include /usr/sbin in the path.

Environment=PATH="$VIRTUAL_ENV/bin:/usr/sbin:$PATH"

This made it work under 0.37 for me.

All 18 comments

This is interesting that Home Assistant would not have access to arp while running as a service. This is a command line tool that is being used to convert from IP address to mac address.

Came across this.. On Debian (Jessie) (at least), this is due to "arp" being in /usr/sbin and therefore not in your path. Editing your local PATH to include this corrects the issue.

Could you provide more details hrabbit? I can use arp without problems in terminal.

Check it with $ which arp and compare the output of $ echo $PATH for the path where arp is located.

arp is located in a path included in my $PATH but I still get this error in my error logs.

$ which arp
/usr/sbin/arp
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/3.5/bin:~/.nvm/versions/node/v5.6.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

@trymbill Same here.

I just can't get it to work.

I am having the same issue on an rpi3. Happened once before and I don't remember what I did to fix it.

Aug 25 15:14:58 hass hass[14946]: ERROR:homeassistant.components.device_tracker:Error setting up platform nmap_tracker Aug 25 15:14:58 hass hass[14946]: Traceback (most recent call last): Aug 25 15:14:58 hass hass[14946]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/__init__.py", line 124, in setup_platform Aug 25 15:14:58 hass hass[14946]: scanner = platform.get_scanner(hass, {DOMAIN: p_config}) Aug 25 15:14:58 hass hass[14946]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 36, in get_scanner Aug 25 15:14:58 hass hass[14946]: scanner = NmapDeviceScanner(config[DOMAIN]) Aug 25 15:14:58 hass hass[14946]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 66, in __init__ Aug 25 15:14:58 hass hass[14946]: self.success_init = self._update_info() Aug 25 15:14:58 hass hass[14946]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 296, in wrapper Aug 25 15:14:58 hass hass[14946]: result = method(*args, **kwargs) Aug 25 15:14:58 hass hass[14946]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 121, in _update_info Aug 25 15:14:58 hass hass[14946]: mac = info['addresses'].get('mac') or _arp(ipv4) Aug 25 15:14:58 hass hass[14946]: File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 46, in _arp Aug 25 15:14:58 hass hass[14946]: arp = subprocess.Popen(cmd, stdout=subprocess.PIPE) Aug 25 15:14:58 hass hass[14946]: File "/usr/lib/python3.4/subprocess.py", line 859, in __init__ Aug 25 15:14:58 hass hass[14946]: restore_signals, start_new_session) Aug 25 15:14:58 hass hass[14946]: File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child Aug 25 15:14:58 hass hass[14946]: raise child_exception_type(errno_num, err_msg) Aug 25 15:14:58 hass hass[14946]: FileNotFoundError: [Errno 2] No such file or directory: 'arp'

Not sure if the input is helpfull, but I got the same problem.
I was running it in sudo and it worked fine, the moment I put it in crontab of root I got the same error.

INFO:homeassistant.components.device_tracker.nmap_tracker:Scanning ERROR:homeassistant.components.device_tracker:Error setting up platform nmap_tracker Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/__init__.py", line 132, in setup_platform scanner = platform.get_scanner(hass, {DOMAIN: p_config}) File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 36, in get_scanner scanner = NmapDeviceScanner(config[DOMAIN]) File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 66, in __init__ self.success_init = self._update_info() File "/usr/local/lib/python3.4/dist-packages/homeassistant/util/__init__.py", line 296, in wrapper result = method(*args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 121, in _update_info mac = info['addresses'].get('mac') or _arp(ipv4) File "/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/nmap_tracker.py", line 46, in _arp arp = subprocess.Popen(cmd, stdout=subprocess.PIPE) File "/usr/lib/python3.4/subprocess.py", line 859, in __init__ restore_signals, start_new_session) File "/usr/lib/python3.4/subprocess.py", line 1457, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'arp'

nmap wasn't finding arp.

sbin is in the path, but it wouldn't work until I made a link for it in bin
I came up with this fix, is it proper?

sudo ln -s /usr/sbin/arp /usr/bin/arp

I just applied a fix to the code, testing it now - will update in 15mins
I think the problem is that root does not know where to find it, so I told it.

/usr/local/lib/python3.4/dist-packages/homeassistant/components/device_tracker/nmap_tracker.py line 45
update to:
cmd = ['/usr/sbin/arp', '-n', ip_address]
from
cmd = ['arp', '-n', ip_address]

PS: when making changes, you need to save before you reboot to test :P

@fabaff @trainman419
Found the fix, as per my last post and it works, as per below.

INFO:homeassistant.loader:Loaded device_tracker.nmap_tracker from homeassistant.components.device_tracker.nmap_tracker INFO:homeassistant.components.device_tracker.nmap_tracker:No MAC address found for 10.0.66.4 INFO:homeassistant.components.device_tracker.nmap_tracker:nmap scan successful

this fix works for me, please put it in the next update

Worked just fine. Thanks!

/Ola

for every one with the All in One installation... The path is different as the above given. So check out this:

/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/device_tracker/nmap_tracker.py

Problem is still unsolved with version 0.37 :(

updated /etc/systemd/system/[email protected] file to include /usr/sbin in the path.

Environment=PATH="$VIRTUAL_ENV/bin:/usr/sbin:$PATH"

This made it work under 0.37 for me.

Running 0.38.4, can get nmap_tracker to function, tried above fix no joy.

Used HASSbian 1.1 - The Toy-box image, has this been fixed? or do I need to do any changes?

Same problem with newest HASS version on debian amd64 stable

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sibbl picture sibbl  路  3Comments

Elmardus picture Elmardus  路  3Comments

aweb-01 picture aweb-01  路  3Comments

piitaya picture piitaya  路  3Comments

arangates picture arangates  路  3Comments