Fix asuswrt AttributeError on neigh for unknown device (#11960)

This commit is contained in:
Ville Skyttä 2018-01-27 16:20:28 +02:00 committed by Martin Hjelmare
parent f1fc3c762a
commit 3af7c67bf1
2 changed files with 5 additions and 1 deletions

View file

@ -214,7 +214,8 @@ class AsusWrtDeviceScanner(DeviceScanner):
for device in result:
if device['mac'] is not None:
mac = device['mac'].upper()
old_ip = cur_devices.get(mac, {}).ip or None
old_device = cur_devices.get(mac)
old_ip = old_device.ip if old_device else None
devices[mac] = Device(mac, device.get('ip', old_ip), None)
return devices

View file

@ -447,6 +447,9 @@ class TestComponentsDeviceTrackerASUSWRT(unittest.TestCase):
scanner = get_scanner(self.hass, VALID_CONFIG_ROUTER_SSH)
scanner.connection = mocked_ssh
self.assertEqual(NEIGH_DEVICES, scanner._get_neigh(ARP_DEVICES.copy()))
self.assertEqual(NEIGH_DEVICES, scanner._get_neigh({
'UN:KN:WN:DE:VI:CE': Device('UN:KN:WN:DE:VI:CE', None, None),
}))
mocked_ssh.run_command.return_value = ''
self.assertEqual({}, scanner._get_neigh(ARP_DEVICES.copy()))