UniFi - honor detection time when UniFi wire bug happens (#29820)

This commit is contained in:
Robert Svensson
2019-12-10 20:05:18 +01:00
committed by GitHub
parent 47e5142ddb
commit 99328bd4c1
2 changed files with 28 additions and 9 deletions
@@ -127,6 +127,7 @@ class UniFiClientTracker(ScannerEntity):
self.client = client
self.controller = controller
self.is_wired = self.client.mac not in controller.wireless_clients
self.wired_bug = None
@property
def entity_registry_enabled_default(self):
@@ -169,13 +170,18 @@ class UniFiClientTracker(ScannerEntity):
If is_wired and client.is_wired differ it means that the device is offline and UniFi bug shows device as wired.
"""
if self.is_wired == self.client.is_wired and (
(
dt_util.utcnow()
- dt_util.utc_from_timestamp(float(self.client.last_seen))
if self.is_wired != self.client.is_wired:
if not self.wired_bug:
self.wired_bug = dt_util.utcnow()
since_last_seen = dt_util.utcnow() - self.wired_bug
else:
self.wired_bug = None
since_last_seen = dt_util.utcnow() - dt_util.utc_from_timestamp(
float(self.client.last_seen)
)
< self.controller.option_detection_time
):
if since_last_seen < self.controller.option_detection_time:
return True
return False