Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion homeassistant/components/unifi/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ async def async_remove_clients(hass, data) -> None:

for client in controller.api.clients_all.values():

if client.last_seen - client.first_seen > 900:
if (
client.last_seen
and client.first_seen
and client.last_seen - client.first_seen > 900
):
continue

if any({client.fixed_ip, client.hostname, client.name}):
Expand Down
5 changes: 4 additions & 1 deletion tests/components/unifi/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ async def test_reconnect_wired_client(hass, aioclient_mock):
async def test_remove_clients(hass, aioclient_mock):
"""Verify removing different variations of clients work."""
clients = [
{
"mac": "00:00:00:00:00:00",
},
{
"first_seen": 100,
"last_seen": 500,
Expand Down Expand Up @@ -239,7 +242,7 @@ async def test_remove_clients(hass, aioclient_mock):
await hass.services.async_call(UNIFI_DOMAIN, SERVICE_REMOVE_CLIENTS, blocking=True)
assert aioclient_mock.mock_calls[0][2] == {
"cmd": "forget-sta",
"macs": ["00:00:00:00:00:01"],
"macs": ["00:00:00:00:00:00", "00:00:00:00:00:01"],
}

assert await hass.config_entries.async_unload(config_entry.entry_id)
Expand Down