mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
UniFi - Improve client tracker attributes based on connection (#32817)
* Improve client tracker attributes by setting them to None when client is disconnected * Fix martins comment
This commit is contained in:
parent
738ef38ddc
commit
529656cf64
@ -16,26 +16,28 @@ from .unifi_client import UniFiClient
|
|||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
DEVICE_ATTRIBUTES = [
|
CLIENT_CONNECTED_ATTRIBUTES = [
|
||||||
"_is_guest_by_uap",
|
"_is_guest_by_uap",
|
||||||
"ap_mac",
|
"ap_mac",
|
||||||
"authorized",
|
"authorized",
|
||||||
"essid",
|
"essid",
|
||||||
"hostname",
|
|
||||||
"ip",
|
"ip",
|
||||||
"is_11r",
|
"is_11r",
|
||||||
"is_guest",
|
"is_guest",
|
||||||
"mac",
|
|
||||||
"name",
|
|
||||||
"noted",
|
"noted",
|
||||||
"oui",
|
|
||||||
"qos_policy_applied",
|
"qos_policy_applied",
|
||||||
"radio",
|
"radio",
|
||||||
"radio_proto",
|
"radio_proto",
|
||||||
"site_id",
|
|
||||||
"vlan",
|
"vlan",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
CLIENT_STATIC_ATTRIBUTES = [
|
||||||
|
"hostname",
|
||||||
|
"mac",
|
||||||
|
"name",
|
||||||
|
"oui",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up device tracker for UniFi component."""
|
"""Set up device tracker for UniFi component."""
|
||||||
@ -284,12 +286,14 @@ class UniFiClientTracker(UniFiClient, ScannerEntity):
|
|||||||
"""Return the client state attributes."""
|
"""Return the client state attributes."""
|
||||||
attributes = {}
|
attributes = {}
|
||||||
|
|
||||||
for variable in DEVICE_ATTRIBUTES:
|
|
||||||
if variable in self.client.raw:
|
|
||||||
attributes[variable] = self.client.raw[variable]
|
|
||||||
|
|
||||||
attributes["is_wired"] = self.is_wired
|
attributes["is_wired"] = self.is_wired
|
||||||
|
|
||||||
|
for variable in CLIENT_STATIC_ATTRIBUTES + CLIENT_CONNECTED_ATTRIBUTES:
|
||||||
|
if variable in self.client.raw:
|
||||||
|
if self.is_disconnected and variable in CLIENT_CONNECTED_ATTRIBUTES:
|
||||||
|
continue
|
||||||
|
attributes[variable] = self.client.raw[variable]
|
||||||
|
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user