Home assistant could potentially do it - many smart devices have api's that allow them to be controlled but depends on what you have.
At worst something like harmony elite or similar products have IR blasters that will do remote control inputs if there is no direct api interface - my stereo amp is controlled in that way as there is no smart integration so it turns it on via replicating its remote and switches it to the input, my tv, avr, subs etc all have direct integration so they're easy
It does look like blue sound has a home assistant plugin, but depend if you want that route
View attachment 28359
Have you tried this?
Bluesound Players can automatically switch the audio source to the externally connected Digital Input (Optical, Coaxial, or HDMI) when a valid signal is detected from a TV, CD Player, or any other ...
support1.bluesound.com