The Ray can only play whatever sound signal is sent to it. If the Ray is connected to the TV, it should play the TV sound, regardless of which input the tv has selected.
You may need to check the sound output settings on the tv, rather than looking to the Ray as the culprit.
What tv make and model do you have?
Its a Panasonic TX-55C320B. Its a few years old now right enough but would think should still be up to the job.
I’m about to go out but had a quick look at the manual - page 12 seems most relevant. Check your audio out and CEC settings.
Does it happen often enough that you could temporarily disconnect the Ray and/or change the Tv settings to output to the tv speakers and see if the same thing happens using the TV speakers? It could be a hdmi handshake issue between the devices and the Tv when you change inputs.
In the past I would have occasional issues where changing hdmi inputs with my Avr would cause a loss of sound. Something in the hdmi handshake when switching would randomly not work properly and while I’d get a picture I’d get no sound until either changing to a different input which didn’t use hdmi or in worse cases no picture either and if the input changing didn’t resolve it I would need to remove the Avr power.
Even now my PC will occasionally get its sound settings in a mess with my current tv if I change the tv input while it is on.
Thanks for the advice but I think I have tried everything and its always the same. Im begining to hate my TV and my Sonos.