Pyatv: Refuses to connect if Apple TV on different subnet

Created on 29 Apr 2020  路  11Comments  路  Source: postlund/pyatv

Describe the bug
Apple TV is on a different subnet from the Home Assistant host. This was working properly in older versions, but behavior changed in #581 to disallow this configuration in 0.6.0.

Since this was working properly before, is it necessary to explicitly abort configuration?

System Setup (please complete the following information):

  • OS: Ubuntu 19.10
  • Python: 3.7.5
  • pyatv: 0.6.1

    • Apple TV: 4 on latest OS

bug

Most helpful comment

I just pushed an update that hopefully should fix this. Please give it a go!

All 11 comments

Ah, yes. The cross-subnet restriction only applies to unicast scanning, but since that it used in the component as an additional measure against scanning problems, it will fail in this case. I assume you use some kind of MDNS bridge?

Anyway, I shall make a fix for it.

Exactly, I use an mDNS repeater for device discovery.

I just pushed an update that hopefully should fix this. Please give it a go!

Works for me again!

Great!

It's seems it's doesn't work same after the last update.

From the HomeAssistant host (not the same subnet), if I do an manual scan :
Capture d鈥檈虂cran 2020-05-10 a虁 20 30 10

If I ping it (not an the same subnet too) :
Capture d鈥檈虂cran 2020-05-10 a虁 20 31 33

From HomeAssistant:
With the hostname it's doesn't work before the timeout, and with the IP I've an warning about the subnet
Capture d鈥檈虂cran 2020-05-10 a虁 20 38 01

And If i do an manual scan from the same subnet of my AppleTV:
Capture d鈥檈虂cran 2020-05-10 a虁 20 32 27

I hope it's can help !

@Robvred The integration only works if Home Assistant and the Apple TV is on the same network or if you are using something that relays zeroconf services between subnets. In the latter case you must use either the Apple TV name or one of its unique identifiers (that you get with for instance atvremote scan). Using the IP address won't work in this case as that triggers the usage of unicast scanning, which doesn't work because hosts are not supposed to answer those kinds of requests from other subnets. It's documented here:

https://pyatv.dev/documentation/concepts/#scanning

Thanks @postlund it's clear. May I ask you a recommendation for relays zeroconf services between subnets in docker ?

@Robvred Not sure I'm afraid, never used one. I intend to create a script for it in pyatv at some point, but I'm not sure when that will happen.

@postlund just because it's can be interesting for others, I've found a solution working perfectly on my configuration with subnet.
I've added an macvlan subnet and attach my docker container to it, and I've been able to listen all broadcast coming from my lan network devices like AppleTV, chromecast and more...
I've just create an restricted subnet in my local network to avoid DHCP collision.
I hope it's can be useful for others.

@Robvred Yeah, sounds like that should work. As long as multicast traffic is passed along it should be fine. Great tip 馃憤

Was this page helpful?
0 / 5 - 0 ratings