Fix asuswrt AttributeError on neigh for unknown device (#11960)
This commit is contained in:
parent
f1fc3c762a
commit
3af7c67bf1
2 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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()))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue