Integrations h*: Rename HomeAssistantType to HomeAssistant. (#49590)

This commit is contained in:
jan iversen 2021-04-23 09:49:02 +02:00 committed by GitHub
parent a5a3c98aff
commit 017e32a0cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 73 additions and 79 deletions

View file

@ -11,9 +11,10 @@ import voluptuous as vol
from homeassistant.components.media_player.const import DOMAIN as MEDIA_PLAYER_DOMAIN from homeassistant.components.media_player.const import DOMAIN as MEDIA_PLAYER_DOMAIN
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP from homeassistant.const import CONF_HOST, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from homeassistant.util import Throttle from homeassistant.util import Throttle
from . import services from . import services
@ -36,7 +37,7 @@ MIN_UPDATE_SOURCES = timedelta(seconds=1)
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
async def async_setup(hass: HomeAssistantType, config: ConfigType): async def async_setup(hass: HomeAssistant, config: ConfigType):
"""Set up the HEOS component.""" """Set up the HEOS component."""
if DOMAIN not in config: if DOMAIN not in config:
return True return True
@ -60,7 +61,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType):
return True return True
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Initialize config entry which represents the HEOS controller.""" """Initialize config entry which represents the HEOS controller."""
# For backwards compat # For backwards compat
if entry.unique_id is None: if entry.unique_id is None:
@ -124,7 +125,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
return True return True
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry): async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry.""" """Unload a config entry."""
controller_manager = hass.data[DOMAIN][DATA_CONTROLLER_MANAGER] controller_manager = hass.data[DOMAIN][DATA_CONTROLLER_MANAGER]
await controller_manager.disconnect() await controller_manager.disconnect()

View file

@ -30,7 +30,7 @@ from homeassistant.components.media_player.const import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import STATE_IDLE, STATE_PAUSED, STATE_PLAYING from homeassistant.const import STATE_IDLE, STATE_PAUSED, STATE_PLAYING
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from homeassistant.util.dt import utcnow from homeassistant.util.dt import utcnow
from .const import DATA_SOURCE_MANAGER, DOMAIN as HEOS_DOMAIN, SIGNAL_HEOS_UPDATED from .const import DATA_SOURCE_MANAGER, DOMAIN as HEOS_DOMAIN, SIGNAL_HEOS_UPDATED
@ -63,7 +63,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, entry: ConfigEntry, async_add_entities hass: HomeAssistant, entry: ConfigEntry, async_add_entities
): ):
"""Add media players for a config entry.""" """Add media players for a config entry."""
players = hass.data[HEOS_DOMAIN][DOMAIN] players = hass.data[HEOS_DOMAIN][DOMAIN]

View file

@ -5,8 +5,8 @@ import logging
from pyheos import CommandFailedError, Heos, HeosError, const from pyheos import CommandFailedError, Heos, HeosError, const
import voluptuous as vol import voluptuous as vol
from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.typing import HomeAssistantType
from .const import ( from .const import (
ATTR_PASSWORD, ATTR_PASSWORD,
@ -25,7 +25,7 @@ HEOS_SIGN_IN_SCHEMA = vol.Schema(
HEOS_SIGN_OUT_SCHEMA = vol.Schema({}) HEOS_SIGN_OUT_SCHEMA = vol.Schema({})
def register(hass: HomeAssistantType, controller: Heos): def register(hass: HomeAssistant, controller: Heos):
"""Register HEOS services.""" """Register HEOS services."""
hass.services.async_register( hass.services.async_register(
DOMAIN, DOMAIN,
@ -41,7 +41,7 @@ def register(hass: HomeAssistantType, controller: Heos):
) )
def remove(hass: HomeAssistantType): def remove(hass: HomeAssistant):
"""Unregister HEOS services.""" """Unregister HEOS services."""
hass.services.async_remove(DOMAIN, SERVICE_SIGN_IN) hass.services.async_remove(DOMAIN, SERVICE_SIGN_IN)
hass.services.async_remove(DOMAIN, SERVICE_SIGN_OUT) hass.services.async_remove(DOMAIN, SERVICE_SIGN_OUT)

View file

@ -4,10 +4,11 @@ import voluptuous as vol
from homeassistant import config_entries from homeassistant import config_entries
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_NAME, EVENT_HOMEASSISTANT_STOP from homeassistant.const import CONF_NAME, EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er from homeassistant.helpers import device_registry as dr, entity_registry as er
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_registry import async_entries_for_config_entry from homeassistant.helpers.entity_registry import async_entries_for_config_entry
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
CONF_ACCESSPOINT, CONF_ACCESSPOINT,
@ -40,7 +41,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 HomematicIP Cloud component.""" """Set up the HomematicIP Cloud component."""
hass.data[DOMAIN] = {} hass.data[DOMAIN] = {}
@ -66,7 +67,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
return True return True
async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up an access point from a config entry.""" """Set up an access point from a config entry."""
# 0.104 introduced config entry unique id, this makes upgrading possible # 0.104 introduced config entry unique id, this makes upgrading possible
@ -107,7 +108,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
return True return True
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool: async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry.""" """Unload a config entry."""
hap = hass.data[DOMAIN].pop(entry.unique_id) hap = hass.data[DOMAIN].pop(entry.unique_id)
hap.reset_connection_listener() hap.reset_connection_listener()
@ -118,7 +119,7 @@ async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> boo
async def async_remove_obsolete_entities( async def async_remove_obsolete_entities(
hass: HomeAssistantType, entry: ConfigEntry, hap: HomematicipHAP hass: HomeAssistant, entry: ConfigEntry, hap: HomematicipHAP
): ):
"""Remove obsolete entities from entity registry.""" """Remove obsolete entities from entity registry."""

View file

@ -18,8 +18,7 @@ from homeassistant.const import (
STATE_ALARM_DISARMED, STATE_ALARM_DISARMED,
STATE_ALARM_TRIGGERED, STATE_ALARM_TRIGGERED,
) )
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.typing import HomeAssistantType
from . import DOMAIN as HMIPC_DOMAIN from . import DOMAIN as HMIPC_DOMAIN
from .hap import HomematicipHAP from .hap import HomematicipHAP
@ -30,7 +29,7 @@ CONST_ALARM_CONTROL_PANEL_NAME = "HmIP Alarm Control Panel"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the HomematicIP alrm control panel from a config entry.""" """Set up the HomematicIP alrm control panel from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]

View file

@ -44,7 +44,7 @@ from homeassistant.components.binary_sensor import (
BinarySensorEntity, BinarySensorEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .hap import HomematicipHAP from .hap import HomematicipHAP
@ -80,7 +80,7 @@ SAM_DEVICE_ATTRIBUTES = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the HomematicIP Cloud binary sensor from a config entry.""" """Set up the HomematicIP Cloud binary sensor from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]

View file

@ -26,7 +26,7 @@ from homeassistant.components.climate.const import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .hap import HomematicipHAP from .hap import HomematicipHAP
@ -43,7 +43,7 @@ HMIP_ECO_CM = "ECO"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the HomematicIP climate from a config entry.""" """Set up the HomematicIP climate from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]

View file

@ -18,7 +18,7 @@ from homeassistant.components.cover import (
CoverEntity, CoverEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .hap import HomematicipHAP from .hap import HomematicipHAP
@ -30,7 +30,7 @@ HMIP_SLATS_CLOSED = 1
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the HomematicIP cover from a config entry.""" """Set up the HomematicIP cover from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]

View file

@ -8,10 +8,9 @@ from homematicip.base.base_connection import HmipConnectionError
from homematicip.base.enums import EventType from homematicip.base.enums import EventType
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.typing import HomeAssistantType
from .const import HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN, PLATFORMS from .const import HMIPC_AUTHTOKEN, HMIPC_HAPID, HMIPC_NAME, HMIPC_PIN, PLATFORMS
from .errors import HmipcConnectionError from .errors import HmipcConnectionError
@ -54,7 +53,7 @@ class HomematicipAuth:
except HmipConnectionError: except HmipConnectionError:
return False return False
async def get_auth(self, hass: HomeAssistantType, hapid, pin): async def get_auth(self, hass: HomeAssistant, hapid, pin):
"""Create a HomematicIP access point object.""" """Create a HomematicIP access point object."""
auth = AsyncAuth(hass.loop, async_get_clientsession(hass)) auth = AsyncAuth(hass.loop, async_get_clientsession(hass))
try: try:
@ -70,7 +69,7 @@ class HomematicipAuth:
class HomematicipHAP: class HomematicipHAP:
"""Manages HomematicIP HTTP and WebSocket connection.""" """Manages HomematicIP HTTP and WebSocket connection."""
def __init__(self, hass: HomeAssistantType, config_entry: ConfigEntry) -> None: def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:
"""Initialize HomematicIP Cloud connection.""" """Initialize HomematicIP Cloud connection."""
self.hass = hass self.hass = hass
self.config_entry = config_entry self.config_entry = config_entry
@ -234,7 +233,7 @@ class HomematicipHAP:
) )
async def get_hap( async def get_hap(
self, hass: HomeAssistantType, hapid: str, authtoken: str, name: str self, hass: HomeAssistant, hapid: str, authtoken: str, name: str
) -> AsyncHome: ) -> AsyncHome:
"""Create a HomematicIP access point object.""" """Create a HomematicIP access point object."""
home = AsyncHome(hass.loop, async_get_clientsession(hass)) home = AsyncHome(hass.loop, async_get_clientsession(hass))

View file

@ -26,7 +26,7 @@ from homeassistant.components.light import (
LightEntity, LightEntity,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .hap import HomematicipHAP from .hap import HomematicipHAP
@ -36,7 +36,7 @@ ATTR_CURRENT_POWER_W = "current_power_w"
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the HomematicIP Cloud lights from a config entry.""" """Set up the HomematicIP Cloud lights from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]

View file

@ -40,7 +40,7 @@ from homeassistant.const import (
SPEED_KILOMETERS_PER_HOUR, SPEED_KILOMETERS_PER_HOUR,
TEMP_CELSIUS, TEMP_CELSIUS,
) )
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .hap import HomematicipHAP from .hap import HomematicipHAP
@ -62,7 +62,7 @@ ILLUMINATION_DEVICE_ATTRIBUTES = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the HomematicIP Cloud sensors from a config entry.""" """Set up the HomematicIP Cloud sensors from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]

View file

@ -11,13 +11,14 @@ from homematicip.base.helpers import handle_config
import voluptuous as vol import voluptuous as vol
from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE from homeassistant.const import ATTR_ENTITY_ID, ATTR_TEMPERATURE
from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.config_validation import comp_entity_ids from homeassistant.helpers.config_validation import comp_entity_ids
from homeassistant.helpers.service import ( from homeassistant.helpers.service import (
async_register_admin_service, async_register_admin_service,
verify_domain_control, verify_domain_control,
) )
from homeassistant.helpers.typing import HomeAssistantType, ServiceCallType from homeassistant.helpers.typing import ServiceCallType
from .const import DOMAIN as HMIPC_DOMAIN from .const import DOMAIN as HMIPC_DOMAIN
@ -107,7 +108,7 @@ SCHEMA_RESET_ENERGY_COUNTER = vol.Schema(
) )
async def async_setup_services(hass: HomeAssistantType) -> None: async def async_setup_services(hass: HomeAssistant) -> None:
"""Set up the HomematicIP Cloud services.""" """Set up the HomematicIP Cloud services."""
if hass.services.async_services().get(HMIPC_DOMAIN): if hass.services.async_services().get(HMIPC_DOMAIN):
@ -194,7 +195,7 @@ async def async_setup_services(hass: HomeAssistantType) -> None:
) )
async def async_unload_services(hass: HomeAssistantType): async def async_unload_services(hass: HomeAssistant):
"""Unload HomematicIP Cloud services.""" """Unload HomematicIP Cloud services."""
if hass.data[HMIPC_DOMAIN]: if hass.data[HMIPC_DOMAIN]:
return return
@ -204,7 +205,7 @@ async def async_unload_services(hass: HomeAssistantType):
async def _async_activate_eco_mode_with_duration( async def _async_activate_eco_mode_with_duration(
hass: HomeAssistantType, service: ServiceCallType hass: HomeAssistant, service: ServiceCallType
) -> None: ) -> None:
"""Service to activate eco mode with duration.""" """Service to activate eco mode with duration."""
duration = service.data[ATTR_DURATION] duration = service.data[ATTR_DURATION]
@ -220,7 +221,7 @@ async def _async_activate_eco_mode_with_duration(
async def _async_activate_eco_mode_with_period( async def _async_activate_eco_mode_with_period(
hass: HomeAssistantType, service: ServiceCallType hass: HomeAssistant, service: ServiceCallType
) -> None: ) -> None:
"""Service to activate eco mode with period.""" """Service to activate eco mode with period."""
endtime = service.data[ATTR_ENDTIME] endtime = service.data[ATTR_ENDTIME]
@ -236,7 +237,7 @@ async def _async_activate_eco_mode_with_period(
async def _async_activate_vacation( async def _async_activate_vacation(
hass: HomeAssistantType, service: ServiceCallType hass: HomeAssistant, service: ServiceCallType
) -> None: ) -> None:
"""Service to activate vacation.""" """Service to activate vacation."""
endtime = service.data[ATTR_ENDTIME] endtime = service.data[ATTR_ENDTIME]
@ -253,7 +254,7 @@ async def _async_activate_vacation(
async def _async_deactivate_eco_mode( async def _async_deactivate_eco_mode(
hass: HomeAssistantType, service: ServiceCallType hass: HomeAssistant, service: ServiceCallType
) -> None: ) -> None:
"""Service to deactivate eco mode.""" """Service to deactivate eco mode."""
hapid = service.data.get(ATTR_ACCESSPOINT_ID) hapid = service.data.get(ATTR_ACCESSPOINT_ID)
@ -268,7 +269,7 @@ async def _async_deactivate_eco_mode(
async def _async_deactivate_vacation( async def _async_deactivate_vacation(
hass: HomeAssistantType, service: ServiceCallType hass: HomeAssistant, service: ServiceCallType
) -> None: ) -> None:
"""Service to deactivate vacation.""" """Service to deactivate vacation."""
hapid = service.data.get(ATTR_ACCESSPOINT_ID) hapid = service.data.get(ATTR_ACCESSPOINT_ID)
@ -283,7 +284,7 @@ async def _async_deactivate_vacation(
async def _set_active_climate_profile( async def _set_active_climate_profile(
hass: HomeAssistantType, service: ServiceCallType hass: HomeAssistant, service: ServiceCallType
) -> None: ) -> None:
"""Service to set the active climate profile.""" """Service to set the active climate profile."""
entity_id_list = service.data[ATTR_ENTITY_ID] entity_id_list = service.data[ATTR_ENTITY_ID]
@ -301,9 +302,7 @@ async def _set_active_climate_profile(
await group.set_active_profile(climate_profile_index) await group.set_active_profile(climate_profile_index)
async def _async_dump_hap_config( async def _async_dump_hap_config(hass: HomeAssistant, service: ServiceCallType) -> None:
hass: HomeAssistantType, service: ServiceCallType
) -> None:
"""Service to dump the configuration of a Homematic IP Access Point.""" """Service to dump the configuration of a Homematic IP Access Point."""
config_path = service.data.get(ATTR_CONFIG_OUTPUT_PATH) or hass.config.config_dir config_path = service.data.get(ATTR_CONFIG_OUTPUT_PATH) or hass.config.config_dir
config_file_prefix = service.data[ATTR_CONFIG_OUTPUT_FILE_PREFIX] config_file_prefix = service.data[ATTR_CONFIG_OUTPUT_FILE_PREFIX]
@ -325,9 +324,7 @@ async def _async_dump_hap_config(
config_file.write_text(json_state, encoding="utf8") config_file.write_text(json_state, encoding="utf8")
async def _async_reset_energy_counter( async def _async_reset_energy_counter(hass: HomeAssistant, service: ServiceCallType):
hass: HomeAssistantType, service: ServiceCallType
):
"""Service to reset the energy counter.""" """Service to reset the energy counter."""
entity_id_list = service.data[ATTR_ENTITY_ID] entity_id_list = service.data[ATTR_ENTITY_ID]
@ -343,7 +340,7 @@ async def _async_reset_energy_counter(
await device.reset_energy_counter() await device.reset_energy_counter()
def _get_home(hass: HomeAssistantType, hapid: str) -> AsyncHome | None: def _get_home(hass: HomeAssistant, hapid: str) -> AsyncHome | None:
"""Return a HmIP home.""" """Return a HmIP home."""
hap = hass.data[HMIPC_DOMAIN].get(hapid) hap = hass.data[HMIPC_DOMAIN].get(hapid)
if hap: if hap:

View file

@ -22,7 +22,7 @@ from homematicip.aio.group import AsyncExtendedLinkedSwitchingGroup, AsyncSwitch
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .generic_entity import ATTR_GROUP_MEMBER_UNREACHABLE from .generic_entity import ATTR_GROUP_MEMBER_UNREACHABLE
@ -30,7 +30,7 @@ from .hap import HomematicipHAP
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the HomematicIP switch from a config entry.""" """Set up the HomematicIP switch from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]

View file

@ -21,7 +21,7 @@ from homeassistant.components.weather import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import TEMP_CELSIUS from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity from . import DOMAIN as HMIPC_DOMAIN, HomematicipGenericEntity
from .hap import HomematicipHAP from .hap import HomematicipHAP
@ -46,7 +46,7 @@ HOME_WEATHER_CONDITION = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, config_entry: ConfigEntry, async_add_entities hass: HomeAssistant, config_entry: ConfigEntry, async_add_entities
) -> None: ) -> None:
"""Set up the HomematicIP weather sensor from a config entry.""" """Set up the HomematicIP weather sensor from a config entry."""
hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id] hap = hass.data[HMIPC_DOMAIN][config_entry.unique_id]

View file

@ -41,7 +41,7 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
) )
from homeassistant.core import CALLBACK_TYPE, ServiceCall from homeassistant.core import CALLBACK_TYPE, HomeAssistant, ServiceCall
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import ( from homeassistant.helpers import (
config_validation as cv, config_validation as cv,
@ -51,7 +51,7 @@ from homeassistant.helpers import (
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType
from .const import ( from .const import (
ADMIN_SERVICES, ADMIN_SERVICES,
@ -309,7 +309,7 @@ class HuaweiLteData:
routers: dict[str, Router] = attr.ib(init=False, factory=dict) routers: dict[str, Router] = attr.ib(init=False, factory=dict)
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool: async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
"""Set up Huawei LTE component from config entry.""" """Set up Huawei LTE component from config entry."""
url = config_entry.data[CONF_URL] url = config_entry.data[CONF_URL]
@ -458,9 +458,7 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry)
return True return True
async def async_unload_entry( async def async_unload_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
hass: HomeAssistantType, config_entry: ConfigEntry
) -> bool:
"""Unload config entry.""" """Unload config entry."""
# Forward config entry unload to platforms # Forward config entry unload to platforms
@ -474,7 +472,7 @@ async def async_unload_entry(
return True return True
async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Huawei LTE component.""" """Set up Huawei LTE component."""
# dicttoxml (used by huawei-lte-api) has uselessly verbose INFO level. # dicttoxml (used by huawei-lte-api) has uselessly verbose INFO level.
@ -556,9 +554,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
return True return True
async def async_migrate_entry( async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
hass: HomeAssistantType, config_entry: ConfigEntry
) -> bool:
"""Migrate config entry to new version.""" """Migrate config entry to new version."""
if config_entry.version == 1: if config_entry.version == 1:
options = dict(config_entry.options) options = dict(config_entry.options)

View file

@ -13,8 +13,8 @@ from homeassistant.components.binary_sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import HomeAssistantType
from . import HuaweiLteBaseEntity from . import HuaweiLteBaseEntity
from .const import ( from .const import (
@ -28,7 +28,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: Callable[[list[Entity], bool], None],
) -> None: ) -> None:

View file

@ -15,11 +15,10 @@ from homeassistant.components.device_tracker.const import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL
from homeassistant.core import callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_registry from homeassistant.helpers import entity_registry
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import HomeAssistantType
from . import HuaweiLteBaseEntity, Router from . import HuaweiLteBaseEntity, Router
from .const import ( from .const import (
@ -52,7 +51,7 @@ def _get_hosts(
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: Callable[[list[Entity], bool], None],
) -> None: ) -> None:
@ -129,7 +128,7 @@ def _is_us(host: _HostType) -> bool:
@callback @callback
def async_add_new_entities( def async_add_new_entities(
hass: HomeAssistantType, hass: HomeAssistant,
router_url: str, router_url: str,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: Callable[[list[Entity], bool], None],
tracked: set[str], tracked: set[str],

View file

@ -10,7 +10,7 @@ from huawei_lte_api.exceptions import ResponseErrorException
from homeassistant.components.notify import ATTR_TARGET, BaseNotificationService from homeassistant.components.notify import ATTR_TARGET, BaseNotificationService
from homeassistant.const import CONF_RECIPIENT, CONF_URL from homeassistant.const import CONF_RECIPIENT, CONF_URL
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from . import Router from . import Router
from .const import DOMAIN from .const import DOMAIN
@ -19,7 +19,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_get_service( async def async_get_service(
hass: HomeAssistantType, hass: HomeAssistant,
config: dict[str, Any], config: dict[str, Any],
discovery_info: dict[str, Any] | None = None, discovery_info: dict[str, Any] | None = None,
) -> HuaweiLteSmsNotificationService | None: ) -> HuaweiLteSmsNotificationService | None:

View file

@ -23,8 +23,9 @@ from homeassistant.const import (
STATE_UNKNOWN, STATE_UNKNOWN,
TIME_SECONDS, TIME_SECONDS,
) )
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import HomeAssistantType, StateType from homeassistant.helpers.typing import StateType
from . import HuaweiLteBaseEntity from . import HuaweiLteBaseEntity
from .const import ( from .const import (
@ -329,7 +330,7 @@ SENSOR_META: dict[str | tuple[str, str], SensorMeta] = {
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: Callable[[list[Entity], bool], None],
) -> None: ) -> None:

View file

@ -13,8 +13,8 @@ from homeassistant.components.switch import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_URL from homeassistant.const import CONF_URL
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.typing import HomeAssistantType
from . import HuaweiLteBaseEntity from . import HuaweiLteBaseEntity
from .const import DOMAIN, KEY_DIALUP_MOBILE_DATASWITCH from .const import DOMAIN, KEY_DIALUP_MOBILE_DATASWITCH
@ -23,7 +23,7 @@ _LOGGER = logging.getLogger(__name__)
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistantType, hass: HomeAssistant,
config_entry: ConfigEntry, config_entry: ConfigEntry,
async_add_entities: Callable[[list[Entity], bool], None], async_add_entities: Callable[[list[Entity], bool], None],
) -> None: ) -> None:

View file

@ -20,7 +20,8 @@ from homeassistant.components.homematicip_cloud.const import (
) )
from homeassistant.components.homematicip_cloud.hap import HomematicipHAP from homeassistant.components.homematicip_cloud.hap import HomematicipHAP
from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.config_entries import SOURCE_IMPORT
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.core import HomeAssistant
from homeassistant.helpers.typing import ConfigType
from .helper import AUTH_TOKEN, HAPID, HAPPIN, HomeFactory from .helper import AUTH_TOKEN, HAPID, HAPPIN, HomeFactory
@ -70,7 +71,7 @@ def hmip_config_entry_fixture() -> config_entries.ConfigEntry:
@pytest.fixture(name="default_mock_hap_factory") @pytest.fixture(name="default_mock_hap_factory")
async def default_mock_hap_factory_fixture( async def default_mock_hap_factory_fixture(
hass: HomeAssistantType, mock_connection, hmip_config_entry hass: HomeAssistant, mock_connection, hmip_config_entry
) -> HomematicipHAP: ) -> HomematicipHAP:
"""Create a mocked homematic access point.""" """Create a mocked homematic access point."""
return HomeFactory(hass, mock_connection, hmip_config_entry) return HomeFactory(hass, mock_connection, hmip_config_entry)
@ -98,7 +99,7 @@ def dummy_config_fixture() -> ConfigType:
@pytest.fixture(name="mock_hap_with_service") @pytest.fixture(name="mock_hap_with_service")
async def mock_hap_with_service_fixture( async def mock_hap_with_service_fixture(
hass: HomeAssistantType, default_mock_hap_factory, dummy_config hass: HomeAssistant, default_mock_hap_factory, dummy_config
) -> HomematicipHAP: ) -> HomematicipHAP:
"""Create a fake homematic access point with hass services.""" """Create a fake homematic access point with hass services."""
mock_hap = await default_mock_hap_factory.async_get_mock_hap() mock_hap = await default_mock_hap_factory.async_get_mock_hap()

View file

@ -19,7 +19,7 @@ from homeassistant.components.homematicip_cloud.generic_entity import (
ATTR_MODEL_TYPE, ATTR_MODEL_TYPE,
) )
from homeassistant.components.homematicip_cloud.hap import HomematicipHAP from homeassistant.components.homematicip_cloud.hap import HomematicipHAP
from homeassistant.helpers.typing import HomeAssistantType from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
from tests.common import load_fixture from tests.common import load_fixture
@ -76,7 +76,7 @@ class HomeFactory:
def __init__( def __init__(
self, self,
hass: HomeAssistantType, hass: HomeAssistant,
mock_connection, mock_connection,
hmip_config_entry: config_entries.ConfigEntry, hmip_config_entry: config_entries.ConfigEntry,
): ):