mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 12:45:28 +02:00
Use typed config entry in husqvarna_automower (#132346)
This commit is contained in:
@@ -89,7 +89,9 @@ async def async_unload_entry(hass: HomeAssistant, entry: AutomowerConfigEntry) -
|
|||||||
|
|
||||||
|
|
||||||
def cleanup_removed_devices(
|
def cleanup_removed_devices(
|
||||||
hass: HomeAssistant, config_entry: ConfigEntry, available_devices: list[str]
|
hass: HomeAssistant,
|
||||||
|
config_entry: AutomowerConfigEntry,
|
||||||
|
available_devices: list[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Cleanup entity and device registry from removed devices."""
|
"""Cleanup entity and device registry from removed devices."""
|
||||||
device_reg = dr.async_get(hass)
|
device_reg = dr.async_get(hass)
|
||||||
@@ -104,7 +106,7 @@ def cleanup_removed_devices(
|
|||||||
|
|
||||||
def remove_work_area_entities(
|
def remove_work_area_entities(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_entry: ConfigEntry,
|
config_entry: AutomowerConfigEntry,
|
||||||
removed_work_areas: set[int],
|
removed_work_areas: set[int],
|
||||||
mower_id: str,
|
mower_id: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
@@ -1,8 +1,11 @@
|
|||||||
"""Data UpdateCoordinator for the Husqvarna Automower integration."""
|
"""Data UpdateCoordinator for the Husqvarna Automower integration."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from aioautomower.exceptions import (
|
from aioautomower.exceptions import (
|
||||||
ApiException,
|
ApiException,
|
||||||
@@ -13,13 +16,15 @@ from aioautomower.exceptions import (
|
|||||||
from aioautomower.model import MowerAttributes
|
from aioautomower.model import MowerAttributes
|
||||||
from aioautomower.session import AutomowerSession
|
from aioautomower.session import AutomowerSession
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.exceptions import ConfigEntryAuthFailed
|
from homeassistant.exceptions import ConfigEntryAuthFailed
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from . import AutomowerConfigEntry
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
MAX_WS_RECONNECT_TIME = 600
|
MAX_WS_RECONNECT_TIME = 600
|
||||||
SCAN_INTERVAL = timedelta(minutes=8)
|
SCAN_INTERVAL = timedelta(minutes=8)
|
||||||
@@ -29,7 +34,7 @@ DEFAULT_RECONNECT_TIME = 2 # Define a default reconnect time
|
|||||||
class AutomowerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, MowerAttributes]]):
|
class AutomowerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, MowerAttributes]]):
|
||||||
"""Class to manage fetching Husqvarna data."""
|
"""Class to manage fetching Husqvarna data."""
|
||||||
|
|
||||||
config_entry: ConfigEntry
|
config_entry: AutomowerConfigEntry
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant, api: AutomowerSession) -> None:
|
def __init__(self, hass: HomeAssistant, api: AutomowerSession) -> None:
|
||||||
"""Initialize data updater."""
|
"""Initialize data updater."""
|
||||||
@@ -64,7 +69,7 @@ class AutomowerDataUpdateCoordinator(DataUpdateCoordinator[dict[str, MowerAttrib
|
|||||||
async def client_listen(
|
async def client_listen(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entry: ConfigEntry,
|
entry: AutomowerConfigEntry,
|
||||||
automower_client: AutomowerSession,
|
automower_client: AutomowerSession,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Listen with the client."""
|
"""Listen with the client."""
|
||||||
|
@@ -6,7 +6,6 @@ import logging
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.components.diagnostics import async_redact_data
|
from homeassistant.components.diagnostics import async_redact_data
|
||||||
from homeassistant.config_entries import ConfigEntry
|
|
||||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.device_registry import DeviceEntry
|
from homeassistant.helpers.device_registry import DeviceEntry
|
||||||
@@ -26,7 +25,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
async def async_get_config_entry_diagnostics(
|
async def async_get_config_entry_diagnostics(
|
||||||
hass: HomeAssistant, entry: ConfigEntry
|
hass: HomeAssistant, entry: AutomowerConfigEntry
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
"""Return diagnostics for a config entry."""
|
"""Return diagnostics for a config entry."""
|
||||||
return async_redact_data(entry.as_dict(), TO_REDACT)
|
return async_redact_data(entry.as_dict(), TO_REDACT)
|
||||||
|
Reference in New Issue
Block a user