Add more logging to help future debug situations (#29800)

This commit is contained in:
Robert Svensson 2019-12-11 15:45:21 +01:00 committed by Paulus Schoutsen
parent 7b8dff2aa9
commit 856dd63680
2 changed files with 24 additions and 6 deletions

View file

@ -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."""

View file

@ -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."""