From e59d6b7da00c6bff95068ac64122d80218f22b48 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 2 Mar 2016 11:43:08 -0800 Subject: [PATCH] Fix SNMP device_tracker results without MAC addresses @llauren reported that his router returns empty MAC addresses for things on different subnets, which causes heartache for the HA snmp device tracker. --- homeassistant/components/device_tracker/snmp.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/device_tracker/snmp.py b/homeassistant/components/device_tracker/snmp.py index b7b59fbf95a..edff592f017 100644 --- a/homeassistant/components/device_tracker/snmp.py +++ b/homeassistant/components/device_tracker/snmp.py @@ -66,7 +66,8 @@ class SnmpScanner(object): """ self._update_info() - return [client['mac'] for client in self.last_results] + return [client['mac'] for client in self.last_results + if client.get('mac')] # Supressing no-self-use warning # pylint: disable=R0201 @@ -111,6 +112,7 @@ class SnmpScanner(object): for resrow in restable: for _, val in resrow: mac = binascii.hexlify(val.asOctets()).decode('utf-8') + _LOGGER.debug('Found mac %s', mac) mac = ':'.join([mac[i:i+2] for i in range(0, len(mac), 2)]) devices.append({'mac': mac}) return devices