Fix UniFi client tracker host_name missing (#91188)

This commit is contained in:
Robert Svensson 2023-04-11 11:56:55 +02:00 committed by GitHub
parent 62bc8df964
commit 0d7711f787
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -54,7 +54,6 @@ CLIENT_CONNECTED_ATTRIBUTES = [
]
CLIENT_STATIC_ATTRIBUTES = [
"hostname",
"mac",
"name",
"oui",
@ -175,7 +174,7 @@ ENTITY_DESCRIPTIONS: tuple[UnifiTrackerEntityDescription, ...] = (
supported_fn=lambda controller, obj_id: True,
unique_id_fn=lambda controller, obj_id: f"{obj_id}-{controller.site}",
ip_address_fn=lambda api, obj_id: api.clients[obj_id].ip,
hostname_fn=lambda api, obj_id: None,
hostname_fn=lambda api, obj_id: api.clients[obj_id].hostname,
),
UnifiTrackerEntityDescription[Devices, Device](
key="Device scanner",

View file

@ -144,6 +144,9 @@ async def test_tracked_clients(
assert len(hass.states.async_entity_ids(TRACKER_DOMAIN)) == 4
assert hass.states.get("device_tracker.client_1").state == STATE_NOT_HOME
assert hass.states.get("device_tracker.client_2").state == STATE_NOT_HOME
assert (
hass.states.get("device_tracker.client_5").attributes["host_name"] == "client_5"
)
# Client on SSID not in SSID filter
assert not hass.states.get("device_tracker.client_3")