Apple TV Integration - tvOS 15 Beta

Well, Bluetooth is RF but it’s not a simple protocol. I don’t know if there are any open specifications for how that communication works.

How it’s implemented depends on your automation engine of choice I guess. You could use a helper, e.g. input_number, and save the volume there until you need to restore it. It’s a bit fragile as you might imagine, but would work in theory at least.

For YouTube in particular, you could also try this:

It’s supposed to skip ads automatically somehow. It is also built using pyatv, same as the integration in Home Assistant. I have not tried it myself, just wanted to mention it.

What is the process for app listing and launching? I’ve tried something like this from Developer Tools, but nothing seems to happen:

service: media_player.select_source
data:
  source: netflix
target:
  entity_id: media_player.apple_tv_bedroom

I’m only beginning to explore the media_player aspects of HA, so I may be missing something obvious.

Apologies if asked…Have this in place, off works but no on from HA, what am I doing wrong?

Thanks for the mention @postlund . I’m the project creator and while it’s still in development the core functionality is working.

2 Likes

You’re right of course. I just assumed that the function of mute and the function of pause were different enough that they wouldn’t be interchangeable and that if pause was an acceptable substitution, I’d have to be pretty silly to not have used that in the first place. I’m also always trying not to over explain because I worry that people wouldn’t be bothered to read super long explanations.

In future I shall try harder to strike that balance better though.

Thanks very much. I shall certainly give that a look!

I don’t suppose you could link me to a good explanation of how to save that volume number on an input_number?

Edit: I found this Save Volume Level - #2 by micque and will work from that unless you say there’s a better way.

Also, while the integration is still working fine for my HomePods and AirPorts… It seems to have lost my Apple TV (I suspect after a recent tvOS beta update). Anyone else having issues or is it just me?

1 Like

Check out the last section. I use it for lights, might be just what you need for volume as well and built right into home assistant itself:

Looks like this, maybe you can even get it to work with a attribute but I haven’t tried

Don’t cross post. If you do, at least cross link and cross update too.

Sorry. Deleted my post.

Does anyone have a workaround that after the AppleTV goes to sleep it is not detected by the integration until you completely restart Home Assistant?
Thanks!

Same issue here.
But you don’t have to restart HA, reload the integration also fixes the issue.

3 Likes

Hello all,

just moved over from openHAB to Home Assistant a few weeks ago.
I don’t know why but the Apple TV Integration stopped working yesterday.

I’m running Home Assistant 2022.3.7 on a raspberry pi.

In the logs the first ERROR I get is:

Logger: homeassistant.setup
Source: setup.py:162 
First occurred: 9:43:46 PM (1 occurrences) 
Last logged: 9:43:46 PM

Setup failed for apple_tv: Unable to import component: Exception importing homeassistant.components.apple_tv

After that this:

Logger: homeassistant.loader
Source: components/apple_tv/__init__.py:6 
First occurred: 9:43:46 PM (35 occurrences) 
Last logged: 9:44:45 PM

Unexpected exception importing component homeassistant.components.apple_tv
Unexpected exception importing platform homeassistant.components.apple_tv.config_flow
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 553, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/apple_tv/__init__.py", line 6, in <module>
    from pyatv import connect, exceptions, scan
  File "/usr/local/lib/python3.9/site-packages/pyatv/__init__.py", line 24, in <module>
    from pyatv.protocols import PROTOCOLS
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/__init__.py", line 10, in <module>
    from pyatv.protocols import airplay as airplay_proto
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/airplay/__init__.py", line 28, in <module>
    from pyatv.protocols import mrp
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/mrp/__init__.py", line 56, in <module>
    from pyatv.protocols.mrp import messages, protobuf
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/mrp/messages.py", line 8, in <module>
    from pyatv.protocols.mrp import protobuf
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/mrp/protobuf/__init__.py", line 6, in <module>
    from .ProtocolMessage_pb2 import ProtocolMessage
  File "/usr/local/lib/python3.9/site-packages/pyatv/protocols/mrp/protobuf/ProtocolMessage_pb2.py", line 21, in <module>
    _ERRORCODE = DESCRIPTOR.message_types_by_name['ErrorCode']
AttributeError: 'NoneType' object has no attribute 'message_types_by_name'

and this:

Logger: homeassistant.config_entries
Source: config_entries.py:745 
First occurred: 9:44:02 PM (34 occurrences) 
Last logged: 9:44:45 PM

Error occurred loading configuration flow for integration apple_tv: Exception importing homeassistant.components.apple_tv.config_flow

I tried to uninstall the integration but didn’t work. I can just disable it.
Maybe someone can help me to fix it?

Best regards
Markus

EDIT: Is it maybe a problem that “mbapi2020” uses protobuf 3.14.0?

I solved it by adding a shell command reloading the integration every 30 min.

Hello,

Can you give your command ? Thx

So just picked up a second HomePod which has been discovered fine. However I have moved my
HomePods around so the new one has the same
Name as the old one and despite be changing this in HA after a reboot the new one is discovered again and the old one has reverted back its name.

How can I stop that or remove the integration settings and set it all back up.

You could disable the ATV from going to sleep in the settings on the ATV itself

Is there any way to catch the vol+/- coming from the physical remote control?

My projector has no IR and not -CEC. Want to do volume control translation via HA.

I have never been able to add my HomePod Minis to this Beta integration! (Previously had them working fine, including TTS, under the Core integration pre-OS 15)
Any ideas where to start troubleshooting? The HomePods discover fine, but when I click “configure”, although it tells me I’m adding a “HomePod mini” it also warns about entering PIN codes, then I get 3 more popups warning “Pairing not possible” before it fails.

never mind, finally managed to sort it. Looks like the Beta integration is actually behind the Core integration now anyway, but actually the problem was you need to have “Allow Speakers & TV Access” set to “Everyone” in your Home app to disable the pairing requirement. Managed to figure this out using the atvremote tool - possibly it’s mentioned in the docs somewhere but I never saw it!!

This is a huge thread so forgive me if I missed anything but I am trying to get TTS (using Amazon Polly) working on my Homepod & Homepod Minis.

I am getting the error “Media streaming is not possible with current configuration”. I saw this in the thread above stating that the problem was https streams weren’t supported but then further in the thread noting that the feature was added.

Is there some configuration I maybe need to setup?

EDIT: Ok so I even tried setting up a Node-Red flow that calls the Polly service myself, saves a file locally, then sends it to the Homepod Mini using media_player.play_media and I STILL get the same “Media streaming is not possible with current configuration” error. So I don’t think it has anythign to do with the source but with some config I am missing.