import asyncio
from .const import CONF_CREDENTIALS as CONF_CREDENTIALS, CONF_IDENTIFIERS as CONF_IDENTIFIERS, CONF_START_OFF as CONF_START_OFF, DOMAIN as DOMAIN
from _typeshed import Incomplete
from homeassistant.components import zeroconf as zeroconf
from homeassistant.config_entries import ConfigEntry as ConfigEntry
from homeassistant.const import ATTR_CONNECTIONS as ATTR_CONNECTIONS, ATTR_IDENTIFIERS as ATTR_IDENTIFIERS, ATTR_MANUFACTURER as ATTR_MANUFACTURER, ATTR_MODEL as ATTR_MODEL, ATTR_NAME as ATTR_NAME, ATTR_SUGGESTED_AREA as ATTR_SUGGESTED_AREA, ATTR_SW_VERSION as ATTR_SW_VERSION, CONF_ADDRESS as CONF_ADDRESS, CONF_NAME as CONF_NAME, EVENT_HOMEASSISTANT_STOP as EVENT_HOMEASSISTANT_STOP, Platform as Platform
from homeassistant.core import Event as Event, HomeAssistant as HomeAssistant, callback as callback
from homeassistant.exceptions import ConfigEntryAuthFailed as ConfigEntryAuthFailed, ConfigEntryNotReady as ConfigEntryNotReady
from homeassistant.helpers.aiohttp_client import async_get_clientsession as async_get_clientsession
from homeassistant.helpers.device_registry import DeviceInfo as DeviceInfo
from homeassistant.helpers.dispatcher import async_dispatcher_connect as async_dispatcher_connect, async_dispatcher_send as async_dispatcher_send
from homeassistant.helpers.entity import Entity as Entity
from pyatv.conf import AppleTV
from pyatv.interface import AppleTV as AppleTVInterface, DeviceListener
from typing import Any

_LOGGER: Incomplete
DEFAULT_NAME_TV: str
DEFAULT_NAME_HP: str
BACKOFF_TIME_LOWER_LIMIT: int
BACKOFF_TIME_UPPER_LIMIT: int
SIGNAL_CONNECTED: str
SIGNAL_DISCONNECTED: str
PLATFORMS: Incomplete
AUTH_EXCEPTIONS: Incomplete
CONNECTION_TIMEOUT_EXCEPTIONS: Incomplete
DEVICE_EXCEPTIONS: Incomplete
AppleTvConfigEntry = ConfigEntry[AppleTVManager]

async def async_setup_entry(hass: HomeAssistant, entry: AppleTvConfigEntry) -> bool: ...
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ...

class AppleTVEntity(Entity):
    _attr_should_poll: bool
    _attr_has_entity_name: bool
    _attr_name: Incomplete
    atv: AppleTVInterface | None
    manager: Incomplete
    _attr_unique_id: Incomplete
    _attr_device_info: Incomplete
    def __init__(self, name: str, identifier: str, manager: AppleTVManager) -> None: ...
    async def async_added_to_hass(self) -> None: ...
    def async_device_connected(self, atv: AppleTVInterface) -> None: ...
    def async_device_disconnected(self) -> None: ...

class AppleTVManager(DeviceListener):
    atv: AppleTVInterface | None
    _connection_attempts: int
    _connection_was_lost: bool
    _task: asyncio.Task[None] | None
    config_entry: Incomplete
    hass: Incomplete
    is_on: Incomplete
    def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None: ...
    async def init(self) -> None: ...
    def connection_lost(self, exception: Exception) -> None: ...
    def connection_closed(self) -> None: ...
    def _handle_disconnect(self) -> None: ...
    async def connect(self) -> None: ...
    async def disconnect(self) -> None: ...
    def _start_connect_loop(self) -> None: ...
    async def _connect_once(self, raise_missing_credentials: bool) -> None: ...
    async def async_first_connect(self) -> None: ...
    async def connect_once(self, raise_missing_credentials: bool) -> None: ...
    async def _connect_loop(self) -> None: ...
    async def _scan(self) -> AppleTV | None: ...
    async def _connect(self, conf: AppleTV, raise_missing_credentials: bool) -> None: ...
    def _async_setup_device_registry(self) -> None: ...
    @property
    def is_connecting(self) -> bool: ...
    def _address_updated(self, address: str) -> None: ...
    def _dispatch_send(self, signal: str, *args: Any) -> None: ...
