Can't access Trigger data in an automation

I’m trying to create a simple automation that “pauses” my Sonos Connect whenever anyone changes the input source on my Onkyo amp to something other than “Livingroom Sonos.” Although I’m pretty new to HA, the docs make it seem like a simple matter of comparing trigger.from_state.attributes.source to trigger.to_state_attributes.source to look for a change. The problem is, I can’t even get access to the to_state and from_state when writing to the logbook. For instance, this code:

- alias: "Trigger for pausing Sonos when Livingroom Onkyo changes source of input"
  trigger:
    platform: event
    event_type: state_changed
    event_data:
      entity_id: media_player.onkyo
  action:
    - service: logbook.log
      data_template:
        name: Onkyo/LR Sonos 
        message: "The event changed the Onkyo from {{ trigger.from_state }} to {{ trigger.to_state }}"

results in the following being written to the logbook:

Onkyo/LR Sonos The event changed the Onkyo from to

If I modify the line in my YAML slightly so to access “trigger” then the following is written to the logbook:

...

message: "The event changed the Onkyo from {{ trigger }} to {{ trigger.to_state }}"

then the output to the logbook is:

Onkyo/LR Sonos The event changed the Onkyo from {‘platform’: ‘event’, ‘event’: <Event state_changed[L]: entity_id=media_player.onkyo, old_state=<state media_player.onkyo=on; volume_level=0.32, is_volume_muted=False, source=video6_pc, source_list=[‘Satallite Box’, ‘Network Music’, ‘AppleTV 4K’, ‘Livingroom Sonos’], video_out=yes,out, friendly_name=Onkyo, supported_features=20364 @ 2019-03-08T08:27:46.314441-08:00>, new_state=<state media_player.onkyo=on; volume_level=0.32, is_volume_muted=False, source=video4_aux1, source_list=[‘Satallite Box’, ‘Network Music’, ‘AppleTV 4K’, ‘Livingroom Sonos’], video_out=yes,out, friendly_name=Onkyo, supported_features=20364 @ 2019-03-08T08:27:46.314441-08:00>>} to

And, of course, the thing that I really want to do:

- alias: "Trigger for pausing Sonos when Livingroom Onkyo changes source of input"
  trigger:
    platform: event
    event_type: state_changed
    event_data:
      entity_id: media_player.onkyo
  condition:
    condition: and
    conditions:
      - condition: template
        value_template: '{{ trigger.from_state.attributes.source == "Livingroom Sonos" }}'
      - condition: template
        value_template: '{{ trigger.to_state.attributes.source != "Livingroom Sonos" }}'
  action:
    - service: media_player.media_stop
      data:
        entity_id: media_player.living_room_2

doesn’t do anything.

What is it that I don’t understand?

Have you tried platform: state instead?
trigger.from_state, to_state, etc. are used with the state object which is different from the event object as you found out.
Available trigger data

Excellent! I knew that I was going to feel foolish once someone pointed out my mistake; so, at least I was right about one thing.

In case anyone is curious, here is my updated/working automation:

# make sure to pause sonos when user switches Onkyo source input from Sonos to something else
- alias: "Trigger for pausing Sonos when Livingroom Onkyo changes source of input"
  trigger:
    platform: state
    entity_id: media_player.onkyo
  condition:
    - condition: template
      value_template: '{{ trigger.from_state.attributes.source == "Livingroom Sonos" }}'
    - condition: template
      value_template: '{{ trigger.to_state.attributes.source != "Livingroom Sonos" }}'
  action:
    - service: logbook.log
      data_template:
        name: Onkyo/LR Sonos
        message: "The event changed the Onkyo from {{ trigger.from_state.attributes.source }} to {{ trigger.to_state.attributes.source }}"
    - service: media_player.media_stop
      data:
        entity_id: media_player.living_room_2