mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Add missing config entry type for Husqvarna (#147455)
Add missing type for husqvarna
This commit is contained in:
parent
19b773df85
commit
c93e45c0f2
@ -15,12 +15,14 @@ from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from .const import LOGGER
|
||||
from .coordinator import HusqvarnaCoordinator
|
||||
|
||||
type HusqvarnaConfigEntry = ConfigEntry[HusqvarnaCoordinator]
|
||||
|
||||
PLATFORMS = [
|
||||
Platform.LAWN_MOWER,
|
||||
]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: HusqvarnaConfigEntry) -> bool:
|
||||
"""Set up Husqvarna Autoconnect Bluetooth from a config entry."""
|
||||
address = entry.data[CONF_ADDRESS]
|
||||
channel_id = entry.data[CONF_CLIENT_ID]
|
||||
@ -54,7 +56,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
return True
|
||||
|
||||
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_unload_entry(hass: HomeAssistant, entry: HusqvarnaConfigEntry) -> bool:
|
||||
"""Unload a config entry."""
|
||||
if unload_ok := await hass.config_entries.async_unload_platforms(entry, PLATFORMS):
|
||||
coordinator: HusqvarnaCoordinator = entry.runtime_data
|
||||
|
@ -3,30 +3,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from automower_ble.mower import Mower
|
||||
from bleak import BleakError
|
||||
from bleak_retry_connector import close_stale_connections_by_address
|
||||
|
||||
from homeassistant.components import bluetooth
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
|
||||
from .const import DOMAIN, LOGGER
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import HusqvarnaConfigEntry
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=60)
|
||||
|
||||
|
||||
class HusqvarnaCoordinator(DataUpdateCoordinator[dict[str, bytes]]):
|
||||
"""Class to manage fetching data."""
|
||||
|
||||
config_entry: ConfigEntry
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
config_entry: HusqvarnaConfigEntry,
|
||||
mower: Mower,
|
||||
address: str,
|
||||
channel_id: str,
|
||||
|
@ -10,10 +10,10 @@ from homeassistant.components.lawn_mower import (
|
||||
LawnMowerEntity,
|
||||
LawnMowerEntityFeature,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||
|
||||
from . import HusqvarnaConfigEntry
|
||||
from .const import LOGGER
|
||||
from .coordinator import HusqvarnaCoordinator
|
||||
from .entity import HusqvarnaAutomowerBleEntity
|
||||
@ -21,11 +21,11 @@ from .entity import HusqvarnaAutomowerBleEntity
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
config_entry: HusqvarnaConfigEntry,
|
||||
async_add_entities: AddConfigEntryEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up AutomowerLawnMower integration from a config entry."""
|
||||
coordinator: HusqvarnaCoordinator = config_entry.runtime_data
|
||||
coordinator = config_entry.runtime_data
|
||||
address = coordinator.address
|
||||
|
||||
async_add_entities(
|
||||
|
Loading…
x
Reference in New Issue
Block a user