From 1edaae34c5618fe5b9154fb35b472969841706d7 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Sat, 1 Feb 2020 20:48:23 +0100 Subject: [PATCH] UniFi - Log better information than a backtrace when poor switch data is involved (#31382) --- homeassistant/components/unifi/switch.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/unifi/switch.py b/homeassistant/components/unifi/switch.py index be6002e886e9..941f4f8ab84d 100644 --- a/homeassistant/components/unifi/switch.py +++ b/homeassistant/components/unifi/switch.py @@ -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):