Object rotates fine in update but not in a different method

I’m trying to rotate a door with the following code, it works when the methods are called in Update but not in Interact, when done in Interact the door only rotates one way.
Also for some reason bool isOpen will get changed twice

//From answers.unity.com

    IEnumerator RotateMe(Vector3 byAngles, float inTime)
    {
       
        var fromAngle = transform.rotation;
        var toAngle = Quaternion.Euler(transform.eulerAngles + byAngles);
        for (var t = 0f; t <= 1; t += Time.deltaTime / inTime)
        {
            transform.rotation = Quaternion.Slerp(fromAngle, toAngle, t);
            yield return null;
        }
    }

//Rotates an object correctly when called in Update

void Update () {
     if(Input.GetKeyDown("e")){
     StartCoroutine(RotateMe(Vector3.up * 90, 0.8f));
     }
     if(Input.GetKeyDown("q")){
     StartCoroutine(RotateMe(Vector3.up * -90, 0.8f));
     }
   }


//Does not work when called in a method like so

   void Interact()
    {
        Debug.Log(tf.rotation.y);
        if (!isOpen)
            OpenDoor();
        if (isOpen)
            CloseDoor();
    }
   
    void CloseDoor()
    {
        StartCoroutine(RotateMe(Vector3.up * -90, 0.8f));
        isOpen = false;
        Debug.LogError(isOpen.ToString());
    }
    void OpenDoor()
    {
        StartCoroutine(RotateMe(Vector3.up * 90, 0.8f));
        isOpen = true;
        Debug.LogError(isOpen.ToString());
    }

//Interact method gets called like this

    void Update()
    {

        if (Input.GetKeyDown(KeyCode.E))
        {
            RaycastHit hit;

            if (Physics.Raycast(transform.position, cam.transform.forward, out hit, 10))
            {
                if (hit.collider.gameObject.tag == "Interactable")
                {
                    Debug.Log("Looking at interactable object" + hit.collider.gameObject.tag);
                    hit.collider.gameObject.SendMessageUpwards("Interact");
                    Debug.Log("Used interactable object");                   
                }
            }
        }
    }
}

You have a logic error in Interact(). On first use, assuming the door os closed it will call OpenDoor(), which sets isOpen to true. Once OpenDoor() returns, CloseDoor() is immediately called since isOpen is true and passes the if check. Try making it an if else if block.

You could also try moving the isOpen assignment to the end of the coroutines so it isn’t considered open or closed until it’s finished that action.

Thanks for catching that, I added a bool isOpening, I set it to true at the start of RotateMe and false at the end of it.
And in the two if statements instead of checking if the door is open it now checks for isOpen && !isOpening.