Might be possible with the Rules API, but there is another way to accomplish the time trigger using the Edge Counter Utility. The challenge for your Routine is that there is no trigger for just “changes” for the temperature. It must be “temperature is above” or “temperature is below” or “temperature in range” or “temperature is”.
For the time trigger, create a Routine to turn on a counter when the sensor opens. Then when the temperature changes and is above/below/in range AND the duration of the timer is at or above 5 mins, set the heat/cool temperature to a specific value delayed by 1 min.
Create a Routine to turn off the counter when the sensor closes.
If you don’t need the Routine to run locally on your hub, you might consider using a 3rd party rules engine like sharptools.io which offers triggers like “changes” and more complex evaluation logic.