Remove KNX type alias for homeassistant.core types (#48422)

This commit is contained in:
Matthias Alphart 2021-03-27 22:20:11 +01:00 committed by GitHub
parent 3aa2591b0a
commit 051f29f9b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 40 additions and 77 deletions

View file

@ -24,14 +24,14 @@ from homeassistant.const import (
EVENT_HOMEASSISTANT_STOP,
SERVICE_RELOAD,
)
from homeassistant.core import ServiceCall
from homeassistant.core import Event, HomeAssistant, ServiceCall
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import discovery
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import async_get_platforms
from homeassistant.helpers.reload import async_integration_yaml_config
from homeassistant.helpers.service import async_register_admin_service
from homeassistant.helpers.typing import ConfigType, EventType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from .const import DOMAIN, KNX_ADDRESS, SupportedPlatforms
from .expose import KNXExposeSensor, KNXExposeTime, create_knx_exposure
@ -212,7 +212,7 @@ SERVICE_KNX_EXPOSURE_REGISTER_SCHEMA = vol.Any(
)
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the KNX integration."""
try:
knx_module = KNXModule(hass, config)
@ -299,7 +299,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
class KNXModule:
"""Representation of KNX Object."""
def __init__(self, hass: HomeAssistantType, config: ConfigType) -> None:
def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
"""Initialize KNX module."""
self.hass = hass
self.config = config
@ -328,7 +328,7 @@ class KNXModule:
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.stop)
self.connected = True
async def stop(self, event: EventType) -> None:
async def stop(self, event: Event) -> None:
"""Stop XKNX object. Disconnect from tunneling or Routing device."""
await self.xknx.stop()

View file

@ -6,19 +6,16 @@ from typing import Any, Callable, Iterable
from xknx.devices import BinarySensor as XknxBinarySensor
from homeassistant.components.binary_sensor import DEVICE_CLASSES, BinarySensorEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import ATTR_COUNTER, DOMAIN
from .knx_entity import KnxEntity
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,

View file

@ -15,12 +15,9 @@ from homeassistant.components.climate.const import (
SUPPORT_TARGET_TEMPERATURE,
)
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import CONTROLLER_MODES, DOMAIN, PRESET_MODES
from .knx_entity import KnxEntity
@ -30,7 +27,7 @@ PRESET_MODES_INV = {value: key for key, value in PRESET_MODES.items()}
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,

View file

@ -21,21 +21,17 @@ from homeassistant.components.cover import (
SUPPORT_STOP_TILT,
CoverEntity,
)
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_utc_time_change
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import DOMAIN
from .knx_entity import KnxEntity
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,

View file

@ -13,14 +13,9 @@ from homeassistant.const import (
STATE_UNAVAILABLE,
STATE_UNKNOWN,
)
from homeassistant.core import callback
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers.event import async_track_state_change_event
from homeassistant.helpers.typing import (
ConfigType,
EventType,
HomeAssistantType,
StateType,
)
from homeassistant.helpers.typing import ConfigType, StateType
from .const import KNX_ADDRESS
from .schema import ExposeSchema
@ -28,7 +23,7 @@ from .schema import ExposeSchema
@callback
def create_knx_exposure(
hass: HomeAssistantType, xknx: XKNX, config: ConfigType
hass: HomeAssistant, xknx: XKNX, config: ConfigType
) -> KNXExposeSensor | KNXExposeTime:
"""Create exposures from config."""
address = config[KNX_ADDRESS]
@ -61,7 +56,7 @@ class KNXExposeSensor:
def __init__(
self,
hass: HomeAssistantType,
hass: HomeAssistant,
xknx: XKNX,
expose_type: int | str,
entity_id: str,
@ -106,7 +101,7 @@ class KNXExposeSensor:
self._remove_listener = None
self.device.shutdown()
async def _async_entity_changed(self, event: EventType) -> None:
async def _async_entity_changed(self, event: Event) -> None:
"""Handle entity change."""
new_state = event.data.get("new_state")
if new_state is None:

View file

@ -7,12 +7,9 @@ from typing import Any, Callable, Iterable
from xknx.devices import Fan as XknxFan
from homeassistant.components.fan import SUPPORT_OSCILLATE, SUPPORT_SET_SPEED, FanEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.util.percentage import (
int_states_in_range,
percentage_to_ranged_value,
@ -26,7 +23,7 @@ DEFAULT_PERCENTAGE = 50
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,

View file

@ -16,12 +16,9 @@ from homeassistant.components.light import (
SUPPORT_WHITE_VALUE,
LightEntity,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
import homeassistant.util.color as color_util
from .const import DOMAIN
@ -34,7 +31,7 @@ DEFAULT_WHITE_VALUE = 255
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,

View file

@ -6,17 +6,14 @@ from typing import Any
from xknx.devices import Notification as XknxNotification
from homeassistant.components.notify import BaseNotificationService
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import DOMAIN
async def async_get_service(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
discovery_info: DiscoveryInfoType | None = None,
) -> KNXNotificationService | None:

View file

@ -6,19 +6,16 @@ from typing import Any, Callable, Iterable
from xknx.devices import Scene as XknxScene
from homeassistant.components.scene import Scene
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import DOMAIN
from .knx_entity import KnxEntity
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,

View file

@ -6,20 +6,16 @@ from typing import Callable, Iterable
from xknx.devices import Sensor as XknxSensor
from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
StateType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
from .const import DOMAIN
from .knx_entity import KnxEntity
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,

View file

@ -6,19 +6,16 @@ from typing import Any, Callable, Iterable
from xknx.devices import Switch as XknxSwitch
from homeassistant.components.switch import SwitchEntity
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import DOMAIN
from .knx_entity import KnxEntity
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,

View file

@ -7,19 +7,16 @@ from xknx.devices import Weather as XknxWeather
from homeassistant.components.weather import WeatherEntity
from homeassistant.const import TEMP_CELSIUS
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import (
ConfigType,
DiscoveryInfoType,
HomeAssistantType,
)
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from .const import DOMAIN
from .knx_entity import KnxEntity
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
async_add_entities: Callable[[Iterable[Entity]], None],
discovery_info: DiscoveryInfoType | None = None,