Apple TV automation

I want my Apple TV to trigger a scene when playing a movie or TV show, but not when playing music or running game apps. I know I can trigger on the “playing” state but I can’t find out how to determine what kind of media is playing. Does anyone know a way to do this? Is there a list of Apple TV integration attributes anywhere? Thanks!

You can look at the media_content_type which will be either movie, music, tvshow or nothing/unset if unknown. The value depends on how well the playing app provides the content type, so it might not always be accurate.

1 Like

Thanks Pierre!

I was hoping there was something like this. So would I reference that in a condition like this “media_player.livingroom_appletv.media_content_type”? Is there a list of all of these attributes somewhere, or a way to discover them?

Thanks again for your help.

If you go to Developer Tools -> States and play something on your Apple TV, it will report the current state and attributes there. Different apps report different things, so it involves a bit of trial and error.

I’ve found that some apps don’t properly report the media_content_type so I look at the app_name attribute instead.

Here’s a condition I use in my setup that contains most of the major US video apps:

condition:
  - condition: template
    value_template: "{{ state_attr('media_player.office_apple_tv', 'app_name') in ['ABC', 'AMC', 'Comedy Central', 'Disney+', 'ESPN', 'FOX NOW', 'FXNOW', 'Hulu', 'Movies', 'NBC', 'Netflix', 'Paramount+', 'Peacock', 'Plex', 'Pluto TV', 'Prime Video', 'Showtime Anytime', 'STARZ', 'SYFY', 'The CW', 'Trailers', 'Tubi', 'TV', 'TV Shows', 'Twitch', 'USA', 'YouTube', 'YouTube Kids'] }}"

You can keep your automation the same (trigger on “playing” state), but with the above condition it won’t activate the scene unless the app name matches something in that list.

2 Likes

What @SeanM wrote is a good summary :+1:

1 Like

Sean! Awesome. Thanks so much this is gold.

Hi Sean

Where can I learn more about how to do things like this? I’ve got a coding background so the syntax doesn’t scare me.

Thanks

Howard

Hi, I’m trying to run an automation only when I’m using the YouTube app on Apple TV. What is the best way to include this as a condition in my Automation?

I’ve tried using the template condition above, ensuring the syntax and device are correct, but it doesn’t seem to work.

Seems the App ID Attribute would be the most obvious answer, but putting “YouTube” in there doesn’t work. How do I find the App ID of the YouTube app? Or is there a better way?

Thank you for any help!

@postlund you may be the best person to answer this question?

The attribute is called app_id I think and it maps to a bundle identifier, like com.netflix.Netflix or similar. It’s easiest to just play something and check the attribute in the developer tools.

Thank you @postlund. That did the trick.

1 Like