Best answer by Airgetlam
First, whatever source you're playing on the TV (cable, DVD, bluray, whatever) needs to have the audio settings checked to make sure that they're set to Dolby Digital. Not Dolby Digital Plus, or DTS, or Dolby Atmos, just Dolby Digital (or Stereo/PCM).
Once you've locked down the source device, you should then look at the audio settings on the TV set itself, and make sure that it is also set to pass through Dolby Digital. While you're in the audio settings for your TV (and what make and model is it?) you should make sure that the optical port is turned on. There are some TVs that allow the optical port to be on or off, you want to be sure it's on. You may also want to check that the signal is set to "fixed" rather than "variable" if your TV has that setting.
Once you've done those two things, then pull the optical cable out of the back of the PLAYBAR/PLAYBASE/Beam, and check to see that there's a red light coming out of the cable. Might be worth making sure that there's no "cap" on the center of the cable, sometimes they come with little clear rubber tips that can cover the tip, but still allow the cable to be inserted.
Then reconnect the cable to the back of the PLAYBAR/PLAYBASE/Beam, and keep playing the Dolby Digital signal, whatever that is. Then go in to the controller app, and go to settings>About My Sonos system and look at the line that says "Audio In:" under the PLAYBAR/PLAYBASE/Beam's data, and see what that says.
That should be a start. Let us know how you get on.