Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Home Assistant integration does not work with tvOS 15 #1333

Closed
WanKa-zone opened this issue Sep 24, 2021 · 91 comments
Closed

Home Assistant integration does not work with tvOS 15 #1333

WanKa-zone opened this issue Sep 24, 2021 · 91 comments
Labels
3rd party Used for issues dealing applications using pyatv bug

Comments

@WanKa-zone
Copy link

Describe the bug

An aborted noted popped up every time when I try to add my Apple TV into hass.
image

Error log

<place log here>

How to reproduce the bug?

After typed in the PIN code displayed on Apple TV.

What is expected behavior?

Successfully add Apple TV Integration.

Operating System

core-2021.9.7

Python

Other

pyatv

not sure

Device

Apple TV 4K tvOS 15.0(19J346)

Additional context

Using tvOS 15.0(19J346) on my Apple TV 4K.

@WanKa-zone WanKa-zone added the bug label Sep 24, 2021
@Smiggel
Copy link

Smiggel commented Sep 24, 2021

Same here. After entering the first pin (out of two - as it was before?) it stops working.

@postlund
Copy link
Owner

It is because of tvOS 15, there are a couple of issues about it. You either have to sit tight and wait until I have updated the integration or run the beta version until I'm done.

https://github.com/postlund/hass-atv-beta

(It's available in HACS)

@postlund postlund changed the title CANNOT ADD APPLE TV Home Assistant integration does not work with tvOS 15 Sep 24, 2021
@postlund postlund added the 3rd party Used for issues dealing applications using pyatv label Sep 24, 2021
@postlund postlund pinned this issue Sep 24, 2021
@Smiggel
Copy link

Smiggel commented Sep 25, 2021

It is because of tvOS 15, there are a couple of issues about it. You either have to sit tight and wait until I have updated the integration or run the beta version until I'm done.

https://github.com/postlund/hass-atv-beta

(It's available in HACS)

Where do I have to look for? I can't seem to find the beta in HACS.

@DuncanRae
Copy link

DuncanRae commented Sep 25, 2021

Hi,

I’ve installed the beta component and it sees all my Apple TV’s, and can integrate them with the pairing codes, although I do get the same error above, but HA still can’t see their state. I have all my light automations set up to dim based on their playing, paused etc. state. Feels like I’m back in the 80s having to manually dim the lights.

Apple TV state in HA just says Off. I did remove he, from HA before installing the beta component, and they have been detected but the integration isn’t working yet.

Thanks so much for your hard work on this. Really appreciate it and I really miss this function not working.

@postlund
Copy link
Owner

@Smiggel it should be called "Apple TV beta component" or something like that. If it doesn't show up, try adding the address manually. That should work.

@DuncanRae Can you check the log? Might be that the connection fails for some reason.

@Smiggel
Copy link

Smiggel commented Sep 25, 2021

Installed the new beta and it works good for what I can see. HA sees my Apple TV. I was able to pair it and as soon as I play something on Netflix, I see it in HA! Nice.

Can't say if it stable yet. Have to test it more. But looks really promising! Thanks!

@postlund
Copy link
Owner

@Smiggel Sounds great! 👍 I'm very interested in stability related testing, so please report back on that!

@Smiggel
Copy link

Smiggel commented Sep 25, 2021

@postlund Will do. Will test it this week.

@DuncanRae
Copy link

DuncanRae commented Sep 25, 2021

@Smiggel it should be called "Apple TV beta component" or something like that. If it doesn't show up, try adding the address manually. That should work.

@DuncanRae Can you check the log? Might be that the connection fails for some reason.

Hi,

The only thing I can find of interest in the log is this which is happening over and over again. I do see it mentioned in another thread too:

2021-09-25 20:53:14 DEBUG (MainThread) [custom_components.apple_tv] Discovering device DEFB5818-ABD3-4C56-A2FB-21A5248ACC44
2021-09-25 20:53:14 DEBUG (MainThread) [pyatv.support.knock] Knocking at ports [3689, 7000, 49152, 32498] on 192.168.0.64
2021-09-25 20:53:14 DEBUG (MainThread) [pyatv.core.scan] Auto-discovered Lounge Apple TV at 192.168.0.64:7000 via Protocol.AirPlay ({'acl': '0', 'btaddr': 'D0:D2:B0:9C:A4:5A', 'deviceid': 'D0:D2:B0:9C:A4:5B', 'fex': '1d9/St5/FbwI', 'features': '0x4A7FDFD5,0xBC157FDE', 'flags': '0x644', 'gid': '0789667B-D142-4802-9308-F055822F7444', 'igl': '1', 'gcgl': '1', 'model': 'AppleTV6,2', 'protovers': '1.1', 'pi': '16e57f49-27ed-4be3-a311-8cf2468ac8c4', 'psi': 'DD9F8738-B45B-475B-8901-34CD70478ADD', 'pk': '1d1aa49693908f1fcb1db0a14e0703296ba9ee180745e7c5d1210fbf6cf7b0a7', 'srcvers': '566.25.43', 'osvers': '15.0', 'vv': '2'})
2021-09-25 20:53:14 DEBUG (MainThread) [pyatv.core.scan] Auto-discovered D0D2B09CA45B@Lounge Apple TV at 192.168.0.64:7000 via Protocol.RAOP ({'cn': '0,1,2,3', 'da': 'true', 'et': '0,3,5', 'ft': '0x4A7FDFD5,0xBC157FDE', 'sf': '0x644', 'md': '0,1,2', 'am': 'AppleTV6,2', 'pk': '1d1aa49693908f1fcb1db0a14e0703296ba9ee180745e7c5d1210fbf6cf7b0a7', 'tp': 'UDP', 'vn': '65537', 'vs': '566.25.43', 'ov': '15.0', 'vv': '2'})
2021-09-25 20:53:14 DEBUG (MainThread) [custom_components.apple_tv] Failed to find device DEFB5818-ABD3-4C56-A2FB-21A5248ACC44 with address 192.168.0.64, trying to scan
2021-09-25 20:53:14 DEBUG (MainThread) [pyatv.support.net] Binding on *:5353
2021-09-25 20:53:14 DEBUG (MainThread) [pyatv.support.net] Binding on 127.0.0.1:0
2021-09-25 20:53:14 DEBUG (MainThread) [pyatv.support.net] Binding on 192.168.0.5:0
2021-09-25 20:53:14 DEBUG (MainThread) [pyatv.support.net] Binding on 172.30.32.1:0
2021-09-25 20:53:14 DEBUG (MainThread) [pyatv.support.net] Binding on 172.17.0.1:0

I did completely remove the devices from HA before re-adding with the new beta component. I also cleaned out all the old pyatv references on the Apple TV itself.

@postlund
Copy link
Owner

@DuncanRae It's the same situation as in #1335. It has taken some time for me to grasp the situation, but I know exactly why this happens. Will try to work out a fix as soon as I can.

@DuncanRae
Copy link

@DuncanRae It's the same situation as in #1335. It has taken some time for me to grasp the situation, but I know exactly why this happens. Will try to work out a fix as soon as I can.

Awesome. Really appreciate the work!

@DAaviide
Copy link

i cant find the beta in hacs

@WanKa-zone
Copy link
Author

WanKa-zone commented Sep 25, 2021

It is because of tvOS 15, there are a couple of issues about it. You either have to sit tight and wait until I have updated the integration or run the beta version until I'm done.

https://github.com/postlund/hass-atv-beta

(It's available in HACS)

Cheers. Really appreciate.

Couldn't find the "Apple TV beta component" or "pyatv" on HACS.
How do I install manually?

@Smiggel
Copy link

Smiggel commented Sep 26, 2021

So far so good. Ran multiple test today with Netflix and Disney+ and it’s running fine. No problems so far.

@DAaviide
Copy link

It is because of tvOS 15, there are a couple of issues about it. You either have to sit tight and wait until I have updated the integration or run the beta version until I'm done.
https://github.com/postlund/hass-atv-beta
(It's available in HACS)

Cheers. Really appreciate.

Couldn't find the "Apple TV beta component" or "pyatv" on HACS.
How do I install manually?

same here😅
how can i do it

@postlund
Copy link
Owner

Manually adding a repo can be done like this:

https://hacs.xyz/docs/faq/custom_repositories

Just use https://github.com/postlund/hass-atv-beta as address.

@WanKa-zone
Copy link
Author

Manually adding a repo can be done like this:

https://hacs.xyz/docs/faq/custom_repositories

Just use https://github.com/postlund/hass-atv-beta as address.

Got it. Cheers

@mpeterson
Copy link

@postlund even with the config version bump that you pushed around 1 hour ago I'm still facing issues. I made sure to delete all references from ./storage/core.config_entries too.

My logs show:

Authentication problem

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pyatv/support/__init__.py", line 33, in error_handler
    return await func(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/companion/auth.py", line 54, in start_pairing
    resp = await self.protocol.exchange_opack(
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/companion/protocol.py", line 80, in exchange_opack
    unpacked_object, _ = opack.unpack(payload)
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/companion/opack.py", line 108, in unpack
    return _unpack(data, [])
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/companion/opack.py", line 115, in _unpack
    if data[0] == 0x01:
IndexError: index out of range

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/apple_tv/config_flow.py", line 285, in async_pair_next_protocol
    await self.pairing.begin()
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/companion/pairing.py", line 53, in begin
    await error_handler(
  File "/usr/local/lib/python3.9/site-packages/pyatv/support/__init__.py", line 41, in error_handler
    raise fallback(str(ex)) from ex
pyatv.exceptions.PairingError: index out of range

This happens after the second input of an AirPlay pin.

When I go to "Remote App and Devices" I have under devices "Unknown Device" entries as many times I tried to pair HASS to the AppleTV

@postlund
Copy link
Owner

@mpeterson That looks like a bug or something I have not implemented in OPACK to me, cool! It would be great if you either enable debug logs for pyatv (https://github.com/postlund/hass-atv-beta#debug-logs) or try to reproduce with atvremote like this:

atvremote --debug -s <ip to the device> --protocol companion pair

@filikun
Copy link

filikun commented Sep 28, 2021

It seems I have the same problem (with authentication) as above and got a log. @postlund I sent you a PM on discord!

@robyevolution
Copy link

with the second beta version the player is always off, I tried to remove and reinstall the integration but it doesn't solve it

@postlund
Copy link
Owner

with the second beta version the player is always off, I tried to remove and reinstall the integration but it doesn't solve it

What does the log say?

@robyevolution
Copy link

robyevolution commented Sep 28, 2021

2021-09-28 18:02:31 WARNING (MainThread) [pyatv.protocols.airplay] Failed to set up remote control channel: not authenticated
2021-09-28 18:02:31 ERROR (MainThread) [custom_components.apple_tv] Failed to connect
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/apple_tv/__init__.py", line 261, in _connect_loop
    await self._connect(conf)
  File "/home/homeassistant/.homeassistant/custom_components/apple_tv/__init__.py", line 337, in _connect
    self.atv = await connect(conf, self.hass.loop, session=session)
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/__init__.py", line 96, in connect
    await atv.connect()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/core/facade.py", line 425, in connect
    if await setup_data.connect():
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/protocols/mrp/__init__.py", line 879, in _connect
    await protocol.start()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/protocols/mrp/protocol.py", line 119, in start
    await self.connection.connect()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/protocols/mrp/connection.py", line 100, in connect
    await self.loop.create_connection(lambda: self, self.host, self.port)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
    sock = await self._connect_sock(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect
    return await fut
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.1.110', 0)
2021-09-28 18:02:34 WARNING (MainThread) [pyatv.protocols.airplay] Failed to set up remote control channel: not authenticated
2021-09-28 18:02:34 ERROR (MainThread) [custom_components.apple_tv] Failed to connect
Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/apple_tv/__init__.py", line 261, in _connect_loop
    await self._connect(conf)
  File "/home/homeassistant/.homeassistant/custom_components/apple_tv/__init__.py", line 337, in _connect
    self.atv = await connect(conf, self.hass.loop, session=session)
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/__init__.py", line 96, in connect
    await atv.connect()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/core/facade.py", line 425, in connect
    if await setup_data.connect():
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/protocols/mrp/__init__.py", line 879, in _connect
    await protocol.start()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/protocols/mrp/protocol.py", line 119, in start
    await self.connection.connect()
  File "/srv/homeassistant/lib/python3.8/site-packages/pyatv/protocols/mrp/connection.py", line 100, in connect
    await self.loop.create_connection(lambda: self, self.host, self.port)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
    sock = await self._connect_sock(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect
    return await fut
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.1.110', 0)

@postlund
Copy link
Owner

@robyevolution Did AirPlay succeed to pair when you added the device?

@robyevolution
Copy link

it is added correctly but the entity is always off, tried to restart home assistant and apple tv but the problem persists

@postlund
Copy link
Owner

This line:

2021-09-28 18:02:31 WARNING (MainThread) [pyatv.protocols.airplay] Failed to set up remote control channel: not authenticated

Means that the MRP-over-AirPlay channel failed to set up, so there's basically nothing that provides metadata and that's why the device appears to be off. We need to figure out why that is happening. What device is this? Can you install pyatv so we can run atvremote? Or run it via docker?

@Rrapa
Copy link

Rrapa commented Oct 21, 2021

@Rrapa Which version of the integration are you running? Assuming it's not another OPACK type I'm missing, it should have been fixed in release 1.3 I think.

1.6 . .recently updated

@Rrapa
Copy link

Rrapa commented Oct 21, 2021

No issues on ATV 3 or Homepod mini

@Rrapa
Copy link

Rrapa commented Oct 21, 2021

Well .. I must say .. was struggling a bit with ATV3 mutliple restarts etc. .but finally pairing was successful

@postlund
Copy link
Owner

Then it's probably a new type I haven't implemented yet. I need some logs to troubleshoot. If you add this to you config:

logger:
  logs:
    pyatv: debug

Then restart. Once you see the error above, look above for a line looking:

2021-10-21 19:30:52 DEBUG [pyatv.protocols.companion.connection]: Received data (Data=<hex string>)

I need that line.

@postlund
Copy link
Owner

Do you have any logs from problems with the ATV3? I was hoping that was pretty stable.

@Rrapa
Copy link

Rrapa commented Oct 21, 2021

I'm afraid no .. but I can delete ATV 3 and retry . ... maybe it was temp issue - once was OK and later with bit of issues ..

@Rrapa
Copy link

Rrapa commented Oct 21, 2021

2021-10-21 22:30:19 DEBUG (MainThread) [pyatv.protocols.companion.connection] Connected to companion device 192.168.2.83:49152
2021-10-21 22:30:19 DEBUG (MainThread) [pyatv.protocols.companion.connection] >> Send data (Data=e2435f706476000100060101455f7077547909, FrameType=03)
2021-10-21 22:30:19 DEBUG (MainThread) [pyatv.protocols.companion.connection] Received data (Data=01000000)
2021-10-21 22:30:19 DEBUG (MainThread) [pyatv.protocols.companion.connection] Recv data (Data=01000000)
2021-10-21 22:30:19 DEBUG (MainThread) [pyatv.protocols.companion.connection] Closing connection
2021-10-21 22:30:19 DEBUG (MainThread) [pyatv.protocols.companion.connection] Connection lost to remote device: None

@Rrapa
Copy link

Rrapa commented Oct 21, 2021

U'll never guess ...wasn't working for few days ... worked now .. log below

2021-10-21 22:32:36 DEBUG (MainThread) [pyatv.protocols.companion.connection] Connected to companion device 192.168.2.83:49152
2021-10-21 22:32:36 DEBUG (MainThread) [pyatv.protocols.companion.connection] >> Send data (Data=e2435f706476000100060101455f7077547909, FrameType=03)
2021-10-21 22:32:36 DEBUG (MainThread) [pyatv.protocols.companion.connection] Received data (Data=01000000)
2021-10-21 22:32:36 DEBUG (MainThread) [pyatv.protocols.companion.connection] Received data (Data=040001a4e1435f7064929c01060102021089c0ceca42e8725bfec595e7cc91fc9103ff7b11e1c9334a29fd006c19485bf0f2ec7f473d098327e4b3a243a3c65639021b95d508796139a46a5ae13c3aa1fe581f8f2e6fa1fb62d59d41199cbabb128dbc401fe0709edc9de09129074163f5bf42cfd9329618b146a1fc9d632755716c10bf129307a682f095023964b0a451507d40c6bbd4d50b3823f055c04a5999a6b3605564e4eacf2d7aa7ea063b50489bb9387179f6e623479d453f10620ca314acf54e0d501a4b97d8d5ff9b2a2783213dd27f5003460bd863a43806eb20f5c7a4bd9fa1808382d92431c8e177c3f4fcdc75e469b3c0764491ac1a677...)
2021-10-21 22:32:36 DEBUG (MainThread) [pyatv.protocols.companion.connection] Recv data (Data=040001a4e1435f7064929c01060102021089c0ceca42e8725bfec595e7cc91fc9103ff7b11e1c9334a29fd006c19485bf0f2ec7f473d098327e4b3a243a3c65639021b95d508796139a46a5ae13c3aa1fe581f8f2e6fa1fb62d59d41199cbabb128dbc401fe0709edc9de09129074163f5bf42cfd9329618b146a1fc9d632755716c10bf129307a682f095023964b0a451507d40c6bbd4d50b3823f055c04a5999a6b3605564e4eacf2d7aa7ea063b50489bb9387179f6e623479d453f10620ca314acf54e0d501a4b97d8d5ff9b2a2783213dd27f5003460bd863a43806eb20f5c7a4bd9fa1808382d92431c8e177c3f4fcdc75e469b3c0764491ac1a677...)
2021-10-21 22:32:54 DEBUG (MainThread) [pyatv.protocols.companion.connection] >> Send data (Data=e2435f706492c90106010303ff37612af956759fcd526ad681605171b3fb1fcfcbbecf94bf30ab25bca967cbcdccea5fa5a4cd241c1899287024ccc8ec2d809a7dbd1863a0732c4cb0d0e1dc3ca968f38b756f9b62738db61a471b5aeb9450c73b082241fd5f07c673be9ff8ef7ea99392b602a3881b40e9a7e51fe7ce18e6d59221190847e9950784fb7f89b16347809ed9bfaed03f607f550b718df76d39b77e0f951b4aa8e16f402051f5698cf5186bd1cf43571be92ea8c9b7658804c44306f12aece5595d9944b8d247cf938e0970abac1cba9975941835b75d19c562ea4f6b491a8a2dbe0eb1ba645b1768d250cc7a688a8c55cc2118210ecc74643..., FrameType=04)
2021-10-21 22:32:54 DEBUG (MainThread) [pyatv.protocols.companion.connection] Received data (Data=0400004ce1435f7064914506010404405311be721af32929f63872a3829240d5ea5612df87113c39c2a94f26240a456021980de6a35ce692b513b0656fbf576491d61682e9220eb6d4c202d3df941b88)
2021-10-21 22:32:54 DEBUG (MainThread) [pyatv.protocols.companion.connection] Recv data (Data=0400004ce1435f7064914506010404405311be721af32929f63872a3829240d5ea5612df87113c39c2a94f26240a456021980de6a35ce692b513b0656fbf576491d61682e9220eb6d4c202d3df941b88)
2021-10-21 22:32:54 DEBUG (MainThread) [pyatv.protocols.companion.connection] >> Send data (Data=e2435f706492280106010505ff47ee802a7e8cc3586b4ba7547715c65f2f65c20edebd5363112f805b7f879f4b67fe8e52292cf64353ec2ce199fc63ff33c529c3ab8485d8d5e3384dba97b754c0c695c6c99505338081d0a38bb58f7a1755ba2d9563ed83072b01706080a79c081ab9340df26c4132284795b9a29aa09e5df67de25b6ef9cd4d3dd8f98a0f6319959c30c5b026f685169256b3d41cae937fb0e22f1ff594c801c7afdf4936811564ce5b477fe00ec8c255e4d376e74198eb12196e5167a064dd4e6abf2a332d7ef864df94c80ca7c107cfc2e9deccc2edcd9e02a0fc6d45b46072b557821e2be190544ac892202ff769f47e6f57c50c393..., FrameType=04)
2021-10-21 22:32:54 DEBUG (MainThread) [pyatv.protocols.companion.connection] Received data (Data=04000134e1435f7064922c0105ff5c5400b9d982a2f7b6abf0e2db2b44cd9d43fa1e69496c1cf01c682d4dc34b12cdaee7e7c5f7e20b4814b30d1336a751961ed24747f1ee71f679a3383b1de8dd950800e1749a23b03b8269ae0d6571194882376e56bcdf54b9c2d10a41e4b46d212c0252f86b3113f873e34eb5ef5c6984f0eb049fc6f697c242b3e52851bc59ed72f4839ac040af0954cbf959b80a5fbb41a1324959c25aefada1d8839cb7b8ece38f440c08b2eaaac384b65cae607e490c9fc2b0a99dacbbc149ff26752f53c97767ee75b4ddc38225ae81e94c938566a8c76c75807d54e4a8f9453d98aadae0a1230909487f04a6bcf1f4f9b67ce02...)
2021-10-21 22:32:54 DEBUG (MainThread) [pyatv.protocols.companion.connection] Recv data (Data=04000134e1435f7064922c0105ff5c5400b9d982a2f7b6abf0e2db2b44cd9d43fa1e69496c1cf01c682d4dc34b12cdaee7e7c5f7e20b4814b30d1336a751961ed24747f1ee71f679a3383b1de8dd950800e1749a23b03b8269ae0d6571194882376e56bcdf54b9c2d10a41e4b46d212c0252f86b3113f873e34eb5ef5c6984f0eb049fc6f697c242b3e52851bc59ed72f4839ac040af0954cbf959b80a5fbb41a1324959c25aefada1d8839cb7b8ece38f440c08b2eaaac384b65cae607e490c9fc2b0a99dacbbc149ff26752f53c97767ee75b4ddc38225ae81e94c938566a8c76c75807d54e4a8f9453d98aadae0a1230909487f04a6bcf1f4f9b67ce02...)
2021-10-21 22:32:54 DEBUG (MainThread) [pyatv.protocols.companion.connection] Closing connection
2021-10-21 22:32:54 DEBUG (MainThread) [pyatv.protocols.companion.connection] Connection lost to remote device: None

@Rrapa
Copy link

Rrapa commented Oct 21, 2021

Now .. let me know if u need anything .. I have as well streaming from link / web running via mediaplayer so if u want to test any functionality - let me know

@ruant
Copy link

ruant commented Oct 23, 2021

I'm struggling with the same Authentication problem.
Have anyone looked into how this can be fixed when on different VLAN's?
Putting them on the same VLAN is not an option for me.

Does the Apple TV "talk" back on different TCP/UDP connections to the HA? Or is HA always "polling" for data?
If so it would just be some FW rules for me (i'll try opening up this and report back).

@postlund
Copy link
Owner

I am 99% certain that the Apple TV checks if the IP address belongs to one of the networks that it is on and reject connections from other networks. Just like MDNS requests shall be dropped (according to spec) if they originate from another network. All of these protocols are designed for use on the local network. If someone figures anything out that works, please let me know. I will not put any more effort into supporting devices on different subnets, it's too much work for me to handle with very few users.

@RaZer0r
Copy link

RaZer0r commented Oct 23, 2021

Well my fix is a bit more advanced: Create an outbound NAT rule that translates to the router IP address on that van ;)

Example:
Hassio: 10.0.80.10
router Vlan 80 ip: 10.0.80.1
router AppleTV Vlan: 10.0.81.1
Apple TV : 10.0.81.10

NAT rule: on outbound on AppleTV Vlan interface -- from 10.0.80.10 to 10.0.81.10 NAT with ip 10.0.81.1

That seems to work and I would not see any problems doing this

@ruant
Copy link

ruant commented Oct 23, 2021

@RaZer0r Good idea using NAT! Didn't think of that 👍 I'll give that a go.

@postlund Didn't know MDNS spec stated that, my Google Home speakers doesn't care one bit.

@postlund
Copy link
Owner

@ruant It's not marked as MUST in the specification, but SHOULD. It's all in here:

https://datatracker.ietf.org/doc/html/rfc6762#section-5.5

It is all very reasonable and in my opinion it would have been better to just force that as part of the specification to begin with. Anyhow, re-mapping IP address with NAT certainly works as the makes the source IP correct. It's not for the faint of heart though.

On another note... I decided that it's time to start integrating with Home Assistant since that will probably take a while, so a PR is now open here: https://datatracker.ietf.org/doc/html/rfc6762#section-5.5

@postlund
Copy link
Owner

If you are using TTS with the beta integration, please see:

#1435

@emigrating
Copy link

@postlund since you started requiring HAss 2021.11. 0 it's no longer possible to install ANY version using HACS which is a bit of an issue as I updated to 1.7.0 which didn't work out, so when I went to roll back to 1.6.0 it won't let me.

@Qonstrukt
Copy link

Qonstrukt commented Nov 4, 2021

I've been testing out the new version of the HA component and most of it works fine, but I'm having issues with the new power management features. In theory it's nice to have it mapped to HDMI CEC, but unfortunately for my cases it's kind of counterproductive:
I have a setup of a TV connected to an Onkyo receiver to which the ATV 4K is also connected. I use my ATV to play music, but I don't want my TV to turn on.
So what I did was disable "CEC Auto Power On" in my TV settings. But now I have the issue that my Onkyo receiver also no longer turns on when my ATV starts playing music. No problem though, I made an automation in HA to turn on the Onkyo as soon as the ATV starts playing something.
Unfortunately this no longer works, because the ATV is in standby state in HA and won't switch out of it until the Onkyo receiver is turned on. But that's exactly the thing that I'm trying to do here. 😅 All the media info is still changing on the ATV device in HA, but the state just never leaves standby anymore.
Pressing the power button on the ATV in HA also doesn't turn on the Onkyo. Probably because it's honoring the request from the TV to ignore that. Even though it does let me turn it off using the ATV power button, haha.
Hope it's not too confusing!

[Edit]
Don't get me wrong btw, in some way it behaves like one would expect. But maybe something like a media_state parameter could be added that represents the playing state of the media, even if the device is 'CEC standby'. Or maybe an option to disable the CEC functionality at the device level. Because this is all very specific to the ATV in my office, whereas I like the CEC power sync feature for the other ATV's in the house. 😄

@bverkron
Copy link

bverkron commented Nov 28, 2021

When I go to "Remote App and Devices" I have under devices "Unknown Device" entries as many times I tried to pair HASS to the AppleTV

@mpeterson did you find a solution for this? I have the same problem on v1.9.1

@postlund I was able to collect some logs using your suggested atvremote command in the docker container. I didn't have any success getting debug log output in HA. Despite turning on debug logging and rebooting there was zero output related to pyatv in the logs even after running through the pairing process.

/ # atvremote --debug -s 192.168.1.61 --protocol companion pair
2021-11-28 05:14:08 DEBUG [pyatv.scripts]: Running with pyatv 0.9.6
2021-11-28 05:14:08 DEBUG [pyatv.support.knock]: Knocking at ports [3689, 7000, 49152, 32498] on 192.168.1.61
2021-11-28 05:14:08 DEBUG [pyatv.core.scan]: Auto-discovered Basement at 192.168.1.61:49152 via Protocol.Companion ({'rpmac': '1', 'rphn': 'e691be0bc867', 'rpfl': '0xB6782', 'rpmd': 'AppleTV6,2', 'rpvr': '310.7', 'rpmrtid': '87C32499-F313-466B-A87E-EC45615A9FB6', 'rpad': 'cae68d02b7e4', 'rpba': 'A7:BD:1A:C1:E6:49'})
2021-11-28 05:14:08 DEBUG [pyatv.core.scan]: Auto-discovered Basement at 192.168.1.61:7000 via Protocol.AirPlay ({'acl': '0', 'btaddr': 'CC:D2:81:68:55:6E', 'deviceid': 'CC:D2:81:74:BE:35', 'fex': '1d9/St5/FbwI', 'features': '0x4A7FDFD5,0xBC157FDE', 'flags': '0x18244', 'gid': 'A0006FC5-F2F2-4843-A30E-8A2591FE43BF', 'igl': '1', 'gcgl': '1', 'model': 'AppleTV6,2', 'protovers': '1.1', 'pi': '2c673b66-250f-4e15-9b38-6fea29f25357', 'psi': '87C32499-F313-466B-A87E-EC45615A9FB6', 'pk': '5d13269cb8212e060c6af4fdd1d4abbfccb86c06f5b012afab977adc53401fee', 'srcvers': '595.15.41', 'osvers': '15.1.1', 'vv': '2'})
2021-11-28 05:14:08 DEBUG [pyatv.core.scan]: Auto-discovered CCD28174BE35@Basement at 192.168.1.61:7000 via Protocol.RAOP ({'cn': '0,1,2,3', 'da': 'true', 'et': '0,3,5', 'ft': '0x4A7FDFD5,0xBC157FDE', 'sf': '0x18244', 'md': '0,1,2', 'am': 'AppleTV6,2', 'pk': '5d13269cb8212e060c6af4fdd1d4abbfccb86c06f5b012afab977adc53401fee', 'tp': 'UDP', 'vn': '65537', 'vs': '595.15.41', 'ov': '15.1.1', 'vv': '2'})
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.pairing]: Start pairing Companion
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.connection]: Connected to companion device 192.168.1.61:49152
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.protocol]: Companion credentials: None
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.protocol]: Exchange OPACK: {'_pd': b'\x00\x01\x00\x06\x01\x01', '_pwTy': 1}
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.protocol]: Send OPACK: {'_pd': b'\x00\x01\x00\x06\x01\x01', '_pwTy': 1, '_x': 65319}
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.connection]: >> Send data (Data=e3435f706476000100060101455f7077547909425f783127ff, FrameType=03)
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.connection]: Received data (Data=040001a4e1435f7064929c010601020210f901b4fb6db47425668a1ea72ee5b3c303ff5fcd2b970a463f98c22304fe1e4fedd2ebfcb791668184992b347ce64f776fa4bed4513738360b4dfb24eb20abc6944cd1bb155e718b767f55fd5a0972bbfa8af5ccde72aa554d377fc0f61a22d999fd42e6420abb655996a7803a1a011458521368cf5b36ce36a2827856503b895190359c04c197607a7cedf2f8802c51aaf89e2c5b5243b1f17bf30791e39fb5e98eba9f57cabb844aed44edd585719d4ebe6ffff123046074fcfc6d61a39223e016a5d0868726fe07fb62169274f10b56fd35893752506f1cd9e24dcb7915f3421e814f9684a21442189e4d4a1...)
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.protocol]: Received frame FrameType.PS_Next: b'\xe1C_pd\x92\x9c\x01\x06\x01\x02\x02\x10\xf9\x01\xb4\xfbm\xb4t%f\x8a\x1e\xa7.\xe5\xb3\xc3\x03\xff_\xcd+\x97\nF?\x98\xc2#\x04\xfe\x1eO\xed\xd2\xeb\xfc\xb7\x91f\x81\x84\x99+4|\xe6Owo\xa4\xbe\xd4Q786\x0bM\xfb$\xeb \xab\xc6\x94L\xd1\xbb\x15^q\x8bv\x7fU\xfdZ\tr\xbb\xfa\x8a\xf5\xcc\xder\xaaUM7\x7f\xc0\xf6\x1a"\xd9\x99\xfdB\xe6B\n\xbbeY\x96\xa7\x80:\x1a\x01\x14XR\x13h\xcf[6\xce6\xa2\x82xVP;\x89Q\x905\x9c\x04\xc1\x97`z|\xed\xf2\xf8\x80,Q\xaa\xf8\x9e,[RC\xb1\xf1{\xf3\x07\x91\xe3\x9f\xb5\xe9\x8e\xba\x9fW\xca\xbb\x84J\xedD\xed\xd5\x85q\x9dN\xbeo\xff\xf1#\x04`t\xfc\xfcma\xa3\x92#\xe0\x16\xa5\xd0\x86\x87&\xfe\x07\xfbb\x16\x92t\xf1\x0bV\xfd5\x897RPo\x1c\xd9\xe2M\xcby\x15\xf3B\x1e\x81O\x96\x84\xa2\x14B\x18\x9eMJ\x1f\xf7)N\n\x08\x07_Za\xd0\xce\x9f#\xfc~\xba\x9c[\xf0\xee\xd6\xe4\xc1\xd8\x08\x88\x88\x93\xf6\x8a\xae\x9c\xd9\x17\xf1\x03\x81\xdfF\xc1\xc7\xf24\xeb\xc2z\xbc\tq\xd4\xc7\x7f\xb1b\xae\x87BOv\x15\x98{^m\xe3\xdc{EgL\x07\xb4j>\xf6d\xb2\xbb@\xcb\xffs\xa6\x00)(1N\xd8L\x86m\x95]+\xa5\x16\xa1\xf2m\x1d\xcf=S\xc4\n\xdb\x1e\xd1\x13\xa2o\x1c\xb1]\xce%\xe0\x82m\xf6%:\xcd\xcag\x00\xb8G\xc0\xc1\xbd\xd0\x17\x1c\x00\x97I^c\xf1\x04\xaexPyb\xf9\xa9\xe1\xfe\xf7\xf0\xe9\x98\xae\xe9\xf3a\xbc\x05W\t\xff{\x1d\x1b\x01\x01'
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.protocol]: Process incoming auth frame (FrameType.PS_Next): {'_pd': b'\x06\x01\x02\x02\x10\xf9\x01\xb4\xfbm\xb4t%f\x8a\x1e\xa7.\xe5\xb3\xc3\x03\xff_\xcd+\x97\nF?\x98\xc2#\x04\xfe\x1eO\xed\xd2\xeb\xfc\xb7\x91f\x81\x84\x99+4|\xe6Owo\xa4\xbe\xd4Q786\x0bM\xfb$\xeb \xab\xc6\x94L\xd1\xbb\x15^q\x8bv\x7fU\xfdZ\tr\xbb\xfa\x8a\xf5\xcc\xder\xaaUM7\x7f\xc0\xf6\x1a"\xd9\x99\xfdB\xe6B\n\xbbeY\x96\xa7\x80:\x1a\x01\x14XR\x13h\xcf[6\xce6\xa2\x82xVP;\x89Q\x905\x9c\x04\xc1\x97`z|\xed\xf2\xf8\x80,Q\xaa\xf8\x9e,[RC\xb1\xf1{\xf3\x07\x91\xe3\x9f\xb5\xe9\x8e\xba\x9fW\xca\xbb\x84J\xedD\xed\xd5\x85q\x9dN\xbeo\xff\xf1#\x04`t\xfc\xfcma\xa3\x92#\xe0\x16\xa5\xd0\x86\x87&\xfe\x07\xfbb\x16\x92t\xf1\x0bV\xfd5\x897RPo\x1c\xd9\xe2M\xcby\x15\xf3B\x1e\x81O\x96\x84\xa2\x14B\x18\x9eMJ\x1f\xf7)N\n\x08\x07_Za\xd0\xce\x9f#\xfc~\xba\x9c[\xf0\xee\xd6\xe4\xc1\xd8\x08\x88\x88\x93\xf6\x8a\xae\x9c\xd9\x17\xf1\x03\x81\xdfF\xc1\xc7\xf24\xeb\xc2z\xbc\tq\xd4\xc7\x7f\xb1b\xae\x87BOv\x15\x98{^m\xe3\xdc{EgL\x07\xb4j>\xf6d\xb2\xbb@\xcb\xffs\xa6\x00)(1N\xd8L\x86m\x95]+\xa5\x16\xa1\xf2m\x1d\xcf=S\xc4\n\xdb\x1e\xd1\x13\xa2o\x1c\xb1]\xce%\xe0\x82m\xf6%:\xcd\xcag\x00\xb8G\xc0\xc1\xbd\xd0\x17\x1c\x00\x97I^c\xf1\x04\xaexPyb\xf9\xa9\xe1\xfe\xf7\xf0\xe9\x98\xae\xe9\xf3a\xbc\x05W\t\xff{\x1d\x1b\x01\x01'}
2021-11-28 05:14:08 DEBUG [pyatv.protocols.companion.auth]: Got pub key and salt (PubKey=5fcd2b970a463f98c22304fe1e4fedd2ebfcb791668184992b347ce64f776fa4bed4513738360b4dfb24eb20abc6944cd1bb155e718b767f55fd5a0972bbfa8af5ccde72aa554d377fc0f61a22d999fd42e6420abb655996a7803a1a011458521368cf5b36ce36a2827856503b895190359c04c197607a7cedf2f8802c51aaf89e2c5b5243b1f17bf30791e39fb5e98eba9f57cabb844aed44edd585719d4ebe6ffff123046074fcfc6d61a39223e016a5d0868726fe07fb62169274f10b56fd35893752506f1cd9e24dcb7915f3421e814f9684a21442189e4d4a1ff7294e0a08075f5a61d0ce9f23fc7eba9c5bf0eed6e4c1d808888893f68aae9cd917f..., Salt=f901b4fb6db47425668a1ea72ee5b3c3)
Enter PIN on screen: 5302
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.pairing]: Companion PIN changed to 5302
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.pairing]: Finish pairing Companion
2021-11-28 05:14:12 DEBUG [pyatv.auth.hap_srp]: Client (Proof=70b022f701996e24ddf6b1e76aa529e8345d7699d7f494525a674eacb3d7e75c883361d06f9aced77b2cd83fb29e27ecf73c5d294ac71124d224e61f3393487d, Public=efdc173e70b39d8f99924e911f403ab8231c879ea204c396d9d464bd949ffe17f75afab60590bf54b8a4fcc36231423ad9aa52f3d5231f87d1490a0a176223b6c8ff0d306f27a437c9a0a12b517a269544b0fc2724be329d7e901e135138f5ea433079e820ab357657dd866ef22ee580f2ff171153cf0edd9116f687c2ad12ce9b54b17934b1ec3378d813ef963b1cce3e761b2b4f60320275d6f766e976fe06065b322c6002931d3a8bafd1fc7a0bcca70b669f79c6fe296c28d8bbb05f07b227ebcef06e20041427847012575b63f8fe4bedf484085a9581019ab8d4282fb597bc6a60716089fb50db3adda3370ee6a2c12fd8527de982dccd0fa88b08c...)
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.protocol]: Exchange OPACK: {'_pd': b'\x06\x01\x03\x03\xff\xef\xdc\x17>p\xb3\x9d\x8f\x99\x92N\x91\x1f@:\xb8#\x1c\x87\x9e\xa2\x04\xc3\x96\xd9\xd4d\xbd\x94\x9f\xfe\x17\xf7Z\xfa\xb6\x05\x90\xbfT\xb8\xa4\xfc\xc3b1B:\xd9\xaaR\xf3\xd5#\x1f\x87\xd1I\n\n\x17b#\xb6\xc8\xff\r0o\'\xa47\xc9\xa0\xa1+Qz&\x95D\xb0\xfc\'$\xbe2\x9d~\x90\x1e\x13Q8\xf5\xeaC0y\xe8 \xab5vW\xdd\x86n\xf2.\xe5\x80\xf2\xff\x17\x11S\xcf\x0e\xdd\x91\x16\xf6\x87\xc2\xad\x12\xce\x9bT\xb1y4\xb1\xec3x\xd8\x13\xef\x96;\x1c\xce>v\x1b+O`2\x02u\xd6\xf7f\xe9v\xfe\x06\x06[2,`\x02\x93\x1d:\x8b\xaf\xd1\xfcz\x0b\xcc\xa7\x0bf\x9fy\xc6\xfe)l(\xd8\xbb\xb0_\x07\xb2\'\xeb\xce\xf0n \x04\x14\'\x84p\x12W[c\xf8\xfeK\xed\xf4\x84\x08Z\x95\x81\x01\x9a\xb8\xd4(/\xb5\x97\xbcj`q`\x89\xfbP\xdb:\xdd\xa37\x0e\xe6\xa2\xc1/\xd8R}\xe9\x82\xdc\xcd\x0f\xa8\x8b\x08\xc9\x03\x81\x91x\x93\x10&\xf4\xea+\x0e\xd6\x16\xc6\x90\x8a\xa0\xd5\xd3F\x1e\xf5p\xe4l\xe5\x90_W\x9d\xde\x9c<\x02*Ur\xd8\xb7&\xf0\x05\xe1\x87\rh\x05\xdcL\x94\xc2\x99\x1c}\xe7\xb3\rV\xb9\xe4m\xb9[\xe8J\x91\x14\xeb\x91ae0\xc4Y\x93\xd1\x1c\xa0\xc8&\xa9f\xce,d\xdb\xc9\xb94\x9fu\x0c\x04\x19\x8d\x9c@\xc8[\xd0r\xfb\x8a\x9d]\xaf\x0e\xe6\xcct\xcf`\xff\xe8\rh\xde\x11*\xe5\x06x\x9d&\xd0\xe5\x9cf\xce\xea \x04@p\xb0"\xf7\x01\x99n$\xdd\xf6\xb1\xe7j\xa5)\xe84]v\x99\xd7\xf4\x94RZgN\xac\xb3\xd7\xe7\\\x883a\xd0o\x9a\xce\xd7{,\xd8?\xb2\x9e\'\xec\xf7<])J\xc7\x11$\xd2$\xe6\x1f3\x93H}', '_pwTy': 1}
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.protocol]: Send OPACK: {'_pd': b'\x06\x01\x03\x03\xff\xef\xdc\x17>p\xb3\x9d\x8f\x99\x92N\x91\x1f@:\xb8#\x1c\x87\x9e\xa2\x04\xc3\x96\xd9\xd4d\xbd\x94\x9f\xfe\x17\xf7Z\xfa\xb6\x05\x90\xbfT\xb8\xa4\xfc\xc3b1B:\xd9\xaaR\xf3\xd5#\x1f\x87\xd1I\n\n\x17b#\xb6\xc8\xff\r0o\'\xa47\xc9\xa0\xa1+Qz&\x95D\xb0\xfc\'$\xbe2\x9d~\x90\x1e\x13Q8\xf5\xeaC0y\xe8 \xab5vW\xdd\x86n\xf2.\xe5\x80\xf2\xff\x17\x11S\xcf\x0e\xdd\x91\x16\xf6\x87\xc2\xad\x12\xce\x9bT\xb1y4\xb1\xec3x\xd8\x13\xef\x96;\x1c\xce>v\x1b+O`2\x02u\xd6\xf7f\xe9v\xfe\x06\x06[2,`\x02\x93\x1d:\x8b\xaf\xd1\xfcz\x0b\xcc\xa7\x0bf\x9fy\xc6\xfe)l(\xd8\xbb\xb0_\x07\xb2\'\xeb\xce\xf0n \x04\x14\'\x84p\x12W[c\xf8\xfeK\xed\xf4\x84\x08Z\x95\x81\x01\x9a\xb8\xd4(/\xb5\x97\xbcj`q`\x89\xfbP\xdb:\xdd\xa37\x0e\xe6\xa2\xc1/\xd8R}\xe9\x82\xdc\xcd\x0f\xa8\x8b\x08\xc9\x03\x81\x91x\x93\x10&\xf4\xea+\x0e\xd6\x16\xc6\x90\x8a\xa0\xd5\xd3F\x1e\xf5p\xe4l\xe5\x90_W\x9d\xde\x9c<\x02*Ur\xd8\xb7&\xf0\x05\xe1\x87\rh\x05\xdcL\x94\xc2\x99\x1c}\xe7\xb3\rV\xb9\xe4m\xb9[\xe8J\x91\x14\xeb\x91ae0\xc4Y\x93\xd1\x1c\xa0\xc8&\xa9f\xce,d\xdb\xc9\xb94\x9fu\x0c\x04\x19\x8d\x9c@\xc8[\xd0r\xfb\x8a\x9d]\xaf\x0e\xe6\xcct\xcf`\xff\xe8\rh\xde\x11*\xe5\x06x\x9d&\xd0\xe5\x9cf\xce\xea \x04@p\xb0"\xf7\x01\x99n$\xdd\xf6\xb1\xe7j\xa5)\xe84]v\x99\xd7\xf4\x94RZgN\xac\xb3\xd7\xe7\\\x883a\xd0o\x9a\xce\xd7{,\xd8?\xb2\x9e\'\xec\xf7<])J\xc7\x11$\xd2$\xe6\x1f3\x93H}', '_pwTy': 1, '_x': 65320}
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.connection]: >> Send data (Data=e3435f706492c90106010303ffefdc173e70b39d8f99924e911f403ab8231c879ea204c396d9d464bd949ffe17f75afab60590bf54b8a4fcc36231423ad9aa52f3d5231f87d1490a0a176223b6c8ff0d306f27a437c9a0a12b517a269544b0fc2724be329d7e901e135138f5ea433079e820ab357657dd866ef22ee580f2ff171153cf0edd9116f687c2ad12ce9b54b17934b1ec3378d813ef963b1cce3e761b2b4f60320275d6f766e976fe06065b322c6002931d3a8bafd1fc7a0bcca70b669f79c6fe296c28d8bbb05f07b227ebcef06e20041427847012575b63f8fe4bedf484085a9581019ab8d4282fb597bc6a60716089fb50db3adda3370ee6a2c..., FrameType=04)
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.connection]: Received data (Data=0400004ce1435f706491450601040440783149e0cd27224339543eecf23dcf54b374f8fed6062f0949beb9ca8d05bec07b8d0532f8e1c37d20e3930d5c4f211cbdfe8a7f313fce5343dfa32e82e11712)
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.protocol]: Received frame FrameType.PS_Next: b'\xe1C_pd\x91E\x06\x01\x04\x04@x1I\xe0\xcd\'"C9T>\xec\xf2=\xcfT\xb3t\xf8\xfe\xd6\x06/\tI\xbe\xb9\xca\x8d\x05\xbe\xc0{\x8d\x052\xf8\xe1\xc3} \xe3\x93\r\\O!\x1c\xbd\xfe\x8a\x7f1?\xceSC\xdf\xa3.\x82\xe1\x17\x12'
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.protocol]: Process incoming auth frame (FrameType.PS_Next): {'_pd': b'\x06\x01\x04\x04@x1I\xe0\xcd\'"C9T>\xec\xf2=\xcfT\xb3t\xf8\xfe\xd6\x06/\tI\xbe\xb9\xca\x8d\x05\xbe\xc0{\x8d\x052\xf8\xe1\xc3} \xe3\x93\r\\O!\x1c\xbd\xfe\x8a\x7f1?\xceSC\xdf\xa3.\x82\xe1\x17\x12'}
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.auth]: Device (Proof=783149e0cd27224339543eecf23dcf54b374f8fed6062f0949beb9ca8d05bec07b8d0532f8e1c37d20e3930d5c4f211cbdfe8a7f313fce5343dfa32e82e11712)
2021-11-28 05:14:12 DEBUG [pyatv.auth.hap_srp]: Data (Encrypted=aa29a18eaf27bb1ea85191c0b1ba72fbe5d48610744913618c6439f99268c91c110c0bd3fbb7715ea3a036d7856a1f41ba9dfc82fb82307bd31b46964204551ca3072324cff94f91827844b37330881d9e991bf01c4d8bf00e2e8aa77a608a6e83f9223a4bd113d200a657bdbbd83095f9764265c5353a577a4f3f0176ebd9f3e8e507cb67133831c15a227b2a069cf4af19606884289ac3b8614b4449fedf780842548169079e623cbec25b6e152e2d5cfad2571ff78fa95f6617b491c0ae39e0d89c7155c0d9e17f9d574cc4f65ac31b91f3f1e994e3e57634000dab2b87d46ce7111d115bbf44b7b22ea158beab2fd949136e465347652ed60b800cf67...)
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.protocol]: Exchange OPACK: {'_pd': b'\x06\x01\x05\x05\xff\xaa)\xa1\x8e\xaf\'\xbb\x1e\xa8Q\x91\xc0\xb1\xbar\xfb\xe5\xd4\x86\x10tI\x13a\x8cd9\xf9\x92h\xc9\x1c\x11\x0c\x0b\xd3\xfb\xb7q^\xa3\xa06\xd7\x85j\x1fA\xba\x9d\xfc\x82\xfb\x820{\xd3\x1bF\x96B\x04U\x1c\xa3\x07#$\xcf\xf9O\x91\x82xD\xb3s0\x88\x1d\x9e\x99\x1b\xf0\x1cM\x8b\xf0\x0e.\x8a\xa7z`\x8an\x83\xf9":K\xd1\x13\xd2\x00\xa6W\xbd\xbb\xd80\x95\xf9vBe\xc55:WzO?\x01v\xeb\xd9\xf3\xe8\xe5\x07\xcbg\x1381\xc1Z"{*\x06\x9c\xf4\xaf\x19`h\x84(\x9a\xc3\xb8aKDI\xfe\xdfx\x08BT\x81i\x07\x9eb<\xbe\xc2[n\x15.-\\\xfa\xd2W\x1f\xf7\x8f\xa9_f\x17\xb4\x91\xc0\xae9\xe0\xd8\x9cqU\xc0\xd9\xe1\x7f\x9dWL\xc4\xf6Z\xc3\x1b\x91\xf3\xf1\xe9\x94\xe3\xe5v4\x00\r\xab+\x87\xd4l\xe7\x11\x1d\x11[\xbfD\xb7\xb2.\xa1X\xbe\xab/\xd9I\x13nFSGe.\xd6\x0b\x80\x0c\xf6~\x05"\xbb\x12Ng\x81C\xc6^\xa8PB2\x90\xcb]+\x81"\xd1\x95\xaa\xe4\xbb\xa4\x90\xd0=\x9f$\xfd*\rZ\x04', '_pwTy': 1}
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.protocol]: Send OPACK: {'_pd': b'\x06\x01\x05\x05\xff\xaa)\xa1\x8e\xaf\'\xbb\x1e\xa8Q\x91\xc0\xb1\xbar\xfb\xe5\xd4\x86\x10tI\x13a\x8cd9\xf9\x92h\xc9\x1c\x11\x0c\x0b\xd3\xfb\xb7q^\xa3\xa06\xd7\x85j\x1fA\xba\x9d\xfc\x82\xfb\x820{\xd3\x1bF\x96B\x04U\x1c\xa3\x07#$\xcf\xf9O\x91\x82xD\xb3s0\x88\x1d\x9e\x99\x1b\xf0\x1cM\x8b\xf0\x0e.\x8a\xa7z`\x8an\x83\xf9":K\xd1\x13\xd2\x00\xa6W\xbd\xbb\xd80\x95\xf9vBe\xc55:WzO?\x01v\xeb\xd9\xf3\xe8\xe5\x07\xcbg\x1381\xc1Z"{*\x06\x9c\xf4\xaf\x19`h\x84(\x9a\xc3\xb8aKDI\xfe\xdfx\x08BT\x81i\x07\x9eb<\xbe\xc2[n\x15.-\\\xfa\xd2W\x1f\xf7\x8f\xa9_f\x17\xb4\x91\xc0\xae9\xe0\xd8\x9cqU\xc0\xd9\xe1\x7f\x9dWL\xc4\xf6Z\xc3\x1b\x91\xf3\xf1\xe9\x94\xe3\xe5v4\x00\r\xab+\x87\xd4l\xe7\x11\x1d\x11[\xbfD\xb7\xb2.\xa1X\xbe\xab/\xd9I\x13nFSGe.\xd6\x0b\x80\x0c\xf6~\x05"\xbb\x12Ng\x81C\xc6^\xa8PB2\x90\xcb]+\x81"\xd1\x95\xaa\xe4\xbb\xa4\x90\xd0=\x9f$\xfd*\rZ\x04', '_pwTy': 1, '_x': 65321}
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.connection]: >> Send data (Data=e3435f706492280106010505ffaa29a18eaf27bb1ea85191c0b1ba72fbe5d48610744913618c6439f99268c91c110c0bd3fbb7715ea3a036d7856a1f41ba9dfc82fb82307bd31b46964204551ca3072324cff94f91827844b37330881d9e991bf01c4d8bf00e2e8aa77a608a6e83f9223a4bd113d200a657bdbbd83095f9764265c5353a577a4f3f0176ebd9f3e8e507cb67133831c15a227b2a069cf4af19606884289ac3b8614b4449fedf780842548169079e623cbec25b6e152e2d5cfad2571ff78fa95f6617b491c0ae39e0d89c7155c0d9e17f9d574cc4f65ac31b91f3f1e994e3e57634000dab2b87d46ce7111d115bbf44b7b22ea158beab2fd94..., FrameType=04)
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.connection]: Received data (Data=0400012de1435f706492250105ff760d0e2392eae11e2a3829619242d54f5addf87a668812eb6289a1682e86c80baf2b0344f5755654aa6e9b90af86344a02af266cd72fcb4570bc3d09149fbc082238f5a9ee65445d289afb078624e078f5b55d1991cd3480bbe0c98e38f403ad8d855e9cde175605f08053f4f8d4a4ece1171dc71c9e4832dcaa917a9b27d963cf25a190d586af153e9210754f765ec51069156b21046c32ef3e307b6176a217297cb0d811f0d48fe37232fa47758c766ef0ed8a149d2f43c49e99208e519207b7615a9acf22e80abcb96afffcec1cf8d9a64db56cfbfedd47f5b963e1596a83499e2c3988c250cb160c2846ec55f13cf...)
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.protocol]: Received frame FrameType.PS_Next: b'\xe1C_pd\x92%\x01\x05\xffv\r\x0e#\x92\xea\xe1\x1e*8)a\x92B\xd5OZ\xdd\xf8zf\x88\x12\xebb\x89\xa1h.\x86\xc8\x0b\xaf+\x03D\xf5uVT\xaan\x9b\x90\xaf\x864J\x02\xaf&l\xd7/\xcbEp\xbc=\t\x14\x9f\xbc\x08"8\xf5\xa9\xeeeD](\x9a\xfb\x07\x86$\xe0x\xf5\xb5]\x19\x91\xcd4\x80\xbb\xe0\xc9\x8e8\xf4\x03\xad\x8d\x85^\x9c\xde\x17V\x05\xf0\x80S\xf4\xf8\xd4\xa4\xec\xe1\x17\x1d\xc7\x1c\x9eH2\xdc\xaa\x91z\x9b\'\xd9c\xcf%\xa1\x90\xd5\x86\xaf\x15>\x92\x10uOv^\xc5\x10i\x15k!\x04l2\xef>0{av\xa2\x17)|\xb0\xd8\x11\xf0\xd4\x8f\xe3r2\xfaGu\x8cvn\xf0\xed\x8a\x14\x9d/C\xc4\x9e\x99 \x8eQ\x92\x07\xb7aZ\x9a\xcf"\xe8\n\xbc\xb9j\xff\xfc\xec\x1c\xf8\xd9\xa6M\xb5l\xfb\xfe\xddG\xf5\xb9c\xe1Yj\x83I\x9e,9\x88\xc2P\xcb\x16\x0c(F\xecU\xf1<\xf4\xc9_awY\xe3\x1c\x16\xfd\x9e,\x89\xb3f\x05\x1f[\xcd\xd1\x9f\xead{\xbf\x92\x9f*\xe3)\xd7tt\x1bb\xdf\xe1\x1b#\xe1$\x0c/\x88}*\x8d\xb5\x06\x01\x06'
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.protocol]: Process incoming auth frame (FrameType.PS_Next): {'_pd': b'\x05\xffv\r\x0e#\x92\xea\xe1\x1e*8)a\x92B\xd5OZ\xdd\xf8zf\x88\x12\xebb\x89\xa1h.\x86\xc8\x0b\xaf+\x03D\xf5uVT\xaan\x9b\x90\xaf\x864J\x02\xaf&l\xd7/\xcbEp\xbc=\t\x14\x9f\xbc\x08"8\xf5\xa9\xeeeD](\x9a\xfb\x07\x86$\xe0x\xf5\xb5]\x19\x91\xcd4\x80\xbb\xe0\xc9\x8e8\xf4\x03\xad\x8d\x85^\x9c\xde\x17V\x05\xf0\x80S\xf4\xf8\xd4\xa4\xec\xe1\x17\x1d\xc7\x1c\x9eH2\xdc\xaa\x91z\x9b\'\xd9c\xcf%\xa1\x90\xd5\x86\xaf\x15>\x92\x10uOv^\xc5\x10i\x15k!\x04l2\xef>0{av\xa2\x17)|\xb0\xd8\x11\xf0\xd4\x8f\xe3r2\xfaGu\x8cvn\xf0\xed\x8a\x14\x9d/C\xc4\x9e\x99 \x8eQ\x92\x07\xb7aZ\x9a\xcf"\xe8\n\xbc\xb9j\xff\xfc\xec\x1c\xf8\xd9\xa6M\xb5l\xfb\xfe\xddG\xf5\xb9c\xe1Yj\x83I\x9e,9\x88\xc2P\xcb\x16\x0c(F\xecU\xf1<\xf4\xc9_awY\xe3\x1c\x16\xfd\x9e,\x89\xb3f\x05\x1f[\xcd\xd1\x9f\xead{\xbf\x92\x9f*\xe3)\xd7tt\x1bb\xdf\xe1\x1b#\xe1$\x0c/\x88}*\x8d\xb5\x06\x01\x06'}
2021-11-28 05:14:12 DEBUG [pyatv.auth.hap_srp]: PS-Msg06: {1: b'87C32499-F313-466B-A87E-EC45615A9FB6', 3: b'N\xee\x1a\xb7gh\x01\xa18c\x12\xa9\xed\xe0\xe5\xccbp\xfc\x9c\xf5\xd6U\xcc\xeaNb\x05\x10>g\x9e', 10: b'\xe2\r\x8c\xf0\x8e\xee4D\xc3s\x03">iq\x8e\xbe9\xc5\xc0\xad%\x12\x073!\xc2sE\x86E\x8e\xfa\x8bb\xd99:o\xa4\xecl\xb4\xe1a\xfc\x17p\tYM5\xb6\xb1\xd30A\x16\xb5\x9f=!V\x00', 17: b'\xe6FaltIRK\x80n\x13\x00$\t\xdb\xfd*\xdd\x8a\xab\xafV\x90*\xebIaccountIDa$87C32499-F313-466B-A87E-EC45615A9FB6EmodelJAppleTV6,2GwifiMACv\xcc\xd2\x81to\xb0DnameHBasementCmacv\xcc\xd2\x81t\xbe5'}
2021-11-28 05:14:12 DEBUG [pyatv.auth.hap_srp]: Device (Identifier=38374333323439392d463331332d343636422d413837452d454334353631354139464236, Public=4eee1ab7676801a1386312a9ede0e5cc6270fc9cf5d655ccea4e6205103e679e, Signature=e20d8cf08eee3444c37303223e69718ebe39c5c0ad2512073321c2734586458efa8b62d9393a6fa4ec6cb4e161fc177009594d35b6b1d3304116b59f3d215600)
Pairing seems to have succeeded, yey!
You may now use these credentials: 4eee1ab7676801a1386312a9ede0e5cc6270fc9cf5d655ccea4e6205103e679e:0ae72cd9971580c9cc0a237518361212fa28a10e65b1c7cded2e78e121aef272:38374333323439392d463331332d343636422d413837452d454334353631354139464236:33623735303963392d333532322d346633312d613333612d356361623062383033343830
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.connection]: Closing connection
2021-11-28 05:14:12 DEBUG [pyatv.protocols.companion.connection]: Connection lost to remote device: None
/ # 

@postlund
Copy link
Owner

postlund commented Dec 6, 2021

@Qonstrukt Sorry about the late response here, no excuses for that. So, here is my theory. The media player will report standby whenever pyatv reports that power state is Off. There is no "proper" off state in any of the known protocols so far, but we use a parameter called logicalDeviceCount which seems to correlate to the number of active output devices. Basically if HDMI is active, then it is 1 otherwise it is 0. Since the Apple TV can be used passively for audio streaming, like you do, this becomes a problem. It's obviously strange that the device can report power state "off" while still playing some media... So, one fix would be to change the power state to "on" whenever something is playing (or rather, when the device is not "idle"). One problem is that the power state will jump back and forth between on and off whenever plays or not. But that might be the best solution I guess, what do you think?

Edit: Created #1500 for this.

@postlund
Copy link
Owner

postlund commented Dec 6, 2021

@bverkron That looks good to me. I can't say why remotes are listed as "Unknown Device", but I have not looked into it either. Is this still the case with the latest version of the component?

@postlund
Copy link
Owner

postlund commented Dec 6, 2021

home-assistant/core#58665 has been merged to core, so the release in January will have the updated component bundled! 🎉

Hopefully I will be able to implement some more stuff before then.

@postlund postlund closed this as completed Dec 6, 2021
@postlund postlund unpinned this issue Dec 6, 2021
@bverkron
Copy link

bverkron commented Dec 6, 2021

@bverkron That looks good to me. I can't say why remotes are listed as "Unknown Device", but I have not looked into it either. Is this still the case with the latest version of the component?

I see the latest version requires home assistant 2021.12 which apparently won't be out until Dec 11th. I will try the latest version of this component once I've upgraded to 2021.12 sometime in December, hopefully.

@bverkron
Copy link

I updated and still had issues. It said said the following when I tried a few times.
image

I decided to reset / update the Apple TV itself (15.2 was available, I think it was on 15.1.x). While it was resetting / updating I noticed that the integration for that Apple TV had been "ignored" in the Integrations UI. Not sure how / when / why that happened but I stopped ignoring it and after that and the reset/update of the Apple TV I was able to pair it successfully. So not sure which of those several things fixed it, but it's working!

@postlund
Copy link
Owner

That sounds very strange and I have no theories of how/why that happened I'm afraid. But good that it worked out in the end at least.

@CommittotheIndian
Copy link

I updated and still had issues. It said said the following when I tried a few times. image

I decided to reset / update the Apple TV itself (15.2 was available, I think it was on 15.1.x). While it was resetting / updating I noticed that the integration for that Apple TV had been "ignored" in the Integrations UI. Not sure how / when / why that happened but I stopped ignoring it and after that and the reset/update of the Apple TV I was able to pair it successfully. So not sure which of those several things fixed it, but it's working!

I had the same image even after updating to 2022.2.0.

I looked and had my AppleTV ignored. Once I un-ignored it, it loaded right up no issues so I would go with that as the fix.

@palmerch1
Copy link

Hello,

I am trying to connect my apple tv(tvOS 15.4.1) to HA(v2022.4.5).
I noticed that my version of tvOS wasn't supported by the
"standard" Apple TV integration and discovered the beta version.
So, i installed Apple TV Beta(v3.0.1) via HACS(v1.24.5).
I can see the "Apple TV Beta" integration inside "HACS -> integrations",
but I guess it's not configurated properly as the apple tv is on another
network then my HA instance, but I didn't see any option to connect my apple tv.
My apple tv is in a 192.168.0.0/24 network, while the HA instance is in a 192.168.122.0/24 network.

Can someone please point me towards a config file or some other location where i can enter an ip address ?

I found a file which contains some properties but I don't know if this is the right file : /root/config/.storage/hacs/224041719.hacs

Thank you !

Best regards,
Christof.

@Qonstrukt
Copy link

Qonstrukt commented Apr 17, 2022

This is an outdated ticket. The integration in HA itself should be up to date with what is in HACS.

Besides that, when you add an Apple TV manually in HA you can just specify an IP, so as long as inter network routing is set up properly it should technically work. I think you will also need mDNS forwarding/proxy'ing between those networks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party Used for issues dealing applications using pyatv bug
Projects
None yet
Development

No branches or pull requests