NMAP not working - no PyPi connection

Hey all,

I have just started to explore the beauty of HASS, but sadly enough I am already encountering my first obstacle and I hope you guys can help me out.

I installed HASS using the All-In-One installer on a RPi - Model B Revision 2.0. HASS is accessible. I wanted to try out some settings and the easiest for me to do is using nmap to find a device (as I don’t have any zwave stuff yet…). So I added the following part to the configuration.yaml:

# Track devices
device_tracker:
    platform: nmap_tracker
    hosts: 192.168.2.1/24
    home_interval: 10

After rebooting HASS (both just HASS and the RPi), I don’t get the known_devices.yaml. So I opened the log file and saw that there was a problem installing the python dependency for nmap. I already increased the logging level to “debug”. I have the following log file as a result:

16-09-15 07:20:48 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=logger>
16-09-15 07:20:49 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=http>
16-09-15 07:20:49 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=discovery>
16-09-15 07:20:49 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=api>
16-09-15 07:20:49 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=frontend>
16-09-15 07:20:49 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=logbook, service=log>
16-09-15 07:20:49 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=logbook>
16-09-15 07:20:49 requests.packages.urllib3.connectionpool: Starting new HTTPS connection (1): pypi.python.org
16-09-15 07:20:55 homeassistant.components.updater: Could not contact PyPI to check for updates
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 142, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 75, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 595, in urlopen
    chunked=chunked)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 352, in _make_request
    self._validate_conn(conn)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 831, in _validate_conn
    conn.connect()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 254, in connect
    conn = self._new_conn()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 151, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb23329b0>: Failed to establish a new connection: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 640, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 287, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /pypi/homeassistant/json (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb23329b0>: Failed to establish a new connection: [Errno -2] Name or service not known',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/updater.py", line 47, in get_newest_version
    req = requests.get(PYPI_URL)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /pypi/homeassistant/json (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0xb23329b0>: Failed to establish a new connection: [Errno -2] Name or service not known',))
16-09-15 07:20:55 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=updater>
16-09-15 07:20:55 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=conversation, service=process>
16-09-15 07:20:55 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=conversation>
16-09-15 07:20:55 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=history>
16-09-15 07:20:55 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=mqtt, service=publish>
16-09-15 07:20:55 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=mqtt>
16-09-15 07:20:55 homeassistant.components.zone: Adding new zone Home
16-09-15 07:20:55 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=zone.home, new_state=<state zone.home=zoning; icon=mdi:home, latitude=51.8901, radius=100, friendly_name=Home, hidden=True, longitude=5.8913 @ 2016-09-15T09:20:55.934863+02:00>, old_state=None>
16-09-15 07:20:55 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=zone>
16-09-15 07:20:55 homeassistant.loader: Loaded device_tracker.nmap_tracker from homeassistant.components.device_tracker.nmap_tracker
16-09-15 07:20:56 homeassistant.util.package: Attempting install of python-nmap==0.6.1
16-09-15 07:21:43 homeassistant.bootstrap: Not initializing device_tracker.nmap_tracker because could not install dependency python-nmap==0.6.1
16-09-15 07:21:44 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=0, elevation=0, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>, old_state=None>
16-09-15 07:21:44 homeassistant.core: Bus:Handling <Event component_loaded[L]: component=sun>
16-09-15 07:21:44 homeassistant.core: Starting Home Assistant (15 threads)
16-09-15 07:21:44 homeassistant.core: Bus:Handling <Event homeassistant_start[L]>
16-09-15 07:21:44 homeassistant.core: Timer:starting
16-09-15 07:21:44 netdisco.service: Scanning
16-09-15 07:21:48 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=homeassistant, service=stop>
16-09-15 07:21:48 homeassistant.core: Bus:Handling <Event service_registered[L]: domain=homeassistant, service=restart>
16-09-15 07:22:25 homeassistant.components.mqtt: Successfully reconnected to the MQTT server
16-09-15 07:22:31 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=110.77, elevation=19.05, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>, old_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=0, elevation=0, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>>
16-09-15 07:23:31 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=110.99, elevation=19.19, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>, old_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=110.77, elevation=19.05, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>>
16-09-15 07:24:31 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=111.2, elevation=19.33, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>, old_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=110.99, elevation=19.19, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>>
16-09-15 07:25:31 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=111.42, elevation=19.48, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>, old_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=111.2, elevation=19.33, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>>
16-09-15 07:26:31 homeassistant.core: Bus:Handling <Event state_changed[L]: entity_id=sun.sun, new_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=111.64, elevation=19.62, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>, old_state=<state sun.sun=above_horizon; next_rising=2016-09-16T05:14:04+00:00, azimuth=111.42, elevation=19.48, next_setting=2016-09-15T17:50:23+00:00, friendly_name=Sun @ 2016-09-15T09:21:44.045276+02:00>>

I don’t know if the connection problems to PyPi are related. I checked if nmap works apart from HASS, and that is the case.

Another piece of information from which I don’t know if it is important: I cannot run stuff like “hass --version”.

I hope you guys can help me in any way possible! If you need more information, let me know.

Into https://home-assistant.io/components/device_tracker.nmap_scanner/ you can read:

If you’re on Debian or Ubuntu, you might have to install the packages for arp and nmap. Do so by running apt-get install net-tools nmap. On a Fedora host run sudo dnf -y install nmap.

Did you installed the package?

@Ivor have you by any chance tried to set up a static IP on your Pi? I was getting similar connection errors and figured out I had messed up that process. My solution: Trouble updating Home Assistant...among a cluster of issues

If you’re SSHing into your Pi, try the following shell command:
ping google.com

@michel.settembrino: I believe I tried that. The nmap is working and I don’t see any reference on the arp package.

@quantumpelvis: I did actually do that. I didn’t check your post as the title didn’t trigger me (I updated HASS and it seemed to work just fine…). But that might have actually been HASS misleading me. It sounds like this could be the issue. I can’t try it out now, but I’ll let you know when I tried it.

Thanks for the both of you for your quick reply!

2 Likes

@Ivor Yeah your connection errors look very similar to mine. Hope it works for you.

I just tried it andit works perfectly. So thanks for the quick help guys!

1 Like