Recently got a Sonos soundbar with no support for bluetooth or audio input other than HDMI. Wanted to be able to play music from my turntable to the soundbar, so I had to figure out an alternative way to do this.
Stumbled upon Add Aux to Sonos Using Raspberry Pi - Instructables and Sonos ↔ Vinyl // stevegattuso. I had a spare Raspberry Pi and Behringer USB sound card so I installed Pi OS Lite, darkice and icecast2. This gave me a working audio stream which was exposed locally on the RPi.
Then I just needed to send this audio stream to Sonos. Thought that would be challenging, but it wasn’t at all. Figured out it’s possible to use the “Media player: Play media” action in HomeAssistant to play the turntable audio stream with the Sonos speaker as a target. Wanted to join in another speaker and set the default volume, so I made a script for that. See below:
script
alias: Play turntable on Sonos
sequence:
- data:
volume_level: 0.2
target:
entity_id:
- media_player.living_room
- media_player.dining_room
action: media_player.volume_set
- data:
group_members:
- media_player.dining_room
action: media_player.join
target:
entity_id:
- media_player.living_room
- data:
media_content_id: http://192.168.1.101:8000/turntable.mp3.m3u
media_content_type: music
target:
entity_id: media_player.living_room
action: media_player.play_media
icon: mdi:album
So by starting the script above, it would use the audio stream as a source for the Sonos group. Perfect! But if I were to play music from Spotify or another source on the speakers, it would “break” the audio stream source. And I don’t want to manually start the script each time I play something on the turntable.
The tonearm moves automatically to the starting position when physically pressing “play” on the turntable. So this movement indicates it’s starting. But how to catch this as a sensor value? Maybe a door/window sensor? As a quick proof of concept I attached a door/window sensor from Aqara with some rubber bands and made an automation with this as a trigger. When the sensor value is “open”, it runs the script above.
I think I’ll just keep this proof of concept as-is for now