Remove HomeAssistantType alias from entity components - Part 1 (#48467)

This commit is contained in:
Franck Nijhof 2021-03-30 01:24:36 +02:00 committed by GitHub
parent bb9da22a84
commit 855b68faa1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 60 additions and 76 deletions

View file

@ -2,13 +2,12 @@
from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant, callback
@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.exclude_domain()

View file

@ -10,13 +10,12 @@ from homeassistant.const import (
STATE_ALARM_TRIGGERED,
STATE_OFF,
)
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant, callback
@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.on_off_states(

View file

@ -20,8 +20,7 @@ from homeassistant.const import (
STATE_ALARM_DISARMED,
STATE_ALARM_TRIGGERED,
)
from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import Context, HomeAssistant, State
from . import DOMAIN
@ -38,7 +37,7 @@ VALID_STATES = {
async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
@ -82,7 +81,7 @@ async def _async_reproduce_state(
async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,

View file

@ -12,8 +12,7 @@ from homeassistant.const import (
STATE_OFF,
STATE_ON,
)
from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import Context, HomeAssistant, State
from . import DOMAIN
@ -23,7 +22,7 @@ VALID_STATES = {STATE_ON, STATE_OFF}
async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
@ -60,7 +59,7 @@ async def _async_reproduce_state(
async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,

View file

@ -12,8 +12,7 @@ from homeassistant.const import (
STATE_OFF,
STATE_ON,
)
from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import Context, HomeAssistant, State
from . import DOMAIN
@ -23,7 +22,7 @@ VALID_STATES = {STATE_ON, STATE_OFF}
async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
@ -59,7 +58,7 @@ async def _async_reproduce_state(
async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,

View file

@ -3,13 +3,12 @@
from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant, callback
@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.on_off_states({STATE_ON}, STATE_OFF)

View file

@ -19,6 +19,7 @@ from homeassistant.const import (
STATE_ON,
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
@ -28,7 +29,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.temperature import display_temp as show_temp
from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceDataType
from homeassistant.helpers.typing import ConfigType, ServiceDataType
from homeassistant.util.temperature import convert as convert_temperature
from .const import (
@ -102,7 +103,7 @@ SET_TEMPERATURE_SCHEMA = vol.All(
)
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up climate entities."""
component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
@ -156,12 +157,12 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
return True
async def async_setup_entry(hass: HomeAssistantType, entry):
async def async_setup_entry(hass: HomeAssistant, entry):
"""Set up a config entry."""
return await hass.data[DOMAIN].async_setup_entry(entry)
async def async_unload_entry(hass: HomeAssistantType, entry):
async def async_unload_entry(hass: HomeAssistant, entry):
"""Unload a config entry."""
return await hass.data[DOMAIN].async_unload_entry(entry)

View file

@ -3,15 +3,14 @@
from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_OFF
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant, callback
from .const import HVAC_MODE_OFF, HVAC_MODES
@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.on_off_states(

View file

@ -5,8 +5,7 @@ import asyncio
from typing import Any, Iterable
from homeassistant.const import ATTR_TEMPERATURE
from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import Context, HomeAssistant, State
from .const import (
ATTR_AUX_HEAT,
@ -28,7 +27,7 @@ from .const import (
async def _async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
@ -75,7 +74,7 @@ async def _async_reproduce_states(
async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,

View file

@ -15,10 +15,9 @@ from homeassistant.components.alexa import (
)
from homeassistant.components.google_assistant import const as gc, smart_home as ga
from homeassistant.const import HTTP_OK
from homeassistant.core import Context, callback
from homeassistant.core import Context, HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util.aiohttp import MockRequest
from . import alexa_config, google_config, utils
@ -31,7 +30,7 @@ class CloudClient(Interface):
def __init__(
self,
hass: HomeAssistantType,
hass: HomeAssistant,
prefs: CloudPreferences,
websession: aiohttp.ClientSession,
alexa_user_config: dict[str, Any],

View file

@ -6,9 +6,8 @@ from homeassistant.components.group import (
)
from homeassistant.config import GROUP_CONFIG_PATH
from homeassistant.const import SERVICE_RELOAD
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import HomeAssistantType
from . import EditKeyBasedConfigView
@ -35,7 +34,7 @@ async def async_setup(hass):
@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
return

View file

@ -13,13 +13,13 @@ from homeassistant.const import (
CONF_MINIMUM,
CONF_NAME,
)
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import collection
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
_LOGGER = logging.getLogger(__name__)
@ -101,7 +101,7 @@ CONFIG_SCHEMA = vol.Schema(
)
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up the counters."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager()

View file

@ -6,8 +6,7 @@ import logging
from typing import Any, Iterable
from homeassistant.const import ATTR_ENTITY_ID
from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import Context, HomeAssistant, State
from . import (
ATTR_INITIAL,
@ -23,7 +22,7 @@ _LOGGER = logging.getLogger(__name__)
async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
@ -69,7 +68,7 @@ async def _async_reproduce_state(
async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,

View file

@ -3,13 +3,12 @@
from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_CLOSED, STATE_OPEN
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant, callback
@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
# On means open, Off means closed

View file

@ -24,8 +24,7 @@ from homeassistant.const import (
STATE_OPEN,
STATE_OPENING,
)
from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import Context, HomeAssistant, State
from . import DOMAIN
@ -35,7 +34,7 @@ VALID_STATES = {STATE_CLOSED, STATE_CLOSING, STATE_OPEN, STATE_OPENING}
async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
@ -116,7 +115,7 @@ async def _async_reproduce_state(
async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,

View file

@ -1,6 +1,7 @@
"""Provide functionality to keep track of devices."""
from homeassistant.const import ATTR_GPS_ACCURACY, STATE_HOME # noqa: F401
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass
from .config_entry import async_setup_entry, async_unload_entry # noqa: F401
@ -36,12 +37,12 @@ from .legacy import ( # noqa: F401
@bind_hass
def is_on(hass: HomeAssistantType, entity_id: str):
def is_on(hass: HomeAssistant, entity_id: str):
"""Return the state if any or a specified device is home."""
return hass.states.is_state(entity_id, STATE_HOME)
async def async_setup(hass: HomeAssistantType, config: ConfigType):
async def async_setup(hass: HomeAssistant, config: ConfigType):
"""Set up the device tracker."""
await async_setup_legacy_integration(hass, config)

View file

@ -3,13 +3,12 @@
from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_HOME, STATE_NOT_HOME
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant, callback
@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.on_off_states({STATE_HOME}, STATE_NOT_HOME)

View file

@ -27,7 +27,7 @@ from homeassistant.const import (
STATE_HOME,
STATE_NOT_HOME,
)
from homeassistant.core import callback
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_per_platform, discovery
import homeassistant.helpers.config_validation as cv
@ -37,7 +37,7 @@ from homeassistant.helpers.event import (
async_track_utc_time_change,
)
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import ConfigType, GPSType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType, GPSType
from homeassistant.setup import async_prepare_setup_platform
from homeassistant.util import dt as dt_util
from homeassistant.util.yaml import dump
@ -119,7 +119,7 @@ EVENT_NEW_DEVICE = "device_tracker_new_device"
def see(
hass: HomeAssistantType,
hass: HomeAssistant,
mac: str = None,
dev_id: str = None,
host_name: str = None,
@ -148,7 +148,7 @@ def see(
hass.services.call(DOMAIN, SERVICE_SEE, data)
async def async_setup_integration(hass: HomeAssistantType, config: ConfigType) -> None:
async def async_setup_integration(hass: HomeAssistant, config: ConfigType) -> None:
"""Set up the legacy integration."""
tracker = await get_tracker(hass, config)
@ -302,7 +302,7 @@ async def async_create_platform_type(
@callback
def async_setup_scanner_platform(
hass: HomeAssistantType,
hass: HomeAssistant,
config: ConfigType,
scanner: Any,
async_see_device: Callable,
@ -392,7 +392,7 @@ class DeviceTracker:
def __init__(
self,
hass: HomeAssistantType,
hass: HomeAssistant,
consider_home: timedelta,
track_new: bool,
defaults: dict,
@ -609,7 +609,7 @@ class Device(RestoreEntity):
def __init__(
self,
hass: HomeAssistantType,
hass: HomeAssistant,
consider_home: timedelta,
track: bool,
dev_id: str,
@ -790,7 +790,7 @@ class Device(RestoreEntity):
class DeviceScanner:
"""Device scanner object."""
hass: HomeAssistantType = None
hass: HomeAssistant = None
def scan_devices(self) -> list[str]:
"""Scan for devices."""
@ -817,9 +817,7 @@ class DeviceScanner:
return await self.hass.async_add_executor_job(self.get_extra_attributes, device)
async def async_load_config(
path: str, hass: HomeAssistantType, consider_home: timedelta
):
async def async_load_config(path: str, hass: HomeAssistant, consider_home: timedelta):
"""Load devices from YAML configuration file.
This method is a coroutine.

View file

@ -3,13 +3,12 @@
from homeassistant.components.group import GroupIntegrationRegistry
from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import callback
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import HomeAssistant, callback
@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
registry.on_off_states({STATE_ON}, STATE_OFF)

View file

@ -13,8 +13,7 @@ from homeassistant.const import (
STATE_OFF,
STATE_ON,
)
from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import Context, HomeAssistant, State
from . import (
ATTR_DIRECTION,
@ -43,7 +42,7 @@ ATTRIBUTES = { # attribute: service
async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
@ -97,7 +96,7 @@ async def _async_reproduce_state(
async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,