Log media playing

I am trying to log my media comsumption.
It is only my Apple TV which is used for playing media on my TV.

So I have setup a trigger to be when Apple TV starts playing for 10 sec.
The action is to make a special log.
In the message I would like to have the title of the media.
Under tracking in the automation I can find it in the change variables, but I do not know how to get it into the message.

Below is the changed variables.
Does anybody know how the get the title into a message in the automation?

this:
  entity_id: automation.dagligstue_afspiller
  state: 'on'
  attributes:
    id: '1714415052262'
    last_triggered: '2024-05-01T17:15:09.072927+00:00'
    mode: single
    current: 0
    friendly_name: Dagligstue afspiller
  last_changed: '2024-04-30T14:02:23.188843+00:00'
  last_reported: '2024-05-01T17:15:09.073698+00:00'
  last_updated: '2024-05-01T17:15:09.073698+00:00'
  context:
    id: 01HWTJE9CG9D67GP8X2QWSS05J
    parent_id: 01HWTJDZKZHS06YAT7D7MVRGSQ
    user_id: null
trigger:
  id: '0'
  idx: '0'
  alias: null
  platform: device
  entity_id: media_player.dagligstue
  from_state:
    entity_id: media_player.dagligstue
    state: paused
    attributes:
      source_list:
        - YouTube
      media_duration: 5472
      media_position: 852
      media_position_updated_at: '2024-05-01T19:05:01.606797+00:00'
      media_title: COMEDY ROAST BATTLE - VINDERNES VINDER // @ChristianiaComedyClub
      media_artist: SJOWTIME
      media_album_name: ''
      app_id: com.google.ios.youtube
      app_name: YouTube
      friendly_name: Dagligstue
      supported_features: 450487
    last_changed: '2024-05-01T19:04:51.986327+00:00'
    last_reported: '2024-05-01T19:05:01.607421+00:00'
    last_updated: '2024-05-01T19:05:01.607421+00:00'
    context:
      id: 01HWTRQFD7DRZ1557VGK02M6EP
      parent_id: null
      user_id: null
  to_state:
    entity_id: media_player.dagligstue
    state: playing
    attributes:
      source_list:
        - YouTube
      media_duration: 5472
      media_position: 853
      media_position_updated_at: '2024-05-01T19:05:04.207952+00:00'
      media_title: COMEDY ROAST BATTLE - VINDERNES VINDER // @ChristianiaComedyClub
      media_artist: SJOWTIME
      media_album_name: ''
      app_id: com.google.ios.youtube
      app_name: YouTube
      friendly_name: Dagligstue
      supported_features: 450487
    last_changed: '2024-05-01T19:05:04.208536+00:00'
    last_reported: '2024-05-01T19:05:04.208536+00:00'
    last_updated: '2024-05-01T19:05:04.208536+00:00'
    context:
      id: 01HWTRQHYGDTYAD7V2YVK0JVGN
      parent_id: null
      user_id: null
  for:
    __type: <class 'datetime.timedelta'>
    total_seconds: 10
  attribute: null
  description: state of media_player.dagligstue
data:
  message: "{{ state_attr('media_player.dagligstue','media_title') }}"
1 Like

Thanks.
Forget to follow up. It works perfectly.

1 Like