Skip to content

Commit

Permalink
Remove HomeAssistantType alias from entity components - Part 1 (#48467)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Mar 29, 2021
1 parent bb9da22 commit 855b68f
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 76 deletions.
5 changes: 2 additions & 3 deletions homeassistant/components/air_quality/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
5 changes: 2 additions & 3 deletions homeassistant/components/alarm_control_panel/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
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

Expand All @@ -38,7 +37,7 @@


async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/alert/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
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

Expand All @@ -23,7 +22,7 @@


async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/automation/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
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

Expand All @@ -23,7 +22,7 @@


async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/binary_sensor/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
9 changes: 5 additions & 4 deletions homeassistant/components/climate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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,
Expand All @@ -28,7 +29,7 @@
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 (
Expand Down Expand Up @@ -102,7 +103,7 @@
)


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
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/climate/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/climate/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
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,
Expand All @@ -28,7 +27,7 @@


async def _async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -75,7 +74,7 @@ async def call_service(service: str, keys: Iterable, data=None):


async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
)
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
Expand All @@ -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],
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/config/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
)
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

Expand All @@ -35,7 +34,7 @@ async def hook(action, config_key):

@callback
def async_describe_on_off_states(
hass: HomeAssistantType, registry: GroupIntegrationRegistry
hass: HomeAssistant, registry: GroupIntegrationRegistry
) -> None:
"""Describe group on off states."""
return
6 changes: 3 additions & 3 deletions homeassistant/components/counter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
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__)

Expand Down Expand Up @@ -101,7 +101,7 @@ def _none_to_empty_dict(value):
)


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()
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/counter/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
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,
Expand All @@ -23,7 +22,7 @@


async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/cover/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/cover/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
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

Expand All @@ -35,7 +34,7 @@


async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions homeassistant/components/device_tracker/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -36,12 +37,12 @@


@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)

Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/device_tracker/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Loading

0 comments on commit 855b68f

Please sign in to comment.