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 = [ CLIENT_STATIC_ATTRIBUTES = [
"hostname",
"mac", "mac",
"name", "name",
"oui", "oui",
@ -175,7 +174,7 @@ ENTITY_DESCRIPTIONS: tuple[UnifiTrackerEntityDescription, ...] = (
supported_fn=lambda controller, obj_id: True, supported_fn=lambda controller, obj_id: True,
unique_id_fn=lambda controller, obj_id: f"{obj_id}-{controller.site}", unique_id_fn=lambda controller, obj_id: f"{obj_id}-{controller.site}",
ip_address_fn=lambda api, obj_id: api.clients[obj_id].ip, 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]( UnifiTrackerEntityDescription[Devices, Device](
key="Device scanner", 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 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_1").state == STATE_NOT_HOME
assert hass.states.get("device_tracker.client_2").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 # Client on SSID not in SSID filter
assert not hass.states.get("device_tracker.client_3") assert not hass.states.get("device_tracker.client_3")