Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/immich/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "local_polling",
"loggers": ["aioimmich"],
"quality_scale": "platinum",
"requirements": ["aioimmich==0.16.1"]
"requirements": ["aioimmich==0.17.0"]
}
3 changes: 3 additions & 0 deletions homeassistant/components/mikrotik/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Constants used in the Mikrotik components."""

import logging
from typing import Final

LOGGER = logging.getLogger(__package__)

DOMAIN: Final = "mikrotik"
DEFAULT_NAME: Final = "Mikrotik"
DEFAULT_API_PORT: Final = 8728
Expand Down
30 changes: 14 additions & 16 deletions homeassistant/components/mikrotik/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""The Mikrotik router class."""

from datetime import timedelta
import logging
import ssl
from typing import Any, override

Expand Down Expand Up @@ -37,6 +36,7 @@
IS_WIFI,
IS_WIFIWAVE2,
IS_WIRELESS,
LOGGER,
MIKROTIK_SERVICES,
NAME,
POE,
Expand All @@ -51,8 +51,6 @@
from .errors import CannotConnect, LoginError
from .utils import mikrotik_config_entry_errors

_LOGGER = logging.getLogger(__name__)

type MikrotikConfigEntry = ConfigEntry[MikrotikDataUpdateCoordinator]


Expand Down Expand Up @@ -204,24 +202,24 @@ def update_devices(self) -> None:
# Retrieve data
self.all_devices = self.get_list_from_interface(DHCP)
if self.support_capsman:
_LOGGER.debug("Hub is a CAPSman manager")
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")
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")
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")
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
_LOGGER.debug("Falling back to DHCP for scanning devices")
LOGGER.debug("Falling back to DHCP for scanning devices")

if self.arp_enabled:
_LOGGER.debug("Using arp-ping to check devices")
LOGGER.debug("Using arp-ping to check devices")
arp_devices = self.get_list_from_interface(ARP)

# get hub details and system info
Expand Down Expand Up @@ -270,7 +268,7 @@ def update_devices(self) -> None:

def do_arp_ping(self, ip_address: str, interface: str) -> bool:
"""Attempt to arp ping MAC address via interface."""
_LOGGER.debug("pinging - %s", ip_address)
LOGGER.debug("pinging - %s", ip_address)
params = {
"arp-ping": "yes",
"interval": "100ms",
Expand All @@ -286,7 +284,7 @@ def do_arp_ping(self, ip_address: str, interface: str) -> bool:
if "status" in result:
status += 1
if status == len(data):
_LOGGER.debug(
LOGGER.debug(
"Mikrotik %s - %s arp_ping timed out", ip_address, interface
)
return False
Expand All @@ -300,7 +298,7 @@ def command(
during_setup: bool = False,
) -> list[dict[str, Any]]:
"""Retrieve data from Mikrotik API."""
_LOGGER.debug("Running command %s", cmd)
LOGGER.debug("Running command %s", cmd)
with mikrotik_config_entry_errors(
suppress_errors=suppress_errors, during_setup=during_setup
):
Expand All @@ -324,7 +322,7 @@ def __init__(
self._mk_data = MikrotikData(hass, config_entry, api)
super().__init__(
hass,
_LOGGER,
LOGGER,
config_entry=config_entry,
name=f"{DOMAIN} - {config_entry.data[CONF_HOST]}",
update_interval=timedelta(seconds=10),
Expand Down Expand Up @@ -377,7 +375,7 @@ async def _async_update_data(self) -> None:

def get_api(entry: dict[str, Any]) -> librouteros.Api:
"""Connect to Mikrotik hub."""
_LOGGER.debug("Connecting to Mikrotik hub [%s]", entry[CONF_HOST])
LOGGER.debug("Connecting to Mikrotik hub [%s]", entry[CONF_HOST])

kwargs = {"port": entry["port"], "encoding": "utf8"}

Expand Down Expand Up @@ -408,10 +406,10 @@ def get_api(entry: dict[str, Any]) -> librouteros.Api:
_error = api_error

if _error is not None:
_LOGGER.debug("Mikrotik %s error: %s", entry[CONF_HOST], _error)
LOGGER.debug("Mikrotik %s error: %s", entry[CONF_HOST], _error)
if "invalid user name or password" in str(_error):
raise LoginError from _error
raise CannotConnect from _error

_LOGGER.debug("Connected to %s successfully", entry[CONF_HOST])
LOGGER.debug("Connected to %s successfully", entry[CONF_HOST])
return api
8 changes: 4 additions & 4 deletions homeassistant/components/mikrotik/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from homeassistant.helpers.typing import StateType
from homeassistant.util.dt import utcnow

from .const import HEALTH, RESOURCE
from .coordinator import _LOGGER, MikrotikConfigEntry
from .const import HEALTH, LOGGER, RESOURCE
from .coordinator import MikrotikConfigEntry
from .entity import MikrotikEntity

PARALLEL_UPDATES = 0
Expand Down Expand Up @@ -61,13 +61,13 @@ def _calculate_uptime(data: dict[str, Any]) -> datetime | None:
elif ch == "s":
total += num
else:
_LOGGER.warning("Unknown uptime format: %s", uptime_string)
LOGGER.warning("Unknown uptime format: %s", uptime_string)
return None

num = 0

if num != 0:
_LOGGER.warning("Unknown uptime format: %s", uptime_string)
LOGGER.warning("Unknown uptime format: %s", uptime_string)
return None

return utcnow() - timedelta(seconds=total)
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions tests/components/subaru/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ async def pin_form(
@pytest.fixture
async def options_form(hass: HomeAssistant) -> ConfigFlowResult:
"""Return options form for Subaru config flow."""
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
entry = MockConfigEntry(domain=DOMAIN, data=TEST_CONFIG, options=None)
entry.add_to_hass(hass)
await async_setup_component(hass, DOMAIN, {})
with patch(ASYNC_SETUP_ENTRY, return_value=True):
await async_setup_component(hass, DOMAIN, {})
return await hass.config_entries.options.async_init(entry.entry_id)
Loading