Add more logging to help future debug situations (#29800)
This commit is contained in:
parent
7b8dff2aa9
commit
856dd63680
2 changed files with 24 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
||||||
"""Track devices using UniFi controllers."""
|
"""Track devices using UniFi controllers."""
|
||||||
import logging
|
import logging
|
||||||
|
from pprint import pformat
|
||||||
|
|
||||||
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
from homeassistant.components.device_tracker import DOMAIN as DEVICE_TRACKER_DOMAIN
|
||||||
from homeassistant.components.device_tracker.config_entry import ScannerEntity
|
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.
|
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()
|
await self.controller.request_update()
|
||||||
|
|
||||||
if self.is_wired and self.client.mac in self.controller.wireless_clients:
|
if self.is_wired and self.client.mac in self.controller.wireless_clients:
|
||||||
self.is_wired = False
|
self.is_wired = False
|
||||||
|
|
||||||
|
LOGGER.debug(
|
||||||
|
"Updating UniFi tracked client %s\n%s",
|
||||||
|
self.entity_id,
|
||||||
|
pformat(self.client.raw),
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
"""Return true if the client is connected to the network.
|
"""Return true if the client is connected to the network.
|
||||||
|
@ -246,11 +250,14 @@ class UniFiDeviceTracker(ScannerEntity):
|
||||||
|
|
||||||
async def async_update(self):
|
async def async_update(self):
|
||||||
"""Synchronize state with controller."""
|
"""Synchronize state with controller."""
|
||||||
LOGGER.debug(
|
|
||||||
"Updating UniFi tracked device %s (%s)", self.entity_id, self.device.mac
|
|
||||||
)
|
|
||||||
await self.controller.request_update()
|
await self.controller.request_update()
|
||||||
|
|
||||||
|
LOGGER.debug(
|
||||||
|
"Updating UniFi tracked device %s\n%s",
|
||||||
|
self.entity_id,
|
||||||
|
pformat(self.device.raw),
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
"""Return true if the device is connected to the network."""
|
"""Return true if the device is connected to the network."""
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
"""Support for devices connected to UniFi POE."""
|
"""Support for devices connected to UniFi POE."""
|
||||||
import logging
|
import logging
|
||||||
|
from pprint import pformat
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchDevice
|
from homeassistant.components.switch import SwitchDevice
|
||||||
from homeassistant.components.unifi.config_flow import get_controller_from_config_entry
|
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:
|
if not self.client.sw_port:
|
||||||
self.client.raw["sw_port"] = state.attributes["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
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
"""Return a unique identifier for this switch."""
|
"""Return a unique identifier for this switch."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue