Hi, @jandamm. I just tested @noisneil's clever macro with that tricky System Setting because I have experience with it from the time I was developing Set Sound Output.
FYI: I considered using switchaudio-osx, but I discovered some limitations that motivated me to create Set Sound Output.