Question on the syntax of a sequence

I’ve been trying (unsuccessfully) to troubleshoot a fairly complex set of automations that call other scripts and pass data. The initial automation runs as far as I can tell from the Automations & Scenes page, but it never seems to get to the final script that outputs to tts.google_say.

Right now I’m getting hung up understanding the syntax of a sequence and I can’t find any documentation on it. What is the purpose of ‘who’, ‘where’, and ‘when’, when calling a script? Do I even need them? Here’s an example.

morning_briefing:
  sequence:
  - service: script.speech_engine
    data:
      who: living room
      when: 'morning'
      speech_message: !include ../templates/speech/briefing.yaml

Without being able to see the configuration of script.speech_engine we can only guess… but it looks like who is probably used to select an output device, when is probably used as part of some conditional logic to modify or select parts of the final message… and I don’t see a where.

I compiled this process from two different sources. One referenced the other, so there was some continuity there at least. The speech_engine script is below.

Here is how the process flow is supposed to work:

  1. If a motion sensor detects movement when the condition between two times is true, the morning and evening report automations run in their respective timeframes
  2. The morning and evening reports then call a morning or evening briefing script, respectively
  3. The morning/evening briefing scripts call the speech_engine script and pass the briefing (forecast, AQI, drive time, thermostat details, etc)
  4. The speech_engine script checks if people are in a ‘home’ state. If true, it calls the speech_processing script and passes the briefing from Step 3
  5. The speech_processing sets the speaker volume, speaks the briefing script, then turns off a few input booleans

speech_engine script:

# Define the "speech_engine" script
speech_engine:
  # Set the mode to "queued"
  mode: queued
  # Define the sequence of actions to be performed
  sequence:
    # If the state of the "group.family" entity is "home", proceed with the script
    - condition: or
      conditions:
        - condition: state
          entity_id: group.family
          state: home
        - condition: state
          entity_id: binary_sensor.waking_hours
          state: "on"
    # Run the "script.speech_processing" service with the specified media player and speech message
    - service: script.speech_processing
      data:
        # Set the entity ID for the media players to be controlled
        # If the "media_player" variable is not defined, set it to a list of media player entities
        # If the "media_player" variable is a list, convert it to a comma-separated string
        media_player: >-
           {% if media_player | length == 0 %}
             {% set media_player = [
              'media_player.nesthubmaxec28',
              'media_player.bedroom_display'
             ] %}
           {% endif %}
           {% if media_player is not string and media_player is sequence %}
             {% set media_player = media_player|join(', ') %}
           {% endif %}
           {{ media_player }}
        # Include the speech message from the "templates/speech/briefing.yaml" template file
        speech_message: !include ../templates/speech/briefing.yaml

The speech_engine script does not seem to utilize any of the variables being passed by morning_briefing, so at this point they are pointless.