Fix Mikrotik rename from wifiwave2 to wifi for upcoming RouterOS 7.13 (#104966)

Co-authored-by: Marco98 <Marco98@users.noreply.github.com>
pull/105063/head
Marco 2023-12-05 09:21:03 +01:00 committed by GitHub
parent 482e087a85
commit b7bc49b863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -25,9 +25,11 @@ CAPSMAN: Final = "capsman"
DHCP: Final = "dhcp"
WIRELESS: Final = "wireless"
WIFIWAVE2: Final = "wifiwave2"
WIFI: Final = "wifi"
IS_WIRELESS: Final = "is_wireless"
IS_CAPSMAN: Final = "is_capsman"
IS_WIFIWAVE2: Final = "is_wifiwave2"
IS_WIFI: Final = "is_wifi"
MIKROTIK_SERVICES: Final = {
@ -38,9 +40,11 @@ MIKROTIK_SERVICES: Final = {
INFO: "/system/routerboard/getall",
WIRELESS: "/interface/wireless/registration-table/getall",
WIFIWAVE2: "/interface/wifiwave2/registration-table/print",
WIFI: "/interface/wifi/registration-table/print",
IS_WIRELESS: "/interface/wireless/print",
IS_CAPSMAN: "/caps-man/interface/print",
IS_WIFIWAVE2: "/interface/wifiwave2/print",
IS_WIFI: "/interface/wifi/print",
}

View File

@ -31,10 +31,12 @@ from .const import (
IDENTITY,
INFO,
IS_CAPSMAN,
IS_WIFI,
IS_WIFIWAVE2,
IS_WIRELESS,
MIKROTIK_SERVICES,
NAME,
WIFI,
WIFIWAVE2,
WIRELESS,
)
@ -60,6 +62,7 @@ class MikrotikData:
self.support_capsman: bool = False
self.support_wireless: bool = False
self.support_wifiwave2: bool = False
self.support_wifi: bool = False
self.hostname: str = ""
self.model: str = ""
self.firmware: str = ""
@ -101,6 +104,7 @@ class MikrotikData:
self.support_capsman = bool(self.command(MIKROTIK_SERVICES[IS_CAPSMAN]))
self.support_wireless = bool(self.command(MIKROTIK_SERVICES[IS_WIRELESS]))
self.support_wifiwave2 = bool(self.command(MIKROTIK_SERVICES[IS_WIFIWAVE2]))
self.support_wifi = bool(self.command(MIKROTIK_SERVICES[IS_WIFI]))
def get_list_from_interface(self, interface: str) -> dict[str, dict[str, Any]]:
"""Get devices from interface."""
@ -128,6 +132,9 @@ class MikrotikData:
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)
if not device_list or self.force_dhcp:
device_list = self.all_devices