I have an automation for controlling bathroom vent fans using a humidity sensor in the bathroom and a reference one outside it if you're interested. It also has logic to not turn off the fan if it has a Bluetooth speaker that's playing music (currently using the "Music Active" companion app sensor, Bluetooth MAC was flakey). And logic to turn it off if the AC is running and music isn't playing.