Format with black

This commit is contained in:
Michel van de Wetering 2025-04-25 21:49:43 +02:00
parent 44fe6a626b
commit 5650d7f5ca
17 changed files with 48 additions and 27 deletions

View file

@ -186,12 +186,12 @@ class MikrotikTrackerCoordinator(DataUpdateCoordinator[None]):
"Ping host: %s", self.coordinator.ds["host"][uid]["address"]
)
self.coordinator.ds["host"][uid][
"available"
] = await self.hass.async_add_executor_job(
self.api.arp_ping,
self.coordinator.ds["host"][uid]["address"],
tmp_interface,
self.coordinator.ds["host"][uid]["available"] = (
await self.hass.async_add_executor_job(
self.api.arp_ping,
self.coordinator.ds["host"][uid]["address"],
tmp_interface,
)
)
# Update last seen
@ -519,31 +519,34 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
if "wifiwave2" in packages and packages["wifiwave2"]["enabled"]:
self.support_capsman = False
self._wifimodule = "wifiwave2"
elif "wifi" in packages and packages["wifi"]["enabled"]:
self.support_capsman = False
self._wifimodule = "wifi"
elif "wifi-qcom" in packages and packages["wifi-qcom"]["enabled"]:
self.support_capsman = False
self._wifimodule = "wifi"
elif "wifi-qcom-ac" in packages and packages["wifi-qcom-ac"]["enabled"]:
self.support_capsman = False
self._wifimodule = "wifi"
elif (self.major_fw_version == 7 and self.minor_fw_version >= 13) or self.major_fw_version > 7:
elif (
self.major_fw_version == 7 and self.minor_fw_version >= 13
) or self.major_fw_version > 7:
self.support_capsman = False
self._wifimodule = "wifi"
else:
self.support_capsman = True
self.support_wireless = bool(self.minor_fw_version < 13)
_LOGGER.debug("Mikrotik %s wifi module=%s",
self.host,
self._wifimodule,
)
_LOGGER.debug(
"Mikrotik %s wifi module=%s",
self.host,
self._wifimodule,
)
if "ups" in packages and packages["ups"]["enabled"]:
self.support_ups = True
@ -1580,7 +1583,7 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
if self.ds["fw-update"]["installed-version"] != "unknown":
try:
full_version = self.ds["fw-update"].get("installed-version")
split_end = min(len(full_version),4)
split_end = min(len(full_version), 4)
version = re.sub(r"[^0-9\.]", "", full_version[0:split_end])
self.major_fw_version = int(version.split(".")[0])
self.minor_fw_version = int(version.split(".")[1])
@ -1589,7 +1592,7 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
self.host,
self.major_fw_version,
self.minor_fw_version,
full_version
full_version,
)
except Exception:
_LOGGER.error(
@ -1987,13 +1990,15 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
# ---------------------------
def get_capsman_hosts(self) -> None:
"""Get CAPS-MAN hosts data from Mikrotik"""
if self.major_fw_version > 7 or (self.major_fw_version == 7 and self.minor_fw_version >= 13):
if self.major_fw_version > 7 or (
self.major_fw_version == 7 and self.minor_fw_version >= 13
):
registration_path = "/interface/wifi/registration-table"
else:
registration_path= "/caps-man/registration-table"
registration_path = "/caps-man/registration-table"
self.ds["capsman_hosts"] = parse_api(
data={},
source=self.api.query(registration_path),
@ -2262,9 +2267,9 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
# Resolve manufacturer
if vals["manufacturer"] == "detect" and vals["mac-address"] != "unknown":
try:
self.ds["host"][uid][
"manufacturer"
] = await self.async_mac_lookup.lookup(vals["mac-address"])
self.ds["host"][uid]["manufacturer"] = (
await self.async_mac_lookup.lookup(vals["mac-address"])
)
except Exception:
self.ds["host"][uid]["manufacturer"] = ""