Displaying the correct app names on Android TV using configuration.yaml

I have an Android TV device which is connected to my HA, I would like to be able to view which app is currently playing which is does do, but its quite hard to decipher the name.

It shows names like ar.tvplayer.tv, when it should be showing TiviMate. After Googling I was able to cobble together this in my configuration.yaml file:

#androidTV
media_player:
  - platform: androidtv
    name: Dining Room TV
    device_class: androidtv
    host: 192.168.1.178
    exclude_unnamed_apps: false
    apps:
      com.google.android.apps.tv.launcherx: "Home"
      com.google.android.youtube.tv: "Youtube"
      com.amazon.amazonvideo.livingroom: "Amazon Prime Video"
      com.plexapp.android: "Plex"
      com.netflix.ninja: "Netflix"
      com.disney.disneyplus: "Disney+"
      com.spotify.tv.android: "Spotify"
      ar.tvplayer.tv: "TiviMate"
      com.teamsmart.videomanager.tv: "SmartTube"

The IP address is correct and I have restarted HA after inserting but it doesn’t seem to have taken any affect. Can someone please advise?

EDIT: HA has given me an alert saying “Unused YAML configuration for the androidtv integration” and prompting me to remove the block. I’ve obviously done something wrong. Can someone advise how to fix?

This is quite difficult to read…

Apologies, I’ve corrected this now.

I’m not clear how your TV is integrated. I use Android Debug Bridge, which has the current source app id as an attribute, for example:

ca.dstudio.atvlauncher.pro

If I wanted friendly names I’d create a template sensor something like:

  - sensor: 
      - name: "Channel"
        state: >
          {% if state_attr("media_player.android_tv_192_168_1_103", "app_id") == "com.netflix.ninja" %}
            Netflix
          {% elif state_attr("media_player.android_tv_192_168_1_103", "app_id") == "com.amazon.amazonvideo.livingroom" %}
            Amazon Prime
          {% endif %}

Edit: Although now I look at it I see there is an “app_name” attribute too, so the template wouldn’t be necessary… :roll_eyes:

Would this add a new sensor independent of my media devices? In the media player card, instead of showing the app_id I want it to show the Name of the app, or a friendly label (that I can define).

I have two Android (Shield TV) devices I want to apply this to.

So I managed to find a customisation tag that we can use to display state values in alternative “friendlier” formats. It however does work, can anyone see if this is the correct syntax or whether this isn’t the correct approach.

homeassistant:
  customize:
    media_player.dining_room_tv_shield:
      androidtv_apps:
        ar.tvplayer.tv: "TiviMate"
        com.teamsmart.videomanager.tv: "SmartTube"
        com.google.android.apps.tv.launcherx: "Home"
        com.google.android.youtube.tv: "Youtube"
        com.amazon.amazonvideo.livingroom: "Amazon Prime Video"
        com.plexapp.android: "Plex"
        com.netflix.ninja: "Netflix"
        com.disney.disneyplus: "Disney+"
        com.spotify.tv.android: "Spotify"
    media_player.living_room_tv_shield:
      androidtv_apps:
        ar.tvplayer.tv: "TiviMate"
        com.teamsmart.videomanager.tv: "SmartTube"

I know this topic is quite old now, but if you want to display app name (e.g. TiviMate) instead of app package name (e.g. ar.tvplayer.tv) on Media control card you can do this with media_player.template integration. You can install it with HACS or manually.

The integration allows to set custom media player title via title_template configuration variable. You can conditionally set desired app name based on app package name exposed by Android TV remote media player.

Below is a code snippet you can add to your configuration.yaml file. Just change media_player.android_tv to your Android TV media player entity and add conditions for other Android apps installed on your TV in title_template. You can also configure other variables based on your needs.

media_player:
  - platform: media_player_template
    media_players:
      android_tv_template:
        friendly_name: Android TV
        device_class: tv
        value_template: >
          {% if is_state("media_player.android_tv", "on") %}
            on
          {% else %}
            off
          {% endif %}
        title_template: >
          {% if is_state_attr('media_player.android_tv', 'app_id', "com.netflix.ninja") %}
            Netflix
          {% elif is_state_attr('media_player.android_tv', 'app_id', "com.google.android.youtube.tv") %}
            YouTube
          {% elif is_state_attr('media_player.android_tv', 'app_id', "ar.tvplayer.tv") %}
            TiviMate
          {% else %}
            Android TV
          {% endif %}
        turn_on:
          service: media_player.turn_on
          target:
            entity_id: media_player.android_tv
        turn_off:
          service: media_player.turn_off
          target:
            entity_id: media_player.android_tv
        volume_up:
          service: media_player.volume_up
          target:
            entity_id: media_player.android_tv
        volume_down:
          service: media_player.volume_down
          target:
            entity_id: media_player.android_tv
        mute:
          service: media_player.volume_mute
          target:
            entity_id: media_player.android_tv
        play:
          service: media_player.media_play
          target:
            entity_id: media_player.android_tv
        pause:
          service: media_player.media_pause
          target:
            entity_id: media_player.android_tv
        stop:
          service: media_player.media_stop
          target:
            entity_id: media_player.android_tv
        next:
          service: media_player.media_next_track
          target:
            entity_id: media_player.android_tv
        previous:
          service: media_player.media_previous_track
          target:
            entity_id: media_player.android_tv

After adding this to your configuration.yaml file and restarting Home Asisstant you should have media_player.android_tv_template entity, that shows currently opened app name on Media control card.