From dc5f0ef314b049551215d5463bec6756c26dcfa5 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 8 Oct 2015 21:01:38 -0700 Subject: [PATCH] NMap: fix hostname resolver Fixes #482 --- homeassistant/components/device_tracker/nmap_tracker.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/device_tracker/nmap_tracker.py b/homeassistant/components/device_tracker/nmap_tracker.py index 8d9c2e72c20..247cbbfe7e8 100644 --- a/homeassistant/components/device_tracker/nmap_tracker.py +++ b/homeassistant/components/device_tracker/nmap_tracker.py @@ -123,9 +123,9 @@ class NmapDeviceScanner(object): for host in self.last_results: if host.last_update + self.home_interval > now: exclude_targets.add(host) - if len(exclude_targets) > 0: - target_list = [t.ip for t in exclude_targets] - options += " --exclude {}".format(",".join(target_list)) + if exclude_targets: + options += " --exclude {}".format(",".join(t.ip for t + in exclude_targets)) try: result = scanner.scan(hosts=self.hosts, arguments=options) @@ -137,7 +137,7 @@ class NmapDeviceScanner(object): for ipv4, info in result['scan'].items(): if info['status']['state'] != 'up': continue - name = info['hostnames'][0] if info['hostnames'] else ipv4 + name = info['hostnames'][0]['name'] if info['hostnames'] else ipv4 # Mac address only returned if nmap ran as root mac = info['addresses'].get('mac') or _arp(ipv4) if mac is None: