diff --git a/homeassistant/components/androidtv_remote/__init__.py b/homeassistant/components/androidtv_remote/__init__.py index 28a372da4ea..c8556b6da90 100644 --- a/homeassistant/components/androidtv_remote/__init__.py +++ b/homeassistant/components/androidtv_remote/__init__.py @@ -5,26 +5,18 @@ from __future__ import annotations from asyncio import timeout import logging -from androidtvremote2 import ( - AndroidTVRemote, - CannotConnect, - ConnectionClosed, - InvalidAuth, -) +from androidtvremote2 import CannotConnect, ConnectionClosed, InvalidAuth -from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_NAME, EVENT_HOMEASSISTANT_STOP, Platform from homeassistant.core import Event, HomeAssistant, callback from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady -from .helpers import create_api, get_enable_ime +from .helpers import AndroidTVRemoteConfigEntry, create_api, get_enable_ime _LOGGER = logging.getLogger(__name__) PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER, Platform.REMOTE] -AndroidTVRemoteConfigEntry = ConfigEntry[AndroidTVRemote] - async def async_setup_entry( hass: HomeAssistant, entry: AndroidTVRemoteConfigEntry @@ -82,13 +74,17 @@ async def async_setup_entry( return True -async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +async def async_unload_entry( + hass: HomeAssistant, entry: AndroidTVRemoteConfigEntry +) -> bool: """Unload a config entry.""" _LOGGER.debug("async_unload_entry: %s", entry.data) return await hass.config_entries.async_unload_platforms(entry, PLATFORMS) -async def async_update_options(hass: HomeAssistant, entry: ConfigEntry) -> None: +async def async_update_options( + hass: HomeAssistant, entry: AndroidTVRemoteConfigEntry +) -> None: """Handle options update.""" _LOGGER.debug( "async_update_options: data: %s options: %s", entry.data, entry.options diff --git a/homeassistant/components/androidtv_remote/config_flow.py b/homeassistant/components/androidtv_remote/config_flow.py index 78f24fc498c..25a26fc92df 100644 --- a/homeassistant/components/androidtv_remote/config_flow.py +++ b/homeassistant/components/androidtv_remote/config_flow.py @@ -16,7 +16,6 @@ import voluptuous as vol from homeassistant.config_entries import ( SOURCE_REAUTH, - ConfigEntry, ConfigFlow, ConfigFlowResult, OptionsFlow, @@ -33,7 +32,7 @@ from homeassistant.helpers.selector import ( from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo from .const import CONF_APP_ICON, CONF_APP_NAME, CONF_APPS, CONF_ENABLE_IME, DOMAIN -from .helpers import create_api, get_enable_ime +from .helpers import AndroidTVRemoteConfigEntry, create_api, get_enable_ime _LOGGER = logging.getLogger(__name__) @@ -220,7 +219,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): @staticmethod @callback def async_get_options_flow( - config_entry: ConfigEntry, + config_entry: AndroidTVRemoteConfigEntry, ) -> AndroidTVRemoteOptionsFlowHandler: """Create the options flow.""" return AndroidTVRemoteOptionsFlowHandler(config_entry) @@ -229,7 +228,7 @@ class AndroidTVRemoteConfigFlow(ConfigFlow, domain=DOMAIN): class AndroidTVRemoteOptionsFlowHandler(OptionsFlow): """Android TV Remote options flow.""" - def __init__(self, config_entry: ConfigEntry) -> None: + def __init__(self, config_entry: AndroidTVRemoteConfigEntry) -> None: """Initialize options flow.""" self._apps: dict[str, Any] = dict(config_entry.options.get(CONF_APPS, {})) self._conf_app_id: str | None = None diff --git a/homeassistant/components/androidtv_remote/diagnostics.py b/homeassistant/components/androidtv_remote/diagnostics.py index 41595451be8..add28b807e9 100644 --- a/homeassistant/components/androidtv_remote/diagnostics.py +++ b/homeassistant/components/androidtv_remote/diagnostics.py @@ -8,7 +8,7 @@ from homeassistant.components.diagnostics import async_redact_data from homeassistant.const import CONF_HOST, CONF_MAC from homeassistant.core import HomeAssistant -from . import AndroidTVRemoteConfigEntry +from .helpers import AndroidTVRemoteConfigEntry TO_REDACT = {CONF_HOST, CONF_MAC} diff --git a/homeassistant/components/androidtv_remote/entity.py b/homeassistant/components/androidtv_remote/entity.py index bf146a11e13..7a1e2d6bf06 100644 --- a/homeassistant/components/androidtv_remote/entity.py +++ b/homeassistant/components/androidtv_remote/entity.py @@ -6,7 +6,6 @@ from typing import Any from androidtvremote2 import AndroidTVRemote, ConnectionClosed -from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_HOST, CONF_MAC, CONF_NAME from homeassistant.core import callback from homeassistant.exceptions import HomeAssistantError @@ -14,6 +13,7 @@ from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, Device from homeassistant.helpers.entity import Entity from .const import CONF_APPS, DOMAIN +from .helpers import AndroidTVRemoteConfigEntry class AndroidTVRemoteBaseEntity(Entity): @@ -23,7 +23,9 @@ class AndroidTVRemoteBaseEntity(Entity): _attr_has_entity_name = True _attr_should_poll = False - def __init__(self, api: AndroidTVRemote, config_entry: ConfigEntry) -> None: + def __init__( + self, api: AndroidTVRemote, config_entry: AndroidTVRemoteConfigEntry + ) -> None: """Initialize the entity.""" self._api = api self._host = config_entry.data[CONF_HOST] diff --git a/homeassistant/components/androidtv_remote/helpers.py b/homeassistant/components/androidtv_remote/helpers.py index cdd67b029fc..a67d5839ee6 100644 --- a/homeassistant/components/androidtv_remote/helpers.py +++ b/homeassistant/components/androidtv_remote/helpers.py @@ -10,6 +10,8 @@ from homeassistant.helpers.storage import STORAGE_DIR from .const import CONF_ENABLE_IME, CONF_ENABLE_IME_DEFAULT_VALUE +AndroidTVRemoteConfigEntry = ConfigEntry[AndroidTVRemote] + def create_api(hass: HomeAssistant, host: str, enable_ime: bool) -> AndroidTVRemote: """Create an AndroidTVRemote instance.""" @@ -23,6 +25,6 @@ def create_api(hass: HomeAssistant, host: str, enable_ime: bool) -> AndroidTVRem ) -def get_enable_ime(entry: ConfigEntry) -> bool: +def get_enable_ime(entry: AndroidTVRemoteConfigEntry) -> bool: """Get value of enable_ime option or its default value.""" return entry.options.get(CONF_ENABLE_IME, CONF_ENABLE_IME_DEFAULT_VALUE) diff --git a/homeassistant/components/androidtv_remote/media_player.py b/homeassistant/components/androidtv_remote/media_player.py index 5bc205b32df..ac1c62e0826 100644 --- a/homeassistant/components/androidtv_remote/media_player.py +++ b/homeassistant/components/androidtv_remote/media_player.py @@ -20,9 +20,9 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback -from . import AndroidTVRemoteConfigEntry from .const import CONF_APP_ICON, CONF_APP_NAME, DOMAIN from .entity import AndroidTVRemoteBaseEntity +from .helpers import AndroidTVRemoteConfigEntry PARALLEL_UPDATES = 0 diff --git a/homeassistant/components/androidtv_remote/remote.py b/homeassistant/components/androidtv_remote/remote.py index 212b0491d2d..40220834e53 100644 --- a/homeassistant/components/androidtv_remote/remote.py +++ b/homeassistant/components/androidtv_remote/remote.py @@ -20,9 +20,9 @@ from homeassistant.components.remote import ( from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback -from . import AndroidTVRemoteConfigEntry from .const import CONF_APP_NAME from .entity import AndroidTVRemoteBaseEntity +from .helpers import AndroidTVRemoteConfigEntry PARALLEL_UPDATES = 0