1
mirror of https://github.com/home-assistant/core synced 2024-09-28 03:04:04 +02:00

UniFi - Log better information than a backtrace when poor switch data is involved (#31382)

This commit is contained in:
Robert Svensson 2020-02-01 20:48:23 +01:00 committed by GitHub
parent 43b11f6b39
commit 1edaae34c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,7 +216,15 @@ class UniFiPOEClientSwitch(UniFiClient, SwitchDevice, RestoreEntity):
@property
def port(self):
"""Shortcut to the switch port that client is connected to."""
return self.device.ports[self.client.sw_port]
try:
return self.device.ports[self.client.sw_port]
except TypeError:
LOGGER.warning(
"Entity %s reports faulty device %s or port %s",
self.entity_id,
self.client.sw_mac,
self.client.sw_port,
)
class UniFiBlockClientSwitch(UniFiClient, SwitchDevice):