pyatv
pyatv copied to clipboard
Connect without Bonjour
What feature would you like?
Would it be possible to connect directly to the IP address of the Apple TV instead of using Bonjour/Zeroconf? This would be awesome to connect through more complicated networks with VLANs, etc.
Describe the solution you'd like
Choose Apple TV by IP address
Any other information to share?
thanks!
So, while it is to some extent already possible, it's not a very fun experience. You can manually create a configuration as described here but since port number (for most protocols) change dynamically and you need the Zeroconf properties from each service to get the best experience (unique identifiers, device information, working detection of pairing requirements, etc.) it will be very tedious. A much better way is to use an MDNS responder/relayer and forward all the services that way. The last way I can think of is to write a simple script that periodically scans the target network for devices and forwards the result to your "main script". If unicast scanning had worked that would have been the ideal solution, but Apple devices drop requests from other networks so it's not possible.
Thanks for the tips. Do you know of any protocols that use a static port number? For my use case, I only need remote control commands, no metadata or other info. It sounds like Companion is the only protocol supported in the latest tvOS.
DMAP uses 3689, AirPlay 7000 and RAOP usually 5000 (but some 3rd party receivers use other ports). Since everything is available via AirPlay, in theory that would be fine. But AirPlay establishes multiple tunnels (on random ports) during set up, so that doesn't really work either. As you mentioned, Companion uses a random port but also requires the connection to be initiated from a device on the same network. Otherwise it just responds with "NoOp".
I think this is resolved from the point that not much can be done from the perspective of pyatv.