Skip to content

Commit

Permalink
Adjust async_step_reauth in apple_tv (home-assistant#74166)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Jun 29, 2022
1 parent 79fdb0d commit 75efb54
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions homeassistant/components/apple_tv/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@

import asyncio
from collections import deque
from collections.abc import Mapping
from ipaddress import ip_address
import logging
from random import randrange
from typing import Any

from pyatv import exceptions, pair, scan
from pyatv.const import DeviceModel, PairingRequirement, Protocol
from pyatv.convert import model_str, protocol_str
from pyatv.helpers import get_unique_id
import voluptuous as vol

from homeassistant import config_entries, data_entry_flow
from homeassistant import config_entries
from homeassistant.components import zeroconf
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_PIN
from homeassistant.core import callback
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.util.network import is_ipv6_address
Expand Down Expand Up @@ -118,10 +121,10 @@ def _entry_unique_id_from_identifers(self, all_identifiers: set[str]) -> str | N
return entry.unique_id
return None

async def async_step_reauth(self, user_input=None):
async def async_step_reauth(self, entry_data: Mapping[str, Any]) -> FlowResult:
"""Handle initial step when updating invalid credentials."""
self.context["title_placeholders"] = {
"name": user_input[CONF_NAME],
"name": entry_data[CONF_NAME],
"type": "Apple TV",
}
self.scan_filter = self.unique_id
Expand Down Expand Up @@ -166,7 +169,7 @@ async def async_step_user(self, user_input=None):

async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> data_entry_flow.FlowResult:
) -> FlowResult:
"""Handle device found via zeroconf."""
host = discovery_info.host
if is_ipv6_address(host):
Expand Down Expand Up @@ -250,7 +253,7 @@ def _async_check_and_update_in_progress(self, host: str, unique_id: str) -> None
):
# Add potentially new identifiers from this device to the existing flow
context["all_identifiers"].append(unique_id)
raise data_entry_flow.AbortFlow("already_in_progress")
raise AbortFlow("already_in_progress")

async def async_found_zeroconf_device(self, user_input=None):
"""Handle device found after Zeroconf discovery."""
Expand Down

0 comments on commit 75efb54

Please sign in to comment.