Replace HomeAssistantType with HomeAssistant (#53545)

This commit is contained in:
Milan Meulemans 2021-07-27 12:30:56 +02:00 committed by GitHub
parent ca020e1f87
commit 0471b27179
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 61 additions and 52 deletions

View file

@ -27,14 +27,13 @@ from homeassistant.components.camera import (
async_get_still_stream,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import (
async_dispatcher_connect,
async_dispatcher_send,
)
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import HomeAssistantType
from . import (
get_hyperion_device_id,
@ -57,7 +56,7 @@ IMAGE_STREAM_JPG_SENTINEL = "data:image/jpg;base64,"
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -15,9 +15,10 @@ from homeassistant.const import (
CONF_RESOURCE,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from .const import CONF_DIM_MODE, CONF_SK_NUM_TRIES, CONNECTION, DOMAIN, PLATFORMS
from .helpers import (
@ -32,7 +33,7 @@ from .services import SERVICES
_LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the LCN component."""
if DOMAIN not in config:
return True
@ -53,7 +54,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup_entry(
hass: HomeAssistantType, config_entry: config_entries.ConfigEntry
hass: HomeAssistant, config_entry: config_entries.ConfigEntry
) -> bool:
"""Set up a connection to PCHK host from a config entry."""
hass.data.setdefault(DOMAIN, {})
@ -116,7 +117,7 @@ async def async_setup_entry(
async def async_unload_entry(
hass: HomeAssistantType, config_entry: config_entries.ConfigEntry
hass: HomeAssistant, config_entry: config_entries.ConfigEntry
) -> bool:
"""Close connection to PCHK host represented by config_entry."""
# forward unloading to platforms

View file

@ -9,8 +9,9 @@ from homeassistant.components.binary_sensor import (
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS, CONF_DOMAIN, CONF_ENTITIES, CONF_SOURCE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from . import LcnEntity
from .const import BINSENSOR_PORTS, CONF_DOMAIN_DATA, SETPOINTS
@ -18,7 +19,7 @@ from .helpers import DeviceConnectionType, InputType, get_device_connection
def create_lcn_binary_sensor_entity(
hass: HomeAssistantType, entity_config: ConfigType, config_entry: ConfigEntry
hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry
) -> LcnEntity:
"""Set up an entity for this domain."""
device_connection = get_device_connection(
@ -36,7 +37,7 @@ def create_lcn_binary_sensor_entity(
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -21,8 +21,9 @@ from homeassistant.const import (
TEMP_CELSIUS,
TEMP_FAHRENHEIT,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from . import LcnEntity
from .const import (
@ -38,7 +39,7 @@ PARALLEL_UPDATES = 0
def create_lcn_climate_entity(
hass: HomeAssistantType, entity_config: ConfigType, config_entry: ConfigEntry
hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry
) -> LcnEntity:
"""Set up an entity for this domain."""
device_connection = get_device_connection(
@ -49,7 +50,7 @@ def create_lcn_climate_entity(
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -13,8 +13,9 @@ from homeassistant.const import (
CONF_PORT,
CONF_USERNAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from .const import CONF_DIM_MODE, CONF_SK_NUM_TRIES, DOMAIN
@ -22,7 +23,7 @@ _LOGGER = logging.getLogger(__name__)
def get_config_entry(
hass: HomeAssistantType, data: ConfigType
hass: HomeAssistant, data: ConfigType
) -> config_entries.ConfigEntry | None:
"""Check config entries for already configured entries based on the ip address/port."""
return next(

View file

@ -8,8 +8,9 @@ import pypck
from homeassistant.components.cover import DOMAIN as DOMAIN_COVER, CoverEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS, CONF_DOMAIN, CONF_ENTITIES
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from . import LcnEntity
from .const import CONF_DOMAIN_DATA, CONF_MOTOR, CONF_REVERSE_TIME
@ -19,7 +20,7 @@ PARALLEL_UPDATES = 0
def create_lcn_cover_entity(
hass: HomeAssistantType, entity_config: ConfigType, config_entry: ConfigEntry
hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry
) -> LcnEntity:
"""Set up an entity for this domain."""
device_connection = get_device_connection(
@ -33,7 +34,7 @@ def create_lcn_cover_entity(
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -25,7 +25,8 @@ from homeassistant.const import (
CONF_SWITCHES,
CONF_USERNAME,
)
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .const import (
CONF_CLIMATES,
@ -68,7 +69,7 @@ DOMAIN_LOOKUP = {
def get_device_connection(
hass: HomeAssistantType, address: AddressType, config_entry: ConfigEntry
hass: HomeAssistant, address: AddressType, config_entry: ConfigEntry
) -> DeviceConnectionType | None:
"""Return a lcn device_connection."""
host_connection = hass.data[DOMAIN][config_entry.entry_id][CONNECTION]

View file

@ -15,8 +15,9 @@ from homeassistant.components.light import (
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS, CONF_DOMAIN, CONF_ENTITIES
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from . import LcnEntity
from .const import (
@ -32,7 +33,7 @@ PARALLEL_UPDATES = 0
def create_lcn_light_entity(
hass: HomeAssistantType, entity_config: ConfigType, config_entry: ConfigEntry
hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry
) -> LcnEntity:
"""Set up an entity for this domain."""
device_connection = get_device_connection(
@ -46,7 +47,7 @@ def create_lcn_light_entity(
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -8,8 +8,9 @@ import pypck
from homeassistant.components.scene import DOMAIN as DOMAIN_SCENE, Scene
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS, CONF_DOMAIN, CONF_ENTITIES, CONF_SCENE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from . import LcnEntity
from .const import (
@ -25,7 +26,7 @@ PARALLEL_UPDATES = 0
def create_lcn_scene_entity(
hass: HomeAssistantType, entity_config: ConfigType, config_entry: ConfigEntry
hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry
) -> LcnEntity:
"""Set up an entity for this domain."""
device_connection = get_device_connection(
@ -36,7 +37,7 @@ def create_lcn_scene_entity(
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -14,8 +14,9 @@ from homeassistant.const import (
CONF_SOURCE,
CONF_UNIT_OF_MEASUREMENT,
)
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from . import LcnEntity
from .const import (
@ -30,7 +31,7 @@ from .helpers import DeviceConnectionType, InputType, get_device_connection
def create_lcn_sensor_entity(
hass: HomeAssistantType, entity_config: ConfigType, config_entry: ConfigEntry
hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry
) -> LcnEntity:
"""Set up an entity for this domain."""
device_connection = get_device_connection(
@ -49,7 +50,7 @@ def create_lcn_sensor_entity(
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -11,8 +11,9 @@ from homeassistant.const import (
CONF_UNIT_OF_MEASUREMENT,
TIME_SECONDS,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import HomeAssistantType, ServiceCallType
from homeassistant.helpers.typing import ServiceCallType
from .const import (
CONF_KEYS,
@ -54,7 +55,7 @@ class LcnServiceCall:
schema = vol.Schema({vol.Required(CONF_ADDRESS): is_address})
def __init__(self, hass: HomeAssistantType) -> None:
def __init__(self, hass: HomeAssistant) -> None:
"""Initialize service call."""
self.hass = hass

View file

@ -8,8 +8,9 @@ import pypck
from homeassistant.components.switch import DOMAIN as DOMAIN_SWITCH, SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_ADDRESS, CONF_DOMAIN, CONF_ENTITIES
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from . import LcnEntity
from .const import CONF_DOMAIN_DATA, CONF_OUTPUT, OUTPUT_PORTS
@ -19,7 +20,7 @@ PARALLEL_UPDATES = 0
def create_lcn_switch_entity(
hass: HomeAssistantType, entity_config: ConfigType, config_entry: ConfigEntry
hass: HomeAssistant, entity_config: ConfigType, config_entry: ConfigEntry
) -> LcnEntity:
"""Set up an entity for this domain."""
device_connection = get_device_connection(
@ -33,7 +34,7 @@ def create_lcn_switch_entity(
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -4,7 +4,7 @@ import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_ATTRIBUTION
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
DataUpdateCoordinator,
@ -26,7 +26,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities
hass: HomeAssistant, entry: ConfigEntry, async_add_entities
) -> None:
"""Set up the Meteoclimatic sensor platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]

View file

@ -8,9 +8,9 @@ import voluptuous as vol
from homeassistant.components.fan import SUPPORT_DIRECTION, SUPPORT_SET_SPEED, FanEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util.percentage import (
int_states_in_range,
percentage_to_ranged_value,
@ -34,7 +34,7 @@ from .const import (
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -12,9 +12,9 @@ from homeassistant.components.light import (
LightEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util.percentage import (
percentage_to_ranged_value,
ranged_value_to_percentage,
@ -39,7 +39,7 @@ BRIGHTNESS_RANGE = (1, 255)
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:

View file

@ -18,8 +18,7 @@ from homeassistant.components.light import (
SUPPORT_EFFECT,
LightEntity,
)
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util.color import color_hsv_to_RGB, color_RGB_to_hsv
@ -34,7 +33,7 @@ EFFECT_EXPERT_STYLES = {"FOLLOW_AUDIO", "FOLLOW_COLOR", "Lounge light"}
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
config_entry: config_entries.ConfigEntry,
async_add_entities,
):

View file

@ -10,7 +10,7 @@ import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import SERVICE_TOGGLE, SERVICE_TURN_OFF, SERVICE_TURN_ON
from homeassistant.core import ServiceCall
from homeassistant.core import HomeAssistant, ServiceCall
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
@ -18,7 +18,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
)
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from .const import (
ATTR_AVAILABLE_TONES,
@ -77,7 +77,7 @@ def process_turn_on_params(
return params
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up siren devices."""
component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
@ -110,13 +110,13 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
return True
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up a config entry."""
component: EntityComponent = hass.data[DOMAIN]
return await component.async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
component: EntityComponent = hass.data[DOMAIN]
return await component.async_unload_entry(entry)

View file

@ -34,12 +34,12 @@ from homeassistant.const import (
STATE_PAUSED,
STATE_PLAYING,
)
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import DiscoveryInfoType, HomeAssistantType
from homeassistant.helpers.typing import DiscoveryInfoType
from homeassistant.util import uuid
from . import MusicCastDataUpdateCoordinator, MusicCastDeviceEntity
@ -79,7 +79,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
async def async_setup_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config,
async_add_devices: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
@ -107,7 +107,7 @@ async def async_setup_platform(
async def async_setup_entry(
hass: HomeAssistantType,
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None: