Determine the Media player that triggered the automation

I have 2 Apple TVs conected with home assistant as media players.
What I am aiming is to have a notification on my mobile phone, that finds out which Apple TV started playing, and informs me about of the name of media being played, as well as the app playing this media.

Now, in the action part, if I put this code, it works fine:

service: notify.mobile_app_shadys_iphone
data:
  message: >-
    '{{ state_attr("media_player.lounge_apple_tv", "media_title") }}' is
    playing from '{{ state_attr("media_player.lounge_apple_tv", "app_name")
    }}' on Lounge tv!

But this will only show what is running one of the ‘lounge’ TV’, i deally I need the action to find out which Apple TV triggered the automation and starts pulling the required attributes. When I try to use this code, it shows ‘None’

service: notify.mobile_app_shadys_iphone
data:
  message: >-
    '{{ state_attr("trigger.to_state.entity_id", "media_title") }}' is playing
    from '{{ state_attr("trigger.to_state.entity_id", "app_name") }}' on '{{
    trigger.to_state.name }}'!

The question is:
What is the right syntax that will determine ‘the TV media player’ that triggered the automation, and get its attricutes? Thanks for your help.

What is the automation’s trigger? Please post the entire automation.

Does Simple notifications when Plex is playing - #15 by djbrooks022 help? I use a slightly modified version of that and it shows the media player and media that is being played.

Thank you so much for the prompt response, the complete automation is:

- id: '1653134800624'
  alias: Notification - TVs
  description: ''
  trigger:
  - platform: device
    device_id: fc686af0572ddce28b599aedc5d56013
    domain: media_player
    entity_id: media_player.lounge_apple_tv
    type: playing
  - platform: device
    device_id: 306cdc540ec53eba17fa08aa623870da
    domain: media_player
    entity_id: media_player.living_room_apple_tv
    type: playing
  condition: []
  action:
  - service: notify.mobile_app_shadys_iphone
    data:
      message: '''{{ state_attr("trigger.to_state.entity_id", "media_title") }}''
        is playing from ''{{ state_attr("trigger.to_state.entity_id", "app_name")
        }}'' on ''{{ trigger.to_state.name }}''!'
  mode: single
- id: '1653134800624'
  alias: Notification - TVs
  description: ''
  trigger:
  - platform: state
    entity_id:
      - media_player.lounge_apple_tv
      - media_player.living_room_apple_tv
    to: playing
  condition: []
  action:
  - service: notify.mobile_app_shadys_iphone
    data:
      message: >
        {{ state_attr(trigger.to_state.entity_id, 'media_title') }} is playing from {{ state_attr(trigger.to_state.entity_id, 'app_name')}} on {{ trigger.to_state.name }}!
  mode: single

Perfect. Thank you so much!

That’s very helpful. Thnak you so much