Media player song history (e.g. for Google Home)

This thread was very useful to me, and it led me to create a list of recently played media player songs and when they played

I used this template sensor that I added to configuration.yaml

template:
  - sensor:
      - name: "Spotify Song & Artist"
        state: >
          {%  if state_attr('media_player.spotify_dan', 'media_title') != none -%}
          {{ state_attr('media_player.spotify_dan', 'media_title') }}  |  {{ state_attr('media_player.spotify_dan', 'media_artist') }}
          {%- endif %}
        icon: mdi:format-list-bulleted

To display the information I used the Home Feed Card on Github | Forum Thread and these settings on my dashboard

type: custom:home-feed-card
title: Spotify Recently Played
show_empty: false
scrollbars_enabled: false
more_info_on_tap: true
state_color: true
compact_mode: true
entities:
  - entity: sensor.spotify_song_artist
    include_history: true
    max_history: 25
    format: time
    content_template: '{{state}}'
2 Likes