Auto change output device when connected/disconnected

Hi, I’m using AudioRelay with BlackHole as my virtual device.
It would be great if the app can automatically switch the output device to BlackHole on connection and then switch back to MacBook Speakers on disconnection. (instead of doing it manually from audio midi setup)

I am currently using an utility called switchaudio-osx and Shortcuts to automate it on starting and closing the app

This is what my shortcut looks like. The problem is that I can’t switch to MacBook speakers automatically when my phone is disconnected and I’ll have to close the AudioRelay app to do so.