Automation trigger Entity ID not showing up in action template

I have 3 Team Tracker sensors and have 1 automation that triggers when a game ends. I can’t seem to coax the template into producing the correct output in a notification:

"Final score {{ state_attr( "{{ trigger.entity_id }}" , "team_score") }} {{ state_attr("{{ trigger.entity_id }}", "team_name") }} - {{ state_attr("{{ trigger.entity_id }}", "opponent_score") }} {{ state_attr("{{ trigger.entity_id }}", "opponent_name") }}.

Just shows up as:

Final score None None - None None.

In the editor, I’ve tested using the following:

{% set trigger = {
  "platform": "state",
  "entity_id": "sensor.nfl_seattle_seahawks",
  "from_state": states.sensor.nfl_seattle_seahawks,
  "to_state": states.sensor.nfl_seattle_seahawks,
  "id": "1",
  "idx": "1"
} %}

Entity that changed: {{ trigger.entity_id }}
New state: {{ trigger.from_state.state }}

{{ state_attr("sensor.nfl_seattle_seahawks", "team_score") }}
{{ state_attr("{{ trigger.entity_id }}", "team_score") }}

Which outputs:

Entity that changed: sensor.nfl_seattle_seahawks
New state: POST

21
None

I don’t get why the state_attr template does not pull in the trigger’s entity_id? I’ve also tried {{ trigger.from_state.entity_id }} and {{ trigger.to_state.entity_id }} with no success.

Full Automation Trace
{
  "trace": {
    "last_step": "action/2",
    "run_id": "c53472fa0ac5c1966a15626f99b195e4",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2026-11-14T20:41:53.444127+00:00",
      "finish": "2026-11-14T20:56:54.076803+00:00"
    },
    "domain": "automation",
    "item_id": "1794097204900",
    "trigger": "state of sensor.nhl_seattle_kraken",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2026-11-14T20:41:53.444183+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.outdoor_lights_game_ended",
              "state": "on",
              "attributes": {
                "id": "1794097204900",
                "last_triggered": "2026-11-12T19:48:40.499242+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Outdoor Lights - Game Ended"
              },
              "last_changed": "2026-11-14T15:52:22.169152+00:00",
              "last_reported": "2026-11-14T15:52:22.169152+00:00",
              "last_updated": "2026-11-14T15:52:22.169152+00:00",
              "context": {
                "id": "01M7DC4ZWS8FA3Q0KX8BCK2JVC",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "state",
              "entity_id": "sensor.nhl_seattle_kraken",
              "from_state": {
                "entity_id": "sensor.nhl_seattle_kraken",
                "state": "IN",
                "attributes": {
                  "attribution": "Data provided by ESPN",
                  "state": "IN",
                  "sport": "hockey",
                  "sport_path": "hockey",
                  "league": "NHL",
                  "league_path": "nhl",
                  "league_logo": "https://a.espncdn.com/i/teamlogos/leagues/500/nhl.png",
                  "league_name": "National Hockey League",
                  "season": "regular-season",
                  "alt_game_note": null,
                  "team_abbr": "SEA",
                  "opponent_abbr": "CAR",
                  "event_id": "401891809",
                  "event_name": "SEA @ CAR",
                  "event_url": "https://www.espn.com/nhl/game/_/gameId/401891809",
                  "event_stream": null,
                  "date": "2026-11-14T18:00Z",
                  "kickoff_in": "2 hours ago",
                  "series_summary": null,
                  "venue": "Veikkaus Arena",
                  "location": "Helsinki, Finland",
                  "tv_network": "NHL Net/CARNHL/KONG/Prime Video (Local)",
                  "odds": null,
                  "overunder": null,
                  "team_name": "Kraken",
                  "team_long_name": "Seattle Kraken",
                  "team_id": "124292",
                  "team_record": "9-7-1",
                  "team_rank": null,
                  "team_conference_id": null,
                  "team_homeaway": "away",
                  "team_logo": "https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/sea.png",
                  "team_url": "https://www.espn.com/nhl/team/_/name/sea/seattle-kraken",
                  "team_stream": null,
                  "team_colors": [
                    "#000d33",
                    "#a3dce4"
                  ],
                  "team_score": "1",
                  "team_win_probability": 0,
                  "team_winner": null,
                  "team_timeouts": null,
                  "opponent_name": "Hurricanes",
                  "opponent_long_name": "Carolina Hurricanes",
                  "opponent_id": "7",
                  "opponent_record": "15-3-2",
                  "opponent_rank": null,
                  "opponent_conference_id": null,
                  "opponent_homeaway": "home",
                  "opponent_logo": "https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/car.png",
                  "opponent_url": "https://www.espn.com/nhl/team/_/name/car/carolina-hurricanes",
                  "opponent_stream": null,
                  "opponent_colors": [
                    "#e30426",
                    "#000000"
                  ],
                  "opponent_score": "5",
                  "opponent_win_probability": 0,
                  "opponent_winner": null,
                  "opponent_timeouts": null,
                  "quarter": 3,
                  "clock": "End of 3rd",
                  "possession": null,
                  "last_play": "End of 3rd Period",
                  "down_distance_text": null,
                  "outs": null,
                  "balls": null,
                  "strikes": null,
                  "on_first": null,
                  "on_second": null,
                  "on_third": null,
                  "team_shots_on_target": 14,
                  "team_total_shots": null,
                  "opponent_shots_on_target": 35,
                  "opponent_total_shots": null,
                  "team_sets_won": null,
                  "opponent_sets_won": null,
                  "last_update": "2026-11-14 12:40:48-08:00",
                  "api_message": null,
                  "api_url": "https://site.api.espn.com/apis/site/v2/sports/hockey/nhl/scoreboard?lang=en&limit=50",
                  "private_fast_refresh": true,
                  "icon": "mdi:hockey-puck",
                  "friendly_name": "NHL - Seattle Kraken"
                },
                "last_changed": "2026-11-14T20:04:44.593188+00:00",
                "last_reported": "2026-11-14T20:40:48.487141+00:00",
                "last_updated": "2026-11-14T20:40:48.487141+00:00",
                "context": {
                  "id": "01M7DWN4K7TTBF5BMECBEHEMT2",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sensor.nhl_seattle_kraken",
                "state": "POST",
                "attributes": {
                  "attribution": "Data provided by ESPN",
                  "state": "POST",
                  "sport": "hockey",
                  "sport_path": "hockey",
                  "league": "NHL",
                  "league_path": "nhl",
                  "league_logo": "https://a.espncdn.com/i/teamlogos/leagues/500/nhl.png",
                  "league_name": "National Hockey League",
                  "season": "regular-season",
                  "alt_game_note": null,
                  "team_abbr": "SEA",
                  "opponent_abbr": "CAR",
                  "event_id": "401891809",
                  "event_name": "SEA @ CAR",
                  "event_url": "https://www.espn.com/nhl/game/_/gameId/401891809/kraken-hurricanes",
                  "event_stream": null,
                  "date": "2026-11-14T18:00Z",
                  "kickoff_in": "2 hours ago",
                  "series_summary": null,
                  "venue": "Veikkaus Arena",
                  "location": "Helsinki, Finland",
                  "tv_network": "NHL Net/CARNHL/KONG/Prime Video (Local)",
                  "odds": null,
                  "overunder": null,
                  "team_name": "Kraken",
                  "team_long_name": "Seattle Kraken",
                  "team_id": "124292",
                  "team_record": "9-7-1",
                  "team_rank": null,
                  "team_conference_id": null,
                  "team_homeaway": "away",
                  "team_logo": "https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/sea.png",
                  "team_url": "https://www.espn.com/nhl/team/_/name/sea/seattle-kraken",
                  "team_stream": null,
                  "team_colors": [
                    "#000d33",
                    "#a3dce4"
                  ],
                  "team_score": "1",
                  "team_win_probability": null,
                  "team_winner": false,
                  "team_timeouts": null,
                  "opponent_name": "Hurricanes",
                  "opponent_long_name": "Carolina Hurricanes",
                  "opponent_id": "7",
                  "opponent_record": "15-3-2",
                  "opponent_rank": null,
                  "opponent_conference_id": null,
                  "opponent_homeaway": "home",
                  "opponent_logo": "https://a.espncdn.com/i/teamlogos/nhl/500/scoreboard/car.png",
                  "opponent_url": "https://www.espn.com/nhl/team/_/name/car/carolina-hurricanes",
                  "opponent_stream": null,
                  "opponent_colors": [
                    "#e30426",
                    "#000000"
                  ],
                  "opponent_score": "5",
                  "opponent_win_probability": null,
                  "opponent_winner": true,
                  "opponent_timeouts": null,
                  "quarter": 3,
                  "clock": "Final",
                  "possession": null,
                  "last_play": null,
                  "down_distance_text": null,
                  "outs": null,
                  "balls": null,
                  "strikes": null,
                  "on_first": null,
                  "on_second": null,
                  "on_third": null,
                  "team_shots_on_target": null,
                  "team_total_shots": null,
                  "opponent_shots_on_target": null,
                  "opponent_total_shots": null,
                  "team_sets_won": null,
                  "opponent_sets_won": null,
                  "last_update": "2026-11-14 12:40:53-08:00",
                  "api_message": null,
                  "api_url": "https://site.api.espn.com/apis/site/v2/sports/hockey/nhl/scoreboard?lang=en&limit=50",
                  "private_fast_refresh": false,
                  "icon": "mdi:hockey-puck",
                  "friendly_name": "NHL - Seattle Kraken"
                },
                "last_changed": "2026-11-14T20:40:53.443074+00:00",
                "last_reported": "2026-11-14T20:40:53.443074+00:00",
                "last_updated": "2026-11-14T20:40:53.443074+00:00",
                "context": {
                  "id": "01M7DWN9E34DAQPYNE57XDJM95",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": {
                "__type": "<class 'datetime.timedelta'>",
                "total_seconds": 60
              },
              "attribute": null,
              "description": "state of sensor.nhl_seattle_kraken"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2026-11-14T20:41:53.444612+00:00",
          "changed_variables": {
            "context": {
              "id": "01M7DWQ414AH9SVSBWQBKD9F54",
              "parent_id": "01M7DWN9E34DAQPYNE57XDJM95",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "notify",
              "service": "send_message",
              "service_data": {
                "title": "Game is over!",
                "message": "Final score None None - None None.",
                "entity_id": [
                  "notify.mobile_app_galaxy"
                ]
              },
              "target": {
                "entity_id": [
                  "notify.mobile_app_galaxy"
                ]
              }
            },
            "running_script": false
          }
        }
      ],
      "action/1": [
        {
          "path": "action/1",
          "timestamp": "2026-11-14T20:41:53.640416+00:00",
          "result": {
            "delay": 900,
            "done": true
          }
        }
      ],
      "action/2": [
        {
          "path": "action/2",
          "timestamp": "2026-11-14T20:56:53.642717+00:00",
          "result": {
            "params": {
              "domain": "light",
              "service": "set_effect",
              "service_data": {
                "effect": "Fall",
                "entity_id": [
                  "light.permanent_lights_pro"
                ]
              },
              "target": {
                "entity_id": [
                  "light.permanent_lights_pro"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1794097204900",
      "alias": "Outdoor Lights - Game Ended",
      "description": "",
      "triggers": [
        {
          "trigger": "state",
          "entity_id": [
            "sensor.nhl_seattle_kraken"
          ],
          "to": [
            "POST"
          ],
          "for": {
            "hours": 0,
            "minutes": 1,
            "seconds": 0
          }
        },
        {
          "trigger": "state",
          "entity_id": [
            "sensor.nfl_seattle_seahawks"
          ],
          "to": [
            "POST"
          ],
          "for": {
            "hours": 0,
            "minutes": 1,
            "seconds": 0
          }
        },
        {
          "trigger": "state",
          "entity_id": [
            "sensor.nwsl_seattle_reign_fc"
          ],
          "to": [
            "POST"
          ],
          "for": {
            "hours": 0,
            "minutes": 1,
            "seconds": 0
          }
        }
      ],
      "conditions": [],
      "actions": [
        {
          "action": "notify.send_message",
          "metadata": {},
          "target": {
            "entity_id": [
              "notify.mobile_app_galaxy"
            ]
          },
          "data": {
            "title": "Game is over!",
            "message": "Final score {{ state_attr(\"{{ trigger.from_state.entity_id }}\", \"team_score\") }} {{ state_attr(\"{{ trigger.from_state.entity_id }}\", \"team_name\") }} - {{ state_attr(\"{{ trigger.from_state.entity_id }}\", \"opponent_score\") }} {{ state_attr(\"{{ trigger.from_state.entity_id }}\", \"opponent_name\") }}."
          },
          "enabled": true,
          "continue_on_error": true
        },
        {
          "delay": {
            "hours": 0,
            "minutes": 15,
            "seconds": 0,
            "milliseconds": 0
          }
        },
        {
          "action": "light.set_effect",
          "metadata": {},
          "target": {
            "entity_id": "light.permanent_lights_pro"
          },
          "data": {
            "effect": "{{ states(\"input_text.outdoor_lights_default_effect\") }}"
          }
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01M7DWQ414AH9SVSBWQBKD9F54",
      "parent_id": "01M7DWN9E34DAQPYNE57XDJM95",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Outdoor Lights - Game Ended",
      "message": "triggered by state of sensor.nhl_seattle_kraken",
      "source": "state of sensor.nhl_seattle_kraken",
      "entity_id": "automation.outdoor_lights_game_ended",
      "context_id": "01M7DWQ414AH9SVSBWQBKD9F54",
      "item_id": "1794097204900",
      "run_id": "c53472fa0ac5c1966a15626f99b195e4",
      "domain": "automation",
      "when": 1794688913.4442472
    },
    {
      "state": "2026-11-14T20:41:53.639660+00:00",
      "entity_id": "notify.mobile_app_galaxy",
      "when": 1794688913.639694,
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Outdoor Lights - Game Ended",
      "context_message": "triggered by state of sensor.nhl_seattle_kraken",
      "context_source": "state of sensor.nhl_seattle_kraken",
      "context_entity_id": "automation.outdoor_lights_game_ended"
    }
  ]
}
{{ state_attr("{{ trigger.entity_id }}", "team_score") }}

First, in the above template, you are asking for the value of the team_score attribute of the entity “{{ trigger.entity_id }}”… not the rendered value of the template {{ trigger.entity_id }}… by using quote marks you are saying the entity ID string is “{{ trigger.entity_id }}”. Since that’s not a valid entity ID, the state_attr() function returns None.

Second, nested delimiters are not allowed, just use the variable.

Also, there’s no reason to query the state object with state_attr(), when the trigger variable already has that data…

"Final score {{ trigger.to_state.attributes.team_score }} {{ trigger.to_state.attributes.team_name }} - 
{{ trigger.to_state.attributes.opponent_score }} {{ trigger.to_state.attributes.opponent_name }}."

That worked, thank you! I didn’t realize I could just get the attribute directly, that’s much cleaner.