Scan every supported wireless interface in Mikrotik (#180636)

This commit is contained in:
Simone Chemelli
2026-08-29 17:49:21 +02:00
committed by GitHub
parent b6b40e2427
commit 2f50531be1
2 changed files with 43 additions and 12 deletions
@@ -239,18 +239,22 @@ class MikrotikData:
with mikrotik_config_entry_errors():
# Retrieve data
self.all_devices = self.get_list_from_interface(DHCP)
if self.support_capsman:
LOGGER.debug("Hub is a CAPSman manager")
device_list = wireless_devices = self.get_list_from_interface(CAPSMAN)
elif self.support_wireless:
LOGGER.debug("Hub supports wireless Interface")
device_list = wireless_devices = self.get_list_from_interface(WIRELESS)
elif self.support_wifiwave2:
LOGGER.debug("Hub supports wifiwave2 Interface")
device_list = wireless_devices = self.get_list_from_interface(WIFIWAVE2)
elif self.support_wifi:
LOGGER.debug("Hub supports wifi Interface")
device_list = wireless_devices = self.get_list_from_interface(WIFI)
# A hub can expose more than one wireless stack at once (e.g. the
# legacy "wireless" package kept for CAPsMAN alongside the newer
# "wifi" registration table), so merge every supported interface
# instead of picking only the first match.
for supported, interface, message in (
(self.support_capsman, CAPSMAN, "Hub is a CAPSman manager"),
(self.support_wireless, WIRELESS, "Hub supports wireless Interface"),
(self.support_wifiwave2, WIFIWAVE2, "Hub supports wifiwave2 Interface"),
(self.support_wifi, WIFI, "Hub supports wifi Interface"),
):
if supported:
LOGGER.debug(message)
wireless_devices.update(self.get_list_from_interface(interface))
device_list = wireless_devices
if not device_list or self.force_dhcp:
device_list = self.all_devices
@@ -190,6 +190,33 @@ async def test_hub_wifi(hass: HomeAssistant) -> None:
assert device_2.state == "home"
@pytest.mark.usefixtures("mock_device_registry_devices")
async def test_hub_wireless_and_wifi(hass: HomeAssistant) -> None:
"""Test a hub exposing both the legacy wireless package and the wifi driver.
The legacy ``wireless`` package can linger on a hub acting as a CAPsMAN for
``wifi`` access points, leaving its registration table empty while the
connected clients are only listed on the ``wifi`` interface.
"""
device_2_without_active_address = {
key: value for key, value in DEVICE_2_DHCP.items() if key != "active-address"
}
await setup_mikrotik_entry(
hass,
dhcp_data=[DEVICE_1_DHCP, device_2_without_active_address],
support_wireless=True,
wireless_data=[],
support_wifi=True,
wifi_data=[DEVICE_2_WIRELESS],
)
# device_2 is only present on the wifi interface, not in the wireless list
device_2 = hass.states.get("device_tracker.device_2")
assert device_2
assert device_2.state == "home"
@pytest.mark.usefixtures("mock_device_registry_devices")
async def test_wired_device_without_active_address_is_not_home(
hass: HomeAssistant,