How can I setup a variable off timer based on time on from another switch?

I'm trying to control my bathroom fans based on how long the light switch is on. For example, if the light switch is on for 3 minutes or less, turn off fan as soon as light turns off, but if Light is on longer than that run fan for 10 mins, etc. How would I approach this?

I wrote this rule a while back to track cumulative time:

Screenshot_2021-05-03 cumulative time (Paused)

Screenshot_2021-05-03 cumulative time (Paused)(1)

(The whole "12:00" section corrects the time when midnight is passed during the "on" time.)

"TimePassed" winds up containing the cumulative time in minutes, which you could then use in your rule to determine the fan run time.

Thanks for the idea! I think my abilities are not yet advanced enough to figure that one out tho. I ended up using 3 rules to pull this off and it works for me. May not be the most elegant solution, but it's functional.

Rule 1 Turns Fan on with Light
on

Rule 2 is the normal default rule to turn light off instantly when the Light turns off
instant off

Rule 3 takes place if the light has been on more than 3 minutes. Then the first rule, the rule that turned the light and fan on, pauses the 2nd rule, the one that turns the fan off instantly, which allows this rule to do its thing, which turns off the light after 10 minutes.
timed off

I had to add some cancel timers and things so it would all reset if it was interrupted, but its working for my needs. Eventually I'll revise them some when I get some humidity sensors in there to control the fan a bit better.