Apple TV On HassOS

Hi @postlund and everybody using this plugin.

I was able to install it through HACS and it discovered my Apple TV no problem.

I’m curious if there is a way to send Microphone commands to the Apple TV?

I’d like to be able to automate certain apps (such as “Channels”) and the easiest way would be to use spoof some microphone input by sending “Open Channels App” to the Apple TV.

If not, I can probably work around it with some combination of menu and home key presses to get back to the first icon on the home screen.

Anyway great to have Apple TV 4 playing nice with Home Assistant.

It’s currently not supported, but a feature request. At some point I might give it a try to implement, but I do believe that it’s a non-trivial task. I would also need to find a decent speech synthesizer that is both local (I.e. no cloud) and works well with Siri.

1 Like

I’m sure it’s definitely not trivial, no worries there.

Initially looking at the media_player UI I thought the “Text To Speech” box was for issuing such commands, then I came to realize it was actually connecting to the device and reading text with Airplay… Which makes sense when one wants to use the media player for thinks like notifications during certain automations (so a message is conveyed on the speakers) :smile:

I will continue to fiddle with atv commands to see if I can find a way to get the Apple TV back into a known state. This is the similar type of challenge TVs with non-discrete IR codes for some operations have; i.e. for “mute” you must do vol+,mute,vol- to first unmute, then mute, and finally restore volume with tiny delays between each to that a Mute automation always results in a silenced TV regardless of if the TV was muted or unmuted to begin with.

Yeah, that is for TTS :blush: It’s quite convenient to have it integrated the way it is.

You can change in the settings menu what holding the home button does. If you change it to go to main screen, it will automatically pick the first app in the upper left corner. You can then “press” the button called home_hold to trigger this.

1 Like

Oh, didn’t realize that was configurable, think that could work…

I didn’t find anything for holding down home, but just a single press under here:
Settings -> Remotes and Devices -> Home Button

Mine was set to the default of “Apple TV App”, so changed that to “Home Screen”… Single tap seems to get me to the first app on home screen consistently, so that’s perfect as a consistent starting point for automations.

:beers:

1 Like

Ah, yes, I always confuse that. You are right of course. Hope it works out for you :+1:

Hello @postlund, and thanks for your work.
The HACS integration is working well and I didn’t have to manage nothing. With HA 0.114 he discovered my AppleTV in a second.

I have a question, cause I’m a noob and I’m a bit confused about this integration.
After the first configuration, I got two entities: the remote and the media_player of course.

What I can’t understand is how can I manage the other funcionalities like Device Metadata or Fetch artwork?

Thanks!

1 Like

Device metadata, like what is playing, is available via the media_player entity like with any other media player. Try playing something and head over to Developer Tools -> States and look for your Apple TV there. You should see the available metadata.

Regarding artwork. You get the URL to the artwork if you look at the metadata described above. It is fetched on-the-fly and cached. You can currently not see if artwork is available or not, you will have to fetch and see.

1 Like

Thanks for your reply!

Ok, now I understood. It’s a “common” media_player entity.
Last question: Will “media_player.select_source” service work with AppleTV? Can I launch apps like Netflix or so?

Yeah, it adheres to the same API as all other media players.

Unfortunately no, you cannot start apps via select_source as I haven’t managed to figure out how to start apps yet. It’s another protocol which isn’t fully reverse engineered yet, I’m only half-way.

1 Like

Cool, so maybe in the future…
I really hope that tvOS14 will not ruin nothing of the great work you did until now!

Thak you again!

Yeah, I really hope to get that working in the future. Would be really nice.

It has been tested with tvOS 14 beta and I’ve made a few changes for compatibility. So I think we will be ok. This time there’s really no reason for breakage since there are no big changes in the protocol department.

3 Likes

Hey guys, I have a pretty annoying issue with the integration.

Installation and paring process works fine, but after a few days media player entity becomes unavailable (unknown state) and Hass rediscovers it as a new integration.

In order to make it work again I have to remove the integration, unpair from ATV and restart it, then repair. That works for a few days then it becomes unavailable again etc. etc.

ATV is on fixed IP address.

Any clues where to start?

1 Like

I have the same issue.

I’ve also noted the same behavior on both my ATVs.

I updated to 0.115.2 yesterday and haven’t had the issue since…not sure if it’s coincidence.
I did notice one other thing…status changes from “unknown” to “idle” all the time (when ATV is sleeping).

I spoke too soon…it went unavalable again…and soon enough new ATV is discovered again :frowning:

1 Like

Hello there,
I don’t know if i’m using this integration in a bad way : commands doesn’t work with my Apple TV 4K with TVOS 14.

service: remote.send_command
data: 
  command: home_hold
entity_id: remote.tv_salon

Someone can help me please ?

Command must be a list:

service: remote.send_command
data: 
  command:
    - home_hold
entity_id: remote.tv_salon
1 Like

Fantastic it works. :star_struck:
Many thanks for this amazing integration. It solves a big problem for me : sleep my television through ATV and HDMI CEC.

1 Like