Want to control variable speed of bathroom fan in HA

my bathroom fan has a Hi and Low speed controlled by moving the pin header jumper over. currently speed is set to low and by moving the pin head over it goes to Hi. is there any way I can automate this, say using an esp32 or something. Any help would be much appreciated

Something like this would do (you only need one relay, as the center pin would be the common on the relay)


https://nl.aliexpress.com/item/1005006220264799.html?src=google

I got one of those lying around actually. makes sense now. :sweat_smile: thanks