diff --git a/custom_components/mikrotik_router/__init__.py b/custom_components/mikrotik_router/__init__.py index 6067326..83cebd3 100644 --- a/custom_components/mikrotik_router/__init__.py +++ b/custom_components/mikrotik_router/__init__.py @@ -1,4 +1,5 @@ """Mikrotik Router integration.""" + from __future__ import annotations import voluptuous as vol diff --git a/custom_components/mikrotik_router/apiparser.py b/custom_components/mikrotik_router/apiparser.py index da6cda3..2406810 100644 --- a/custom_components/mikrotik_router/apiparser.py +++ b/custom_components/mikrotik_router/apiparser.py @@ -1,4 +1,5 @@ """API parser for JSON APIs.""" + from datetime import datetime from logging import getLogger diff --git a/custom_components/mikrotik_router/binary_sensor.py b/custom_components/mikrotik_router/binary_sensor.py index 574192f..67ba012 100644 --- a/custom_components/mikrotik_router/binary_sensor.py +++ b/custom_components/mikrotik_router/binary_sensor.py @@ -1,4 +1,5 @@ """Support for the Mikrotik Router binary sensor service.""" + from __future__ import annotations from logging import getLogger diff --git a/custom_components/mikrotik_router/binary_sensor_types.py b/custom_components/mikrotik_router/binary_sensor_types.py index 040822c..de1c33a 100644 --- a/custom_components/mikrotik_router/binary_sensor_types.py +++ b/custom_components/mikrotik_router/binary_sensor_types.py @@ -1,4 +1,5 @@ """Definitions for Mikrotik Router binary sensor entities.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/custom_components/mikrotik_router/button.py b/custom_components/mikrotik_router/button.py index b6451ac..f2f7c06 100644 --- a/custom_components/mikrotik_router/button.py +++ b/custom_components/mikrotik_router/button.py @@ -1,4 +1,5 @@ """Support for the Mikrotik Router buttons.""" + from __future__ import annotations from logging import getLogger diff --git a/custom_components/mikrotik_router/button_types.py b/custom_components/mikrotik_router/button_types.py index 38f8aaf..056759f 100644 --- a/custom_components/mikrotik_router/button_types.py +++ b/custom_components/mikrotik_router/button_types.py @@ -1,4 +1,5 @@ """Definitions for Mikrotik Router button entities.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/custom_components/mikrotik_router/const.py b/custom_components/mikrotik_router/const.py index d7ac4b2..371bac7 100644 --- a/custom_components/mikrotik_router/const.py +++ b/custom_components/mikrotik_router/const.py @@ -1,4 +1,5 @@ """Constants used by the Mikrotik Router component and platforms.""" + from homeassistant.const import Platform PLATFORMS = [ diff --git a/custom_components/mikrotik_router/coordinator.py b/custom_components/mikrotik_router/coordinator.py index 5dd5135..5ba8cb1 100644 --- a/custom_components/mikrotik_router/coordinator.py +++ b/custom_components/mikrotik_router/coordinator.py @@ -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"] = "" diff --git a/custom_components/mikrotik_router/device_tracker.py b/custom_components/mikrotik_router/device_tracker.py index a7cb840..49ed71a 100644 --- a/custom_components/mikrotik_router/device_tracker.py +++ b/custom_components/mikrotik_router/device_tracker.py @@ -1,4 +1,5 @@ """Support for the Mikrotik Router device tracker.""" + from __future__ import annotations from logging import getLogger diff --git a/custom_components/mikrotik_router/device_tracker_types.py b/custom_components/mikrotik_router/device_tracker_types.py index 2ec7f6d..d8b1ec3 100644 --- a/custom_components/mikrotik_router/device_tracker_types.py +++ b/custom_components/mikrotik_router/device_tracker_types.py @@ -1,4 +1,5 @@ """Definitions for Mikrotik Router device tracker entities.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/custom_components/mikrotik_router/diagnostics.py b/custom_components/mikrotik_router/diagnostics.py index f0546ed..e10256e 100644 --- a/custom_components/mikrotik_router/diagnostics.py +++ b/custom_components/mikrotik_router/diagnostics.py @@ -1,4 +1,5 @@ """Diagnostics support for Mikrotik Router.""" + from __future__ import annotations from typing import Any from homeassistant.components.diagnostics import async_redact_data diff --git a/custom_components/mikrotik_router/entity.py b/custom_components/mikrotik_router/entity.py index 9925238..c59bcf2 100644 --- a/custom_components/mikrotik_router/entity.py +++ b/custom_components/mikrotik_router/entity.py @@ -1,4 +1,5 @@ """Mikrotik HA shared entity model""" + from __future__ import annotations from collections.abc import Mapping diff --git a/custom_components/mikrotik_router/sensor.py b/custom_components/mikrotik_router/sensor.py index 94e7012..998975f 100644 --- a/custom_components/mikrotik_router/sensor.py +++ b/custom_components/mikrotik_router/sensor.py @@ -1,4 +1,5 @@ """Mikrotik sensor platform.""" + from __future__ import annotations from logging import getLogger diff --git a/custom_components/mikrotik_router/sensor_types.py b/custom_components/mikrotik_router/sensor_types.py index 9acd422..105a0f6 100644 --- a/custom_components/mikrotik_router/sensor_types.py +++ b/custom_components/mikrotik_router/sensor_types.py @@ -1,4 +1,5 @@ """Definitions for sensor entities.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/custom_components/mikrotik_router/switch.py b/custom_components/mikrotik_router/switch.py index aa229d1..c3de344 100644 --- a/custom_components/mikrotik_router/switch.py +++ b/custom_components/mikrotik_router/switch.py @@ -1,4 +1,5 @@ """Support for the Mikrotik Router switches.""" + from __future__ import annotations from logging import getLogger diff --git a/custom_components/mikrotik_router/switch_types.py b/custom_components/mikrotik_router/switch_types.py index fd59b9a..d6e42de 100644 --- a/custom_components/mikrotik_router/switch_types.py +++ b/custom_components/mikrotik_router/switch_types.py @@ -1,4 +1,5 @@ """Definitions for Mikrotik Router switch entities.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/custom_components/mikrotik_router/update_types.py b/custom_components/mikrotik_router/update_types.py index 91dc17c..e7dbd8a 100644 --- a/custom_components/mikrotik_router/update_types.py +++ b/custom_components/mikrotik_router/update_types.py @@ -1,4 +1,5 @@ """Definitions for Mikrotik Router update entities.""" + from __future__ import annotations from dataclasses import dataclass, field