From 856dd6368085e6caf1ecce64a7642f3ad9af11ff Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Wed, 11 Dec 2019 15:45:21 +0100 Subject: [PATCH] Add more logging to help future debug situations (#29800) --- .../components/unifi/device_tracker.py | 19 +++++++++++++------ homeassistant/components/unifi/switch.py | 11 +++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/unifi/device_tracker.py b/homeassistant/components/unifi/device_tracker.py index 6c3701e883d..6dfa6a6ecad 100644 --- a/homeassistant/components/unifi/device_tracker.py +++ b/homeassistant/components/unifi/device_tracker.py @@ -1,5 +1,6 @@ """Track devices using UniFi controllers.""" import logging +from pprint import pformat from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN from homeassistant.components.device_tracker.config_entry import ScannerEntity @@ -156,14 +157,17 @@ class UniFiClientTracker(ScannerEntity): Make sure to update self.is_wired if client is wireless, there is an issue when clients go offline that they get marked as wired. """ - LOGGER.debug( - "Updating UniFi tracked client %s (%s)", self.entity_id, self.client.mac - ) await self.controller.request_update() if self.is_wired and self.client.mac in self.controller.wireless_clients: self.is_wired = False + LOGGER.debug( + "Updating UniFi tracked client %s\n%s", + self.entity_id, + pformat(self.client.raw), + ) + @property def is_connected(self): """Return true if the client is connected to the network. @@ -246,11 +250,14 @@ class UniFiDeviceTracker(ScannerEntity): async def async_update(self): """Synchronize state with controller.""" - LOGGER.debug( - "Updating UniFi tracked device %s (%s)", self.entity_id, self.device.mac - ) await self.controller.request_update() + LOGGER.debug( + "Updating UniFi tracked device %s\n%s", + self.entity_id, + pformat(self.device.raw), + ) + @property def is_connected(self): """Return true if the device is connected to the network.""" diff --git a/homeassistant/components/unifi/switch.py b/homeassistant/components/unifi/switch.py index e4192d0b6c7..5b64f573ccd 100644 --- a/homeassistant/components/unifi/switch.py +++ b/homeassistant/components/unifi/switch.py @@ -1,5 +1,6 @@ """Support for devices connected to UniFi POE.""" import logging +from pprint import pformat from homeassistant.components.switch import SwitchDevice from homeassistant.components.unifi.config_flow import get_controller_from_config_entry @@ -194,6 +195,16 @@ class UniFiPOEClientSwitch(UniFiClient, SwitchDevice, RestoreEntity): if not self.client.sw_port: self.client.raw["sw_port"] = state.attributes["port"] + async def async_update(self): + """Log client information after update.""" + await super().async_update() + + LOGGER.debug( + "Updating UniFi POE controlled client %s\n%s", + self.entity_id, + pformat(self.client.raw), + ) + @property def unique_id(self): """Return a unique identifier for this switch."""