mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Use typed ConfigEntry in twentemilieu (#131894)
This commit is contained in:
parent
fd42c01a21
commit
8343d7f348
@ -29,7 +29,9 @@ type TwenteMilieuDataUpdateCoordinator = DataUpdateCoordinator[
|
||||
type TwenteMilieuConfigEntry = ConfigEntry[TwenteMilieuDataUpdateCoordinator]
|
||||
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant, entry: TwenteMilieuConfigEntry
|
||||
) -> bool:
|
||||
"""Set up Twente Milieu from a config entry."""
|
||||
session = async_get_clientsession(hass)
|
||||
twentemilieu = TwenteMilieu(
|
||||
@ -55,6 +57,8 @@ 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: TwenteMilieuConfigEntry
|
||||
) -> bool:
|
||||
"""Unload Twente Milieu config entry."""
|
||||
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
|
@ -4,12 +4,13 @@ from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from . import TwenteMilieuConfigEntry
|
||||
|
||||
|
||||
async def async_get_config_entry_diagnostics(
|
||||
hass: HomeAssistant, entry: ConfigEntry
|
||||
hass: HomeAssistant, entry: TwenteMilieuConfigEntry
|
||||
) -> dict[str, Any]:
|
||||
"""Return diagnostics for a config entry."""
|
||||
return {
|
||||
|
@ -2,13 +2,12 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ID
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from . import TwenteMilieuDataUpdateCoordinator
|
||||
from . import TwenteMilieuConfigEntry, TwenteMilieuDataUpdateCoordinator
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
@ -17,7 +16,7 @@ class TwenteMilieuEntity(CoordinatorEntity[TwenteMilieuDataUpdateCoordinator], E
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, entry: ConfigEntry) -> None:
|
||||
def __init__(self, entry: TwenteMilieuConfigEntry) -> None:
|
||||
"""Initialize the Twente Milieu entity."""
|
||||
super().__init__(coordinator=entry.runtime_data)
|
||||
self._attr_device_info = DeviceInfo(
|
||||
|
@ -12,11 +12,11 @@ from homeassistant.components.sensor import (
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import TwenteMilieuConfigEntry
|
||||
from .const import DOMAIN
|
||||
from .entity import TwenteMilieuEntity
|
||||
|
||||
@ -64,7 +64,7 @@ SENSORS: tuple[TwenteMilieuSensorDescription, ...] = (
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
entry: ConfigEntry,
|
||||
entry: TwenteMilieuConfigEntry,
|
||||
async_add_entities: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Set up Twente Milieu sensor based on a config entry."""
|
||||
@ -80,7 +80,7 @@ class TwenteMilieuSensor(TwenteMilieuEntity, SensorEntity):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
entry: ConfigEntry,
|
||||
entry: TwenteMilieuConfigEntry,
|
||||
description: TwenteMilieuSensorDescription,
|
||||
) -> None:
|
||||
"""Initialize the Twente Milieu entity."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user