postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
886 stars 99 forks source link

"Pairing Not Possible" with HomePod in Home Assistant #1384

Closed gitaroomaan closed 3 years ago

gitaroomaan commented 3 years ago

Describe the bug

When attempting to setup any HomePod in Home Assistant, the following error appears:

image

Ultimately, hitting "Submit" repeats the failure message with the other protocols, before receiving a final "Aborted" dialog.

This is with the latest hass-atv-beta installed via HACS. Running Home Assistant 2021.10.0 (though it also had the same issues with earlier versions). This is in a Docker container running on my Synology NAS, though it is using the host networking.

Worth noting that setting up an Apple TV seems to work fine. I'm also not getting any of my devices automatically popping up as "Discovered," which also seems to be some kind of issue.

Home Assistant logs are attached, please let me know if there are other logs I should be looking for.

Error log

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/apple_tv/config_flow.py:111
Integration: Apple TV
First occurred: October 7, 2021, 9:04:18 AM (1413 occurrences)
Last logged: 9:37:03 AM

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 151, in async_init
    flow, result = await task
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 177, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data, init_done)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 256, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/apple_tv/config_flow.py", line 177, in async_step_zeroconf
    return await self.async_find_device_wrapper(self.async_found_zeroconf_device)
  File "/config/custom_components/apple_tv/config_flow.py", line 203, in async_find_device_wrapper
    return await next_func()
  File "/config/custom_components/apple_tv/config_flow.py", line 181, in async_found_zeroconf_device
    await self.async_set_unique_id(self.device_identifier)
  File "/config/custom_components/apple_tv/config_flow.py", line 111, in device_identifier
    if self.atv.identifier in entry.data[CONF_IDENTIFIERS]:
KeyError: 'identifiers'

How to reproduce the bug?

Add HomePod via Apple TV beta integration

What is expected behavior?

HomePod should add normally

Operating System

Linux

Python

3.9

pyatv

hass-atv-beta Release 2

Device

HomePod and HomePod mini w/ HomePodOS 15

Additional context

N/A

postlund commented 3 years ago

You need to allow anyone on the same network to use the HomePod:

https://www.macobserver.com/tips/quick-tip/airplay-homepod-settings/

Discovery is handled via zeroconf in Home Assistant, so if they aren't appearing you probably have something set up improperly. Does home assistant find any device at all on your network?

gitaroomaan commented 3 years ago

That worked like a charm - HomePod immediately added. Thank you very much @postlund!

As for discovery: Yes, Home Assistant typically finds network devices immediately. This has been one of the first instances I've found where it does not.

postlund commented 3 years ago

That sounds a bit strange, they don't even show up over time? As I just specify services of interest, I can't really affect the discovery mechanism. Did you check the community forums if anyone has any tips on debugging discovery?

gitaroomaan commented 3 years ago

I seemed to have resolved this one: While digging around other issues here, I saw reference of deleting old Apple TV instances in the .storage/core.config_entries file. I did that, rebooted and voila - the remaining HomePod/Apple TV instances appeared in discovery. Thanks for the help on this!

Edit: This also resolved the above error from appearing in my logs thousands of times.

postlund commented 3 years ago

Great! I guess we can close this now!