Automations based on rate of humidity increase

I have had a humidity sensor near my shower for quite a while, but never got it to trigger my bathroom fan nicely. The problem is that the baseline humidity changes day to day and throughout the year, so establishing a rule based on a fixed humidity never worked well. What I’d like is a rule that triggers if the humidity has increase by x% in a span of y minutes or less, and then I would like it to run until the humidity reach (x-1)% less than the present humidity. Does anyone know how to make this happen?

Thanks,
B