Skip to content

Commit 6f79a65

Browse files
authored
AsusWRT: Pass only online clients to the device list from the API (home-assistant#154322)
1 parent ce1fdc6 commit 6f79a65

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

homeassistant/components/asuswrt/bridge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from aiohttp import ClientSession
1414
from asusrouter import AsusRouter, AsusRouterError
1515
from asusrouter.config import ARConfigKey
16-
from asusrouter.modules.client import AsusClient
16+
from asusrouter.modules.client import AsusClient, ConnectionState
1717
from asusrouter.modules.data import AsusData
1818
from asusrouter.modules.homeassistant import convert_to_ha_data, convert_to_ha_sensors
1919
from asusrouter.tools.connection import get_cookie_jar
@@ -436,6 +436,7 @@ async def async_get_connected_devices(self) -> dict[str, WrtDevice]:
436436
if dev.connection is not None
437437
and dev.description is not None
438438
and dev.connection.ip_address is not None
439+
and dev.state is ConnectionState.CONNECTED
439440
}
440441

441442
async def async_get_available_sensors(self) -> dict[str, dict[str, Any]]:

tests/components/asuswrt/common.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from unittest.mock import MagicMock
44

55
from aioasuswrt.asuswrt import Device as LegacyDevice
6+
from asusrouter.modules.client import ConnectionState
67

78
from homeassistant.components.asuswrt.const import (
89
CONF_SSH_KEY,
@@ -71,6 +72,7 @@ def make_client(mac, ip, name, node):
7172
client = MagicMock()
7273
client.connection = connection
7374
client.description = description
75+
client.state = ConnectionState.CONNECTED
7476
return client
7577

7678

0 commit comments

Comments
 (0)