Add extra attributes for device scanner, Nmap and Unifi (IP, SSID, etc.) (#13673)

* Start of development

* Add extra attributes from unifi scanner

* Store IP of the device in the state attributes with nmap

* Allow not defining get_extra_attributes method in derived classes
This commit is contained in:
stephanerosi authored and Fabian Affolter committed 2018-04-16 08:20:58 +02:00
1 parent 517fb2e983
commit 36a663adeb
3 files changed
+39 -1

No files matched your search

@@ -80,6 +80,8 @@ class NmapDeviceScanner(DeviceScanner):
"""Scan for new devices and return a list with found device IDs."""
self._update_info()
_LOGGER.debug("Nmap last results %s", self.last_results)
return [device.mac for device in self.last_results]
def get_device_name(self, device):
@@ -91,6 +93,15 @@ class NmapDeviceScanner(DeviceScanner):
return filter_named[0]
return None
def get_extra_attributes(self, device):
"""Return the IP pf the given device."""
filter_ip = [result.ip for result in self.last_results
if result.mac == device]
if filter_ip:
return {'ip': filter_ip[0]}
return None
def _update_info(self):
"""Scan the network for devices.