Sensor Template for Apple TV

I have really delved into Template Sensors, and following 🟣 Rounded - Dashboard guide - #107 by bbolinger for adding various cards.

One I am struggling with is the Media Card, LE0N makes a sensor to relay what is playing and again, I don’t have too much experience building Templates.

TIA

1 Like

So I was able to solve it that way for me. No idea if this is right or if there is a better solution, but it works.


  - sensor:
      - name: "Aktive App Apple TV Wohnzimmer"
        unique_id: aktive_app_apple_tv_wohnzimmer
        state: >
          {{ state_attr('media_player.apple_tv_wohnzimmer', 'app_id') | regex_replace ("de.telekom.entertaintv-iphone", "Magenta TV") | replace ("com.google.ios.youtube", "YouTube") | replace ("com.amazon.aiv.AIVApp", "Prime Video")}}
          

Greetings and a nice weekend
Moss

1 Like

@Moss @chunk

Do you both have this working? I’m made the sensor based on your code moss, but getting unknown back when the tv is off. Tried to change that with your template, see below but no luck. Did either of you have a similar issue?

Option 1

- platform: template
    sensors:
      active_app_samsung_tv_livingroom:
        friendly_name: 'Active App Samsung TV'
        value_template: >
            {{ state_attr('media_player.samsungtvwoonkamer', 'source_list') | regex_replace ("unknown", "Television is off") }}

Option 2

- platform: template
    sensors:
      active_app_samsung_tv_livingroom:
        friendly_name: 'Active App Samsung TV'
        value_template: >
                {% if state_attr('media_player.samsungtvwoonkamer', 'source_list') == 'unknown' %}
                    Television is off
                {% else %}
                  {{ state_attr('media_player.samsungtvwoonkamer', 'source_list') }}
                {% endif %}

Thanks
Bas

Hello Bas I no longer use it. At some point I found myself investing too much time in designing a dashboard. Currently I only run automations and the standard dashboard, I have neglected or given up all other gimmicks

Greetings
Moss

Thanks for your reply, hope that you still enjoy your smart home as much or maybe even more!