Skip to content

Commit

Permalink
Remove HomeAssistantType alias from entity components - Part 2 (#48468)
Browse files Browse the repository at this point in the history
  • Loading branch information
frenck authored Mar 29, 2021
1 parent 855b68f commit c1d5638
Show file tree
Hide file tree
Showing 27 changed files with 79 additions and 99 deletions.
9 changes: 4 additions & 5 deletions homeassistant/components/group/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
STATE_OFF,
STATE_ON,
)
from homeassistant.core import CoreState, callback, split_entity_id
from homeassistant.core import CoreState, HomeAssistant, callback, split_entity_id
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity, async_generate_entity_id
from homeassistant.helpers.entity_component import EntityComponent
Expand All @@ -34,7 +34,6 @@
async_process_integration_platforms,
)
from homeassistant.helpers.reload import async_reload_integration_platforms
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.loader import bind_hass

# mypy: allow-untyped-calls, allow-untyped-defs, no-check-untyped-defs
Expand Down Expand Up @@ -130,7 +129,7 @@ def is_on(hass, entity_id):


@bind_hass
def expand_entity_ids(hass: HomeAssistantType, entity_ids: Iterable[Any]) -> list[str]:
def expand_entity_ids(hass: HomeAssistant, entity_ids: Iterable[Any]) -> list[str]:
"""Return entity_ids with group entity ids replaced by their members.
Async friendly.
Expand Down Expand Up @@ -173,7 +172,7 @@ def expand_entity_ids(hass: HomeAssistantType, entity_ids: Iterable[Any]) -> lis

@bind_hass
def get_entity_ids(
hass: HomeAssistantType, entity_id: str, domain_filter: str | None = None
hass: HomeAssistant, entity_id: str, domain_filter: str | None = None
) -> list[str]:
"""Get members of this group.
Expand All @@ -194,7 +193,7 @@ def get_entity_ids(


@bind_hass
def groups_with_entity(hass: HomeAssistantType, entity_id: str) -> list[str]:
def groups_with_entity(hass: HomeAssistant, entity_id: str) -> list[str]:
"""Get all groups that contain this entity.
Async friendly.
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/group/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
STATE_ON,
STATE_UNAVAILABLE,
)
from homeassistant.core import CoreState, State
from homeassistant.core import CoreState, HomeAssistant, State
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.event import async_track_state_change_event
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import color as color_util

from . import GroupEntity
Expand Down Expand Up @@ -69,7 +69,7 @@


async def async_setup_platform(
hass: HomeAssistantType, config: ConfigType, async_add_entities, discovery_info=None
hass: HomeAssistant, config: ConfigType, async_add_entities, discovery_info=None
) -> None:
"""Initialize light.group platform."""
async_add_entities(
Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/group/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

from typing import Any, Iterable

from homeassistant.core import Context, State
from homeassistant.core import Context, HomeAssistant, State
from homeassistant.helpers.state import async_reproduce_state
from homeassistant.helpers.typing import HomeAssistantType

from . import get_entity_ids


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/history/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
CONF_INCLUDE,
HTTP_BAD_REQUEST,
)
from homeassistant.core import Context, State, split_entity_id
from homeassistant.core import Context, HomeAssistant, State, split_entity_id
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entityfilter import (
CONF_ENTITY_GLOBS,
INCLUDE_EXCLUDE_BASE_FILTER_SCHEMA,
)
from homeassistant.helpers.typing import HomeAssistantType
import homeassistant.util.dt as dt_util

# mypy: allow-untyped-defs, no-check-untyped-defs
Expand Down Expand Up @@ -673,7 +672,7 @@ def _glob_to_like(glob_str):


def _entities_may_have_state_changes_after(
hass: HomeAssistantType, entity_ids: Iterable, start_time: dt
hass: HomeAssistant, entity_ids: Iterable, start_time: dt
) -> bool:
"""Check the state machine to see if entities have changed since start time."""
for entity_id in entity_ids:
Expand Down
9 changes: 5 additions & 4 deletions homeassistant/components/humidifier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
SERVICE_TURN_ON,
STATE_ON,
)
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import ( # noqa: F401
PLATFORM_SCHEMA,
PLATFORM_SCHEMA_BASE,
)
from homeassistant.helpers.entity import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
from homeassistant.helpers.typing import ConfigType
from homeassistant.loader import bind_hass

from .const import (
Expand Down Expand Up @@ -59,7 +60,7 @@ def is_on(hass, entity_id):
return hass.states.is_state(entity_id, STATE_ON)


async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up humidifier devices."""
component = hass.data[DOMAIN] = EntityComponent(
_LOGGER, DOMAIN, hass, SCAN_INTERVAL
Expand Down Expand Up @@ -88,12 +89,12 @@ 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."""
return await hass.data[DOMAIN].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."""
return await hass.data[DOMAIN].async_unload_entry(entry)

Expand Down
5 changes: 2 additions & 3 deletions homeassistant/components/humidifier/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)
7 changes: 3 additions & 4 deletions homeassistant/components/humidifier/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
STATE_OFF,
STATE_ON,
)
from homeassistant.core import Context, State
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.core import Context, HomeAssistant, State

from .const import ATTR_HUMIDITY, DOMAIN, SERVICE_SET_HUMIDITY, SERVICE_SET_MODE

_LOGGER = logging.getLogger(__name__)


async def _async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -81,7 +80,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
6 changes: 3 additions & 3 deletions homeassistant/components/input_boolean/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
SERVICE_TURN_ON,
STATE_ON,
)
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 import ToggleEntity
from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.restore_state import RestoreEntity
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceCallType
from homeassistant.helpers.typing import ConfigType, ServiceCallType
from homeassistant.loader import bind_hass

DOMAIN = "input_boolean"
Expand Down Expand Up @@ -82,7 +82,7 @@ def is_on(hass, entity_id):
return hass.states.is_state(entity_id, STATE_ON)


async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input boolean."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager()
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/input_boolean/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
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

_LOGGER = logging.getLogger(__name__)


async def _async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -55,7 +54,7 @@ async def _async_reproduce_states(


async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/input_datetime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
CONF_NAME,
SERVICE_RELOAD,
)
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
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceCallType
from homeassistant.helpers.typing import ConfigType, ServiceCallType
from homeassistant.util import dt as dt_util

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -101,7 +101,7 @@ def has_date_or_time(conf):
RELOAD_SERVICE_SCHEMA = vol.Schema({})


async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input datetime."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager()
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/input_datetime/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 homeassistant.util import dt as dt_util

from . import ATTR_DATE, ATTR_DATETIME, ATTR_TIME, CONF_HAS_DATE, CONF_HAS_TIME, DOMAIN
Expand All @@ -34,7 +33,7 @@ def is_valid_time(string: str) -> bool:


async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -79,7 +78,7 @@ async def _async_reproduce_state(


async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/input_number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
CONF_UNIT_OF_MEASUREMENT,
SERVICE_RELOAD,
)
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
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceCallType
from homeassistant.helpers.typing import ConfigType, ServiceCallType

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -112,7 +112,7 @@ def _cv_input_number(cfg):
STORAGE_VERSION = 1


async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input slider."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager()
Expand Down
7 changes: 3 additions & 4 deletions homeassistant/components/input_number/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
import voluptuous as vol

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_VALUE, DOMAIN, SERVICE_SET_VALUE

_LOGGER = logging.getLogger(__name__)


async def _async_reproduce_state(
hass: HomeAssistantType,
hass: HomeAssistant,
state: State,
*,
context: Context | None = None,
Expand Down Expand Up @@ -55,7 +54,7 @@ async def _async_reproduce_state(


async def async_reproduce_states(
hass: HomeAssistantType,
hass: HomeAssistant,
states: Iterable[State],
*,
context: Context | None = None,
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/input_select/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
CONF_NAME,
SERVICE_RELOAD,
)
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
import homeassistant.helpers.service
from homeassistant.helpers.storage import Store
from homeassistant.helpers.typing import ConfigType, HomeAssistantType, ServiceCallType
from homeassistant.helpers.typing import ConfigType, ServiceCallType

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -87,7 +87,7 @@ def _cv_input_select(cfg):
RELOAD_SERVICE_SCHEMA = vol.Schema({})


async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up an input select."""
component = EntityComponent(_LOGGER, DOMAIN, hass)
id_manager = collection.IDManager()
Expand Down
Loading

0 comments on commit c1d5638

Please sign in to comment.