Bathroom fan automation with humidity and motion sensing

I was recently successful in implementing an automation using humidity telemetry to control a fan in a bathroom with only a shower in it. It will turn on the fan when humidity goes above a threshold and off when it comes below it. It will also turn off the fan after 60 minutes if it was turned on in a low humidity situation. I’ve done this for both the Aqara Zigbee sensor and the Xiaomi/Mijia BLE based sensor, the latter connecting via an ESP32 board, and am on the fence as to which one is more reliable.

Our other baths are a combination of toilet and shower and I’d like the fan to come on for x minutes minimum once it senses motion or longer if the humidity is higher than a threshold implying that said person decided to take a shower. Has anyone done something like this? If so, could you share what sensor(s) you used and the automation code? (I haven’t used motion sensors in the house yet)

Thanks