Remove KNX type alias for homeassistant.core types (#48422)
This commit is contained in:
parent
3aa2591b0a
commit
051f29f9b6
12 changed files with 40 additions and 77 deletions
|
@ -24,14 +24,14 @@ from homeassistant.const import (
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
SERVICE_RELOAD,
|
SERVICE_RELOAD,
|
||||||
)
|
)
|
||||||
from homeassistant.core import ServiceCall
|
from homeassistant.core import Event, HomeAssistant, ServiceCall
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.helpers.entity_platform import async_get_platforms
|
from homeassistant.helpers.entity_platform import async_get_platforms
|
||||||
from homeassistant.helpers.reload import async_integration_yaml_config
|
from homeassistant.helpers.reload import async_integration_yaml_config
|
||||||
from homeassistant.helpers.service import async_register_admin_service
|
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 .const import DOMAIN, KNX_ADDRESS, SupportedPlatforms
|
||||||
from .expose import KNXExposeSensor, KNXExposeTime, create_knx_exposure
|
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."""
|
"""Set up the KNX integration."""
|
||||||
try:
|
try:
|
||||||
knx_module = KNXModule(hass, config)
|
knx_module = KNXModule(hass, config)
|
||||||
|
@ -299,7 +299,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
|
||||||
class KNXModule:
|
class KNXModule:
|
||||||
"""Representation of KNX Object."""
|
"""Representation of KNX Object."""
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistantType, config: ConfigType) -> None:
|
def __init__(self, hass: HomeAssistant, config: ConfigType) -> None:
|
||||||
"""Initialize KNX module."""
|
"""Initialize KNX module."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.config = config
|
self.config = config
|
||||||
|
@ -328,7 +328,7 @@ class KNXModule:
|
||||||
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.stop)
|
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.stop)
|
||||||
self.connected = True
|
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."""
|
"""Stop XKNX object. Disconnect from tunneling or Routing device."""
|
||||||
await self.xknx.stop()
|
await self.xknx.stop()
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,16 @@ from typing import Any, Callable, Iterable
|
||||||
from xknx.devices import BinarySensor as XknxBinarySensor
|
from xknx.devices import BinarySensor as XknxBinarySensor
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import DEVICE_CLASSES, BinarySensorEntity
|
from homeassistant.components.binary_sensor import DEVICE_CLASSES, BinarySensorEntity
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import ATTR_COUNTER, DOMAIN
|
from .const import ATTR_COUNTER, DOMAIN
|
||||||
from .knx_entity import KnxEntity
|
from .knx_entity import KnxEntity
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
|
@ -15,12 +15,9 @@ from homeassistant.components.climate.const import (
|
||||||
SUPPORT_TARGET_TEMPERATURE,
|
SUPPORT_TARGET_TEMPERATURE,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import CONTROLLER_MODES, DOMAIN, PRESET_MODES
|
from .const import CONTROLLER_MODES, DOMAIN, PRESET_MODES
|
||||||
from .knx_entity import KnxEntity
|
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(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
|
@ -21,21 +21,17 @@ from homeassistant.components.cover import (
|
||||||
SUPPORT_STOP_TILT,
|
SUPPORT_STOP_TILT,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import HomeAssistant, callback
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.event import async_track_utc_time_change
|
from homeassistant.helpers.event import async_track_utc_time_change
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .knx_entity import KnxEntity
|
from .knx_entity import KnxEntity
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
|
@ -13,14 +13,9 @@ from homeassistant.const import (
|
||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
STATE_UNKNOWN,
|
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.event import async_track_state_change_event
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, StateType
|
||||||
ConfigType,
|
|
||||||
EventType,
|
|
||||||
HomeAssistantType,
|
|
||||||
StateType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import KNX_ADDRESS
|
from .const import KNX_ADDRESS
|
||||||
from .schema import ExposeSchema
|
from .schema import ExposeSchema
|
||||||
|
@ -28,7 +23,7 @@ from .schema import ExposeSchema
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def create_knx_exposure(
|
def create_knx_exposure(
|
||||||
hass: HomeAssistantType, xknx: XKNX, config: ConfigType
|
hass: HomeAssistant, xknx: XKNX, config: ConfigType
|
||||||
) -> KNXExposeSensor | KNXExposeTime:
|
) -> KNXExposeSensor | KNXExposeTime:
|
||||||
"""Create exposures from config."""
|
"""Create exposures from config."""
|
||||||
address = config[KNX_ADDRESS]
|
address = config[KNX_ADDRESS]
|
||||||
|
@ -61,7 +56,7 @@ class KNXExposeSensor:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
xknx: XKNX,
|
xknx: XKNX,
|
||||||
expose_type: int | str,
|
expose_type: int | str,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
|
@ -106,7 +101,7 @@ class KNXExposeSensor:
|
||||||
self._remove_listener = None
|
self._remove_listener = None
|
||||||
self.device.shutdown()
|
self.device.shutdown()
|
||||||
|
|
||||||
async def _async_entity_changed(self, event: EventType) -> None:
|
async def _async_entity_changed(self, event: Event) -> None:
|
||||||
"""Handle entity change."""
|
"""Handle entity change."""
|
||||||
new_state = event.data.get("new_state")
|
new_state = event.data.get("new_state")
|
||||||
if new_state is None:
|
if new_state is None:
|
||||||
|
|
|
@ -7,12 +7,9 @@ from typing import Any, Callable, Iterable
|
||||||
from xknx.devices import Fan as XknxFan
|
from xknx.devices import Fan as XknxFan
|
||||||
|
|
||||||
from homeassistant.components.fan import SUPPORT_OSCILLATE, SUPPORT_SET_SPEED, FanEntity
|
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.entity import Entity
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
from homeassistant.util.percentage import (
|
from homeassistant.util.percentage import (
|
||||||
int_states_in_range,
|
int_states_in_range,
|
||||||
percentage_to_ranged_value,
|
percentage_to_ranged_value,
|
||||||
|
@ -26,7 +23,7 @@ DEFAULT_PERCENTAGE = 50
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
|
@ -16,12 +16,9 @@ from homeassistant.components.light import (
|
||||||
SUPPORT_WHITE_VALUE,
|
SUPPORT_WHITE_VALUE,
|
||||||
LightEntity,
|
LightEntity,
|
||||||
)
|
)
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
import homeassistant.util.color as color_util
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -34,7 +31,7 @@ DEFAULT_WHITE_VALUE = 255
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
|
@ -6,17 +6,14 @@ from typing import Any
|
||||||
from xknx.devices import Notification as XknxNotification
|
from xknx.devices import Notification as XknxNotification
|
||||||
|
|
||||||
from homeassistant.components.notify import BaseNotificationService
|
from homeassistant.components.notify import BaseNotificationService
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.core import HomeAssistant
|
||||||
ConfigType,
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
|
|
||||||
async def async_get_service(
|
async def async_get_service(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
) -> KNXNotificationService | None:
|
) -> KNXNotificationService | None:
|
||||||
|
|
|
@ -6,19 +6,16 @@ from typing import Any, Callable, Iterable
|
||||||
from xknx.devices import Scene as XknxScene
|
from xknx.devices import Scene as XknxScene
|
||||||
|
|
||||||
from homeassistant.components.scene import Scene
|
from homeassistant.components.scene import Scene
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .knx_entity import KnxEntity
|
from .knx_entity import KnxEntity
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
|
@ -6,20 +6,16 @@ from typing import Callable, Iterable
|
||||||
from xknx.devices import Sensor as XknxSensor
|
from xknx.devices import Sensor as XknxSensor
|
||||||
|
|
||||||
from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity
|
from homeassistant.components.sensor import DEVICE_CLASSES, SensorEntity
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
StateType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .knx_entity import KnxEntity
|
from .knx_entity import KnxEntity
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
|
@ -6,19 +6,16 @@ from typing import Any, Callable, Iterable
|
||||||
from xknx.devices import Switch as XknxSwitch
|
from xknx.devices import Switch as XknxSwitch
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .knx_entity import KnxEntity
|
from .knx_entity import KnxEntity
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
|
@ -7,19 +7,16 @@ from xknx.devices import Weather as XknxWeather
|
||||||
|
|
||||||
from homeassistant.components.weather import WeatherEntity
|
from homeassistant.components.weather import WeatherEntity
|
||||||
from homeassistant.const import TEMP_CELSIUS
|
from homeassistant.const import TEMP_CELSIUS
|
||||||
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.typing import (
|
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||||
ConfigType,
|
|
||||||
DiscoveryInfoType,
|
|
||||||
HomeAssistantType,
|
|
||||||
)
|
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
from .knx_entity import KnxEntity
|
from .knx_entity import KnxEntity
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass: HomeAssistantType,
|
hass: HomeAssistant,
|
||||||
config: ConfigType,
|
config: ConfigType,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
discovery_info: DiscoveryInfoType | None = None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue