Late last year, I got a Sonos setup for my living room. I chose the Premium Immersive Set, which includes:
- Arc Soundbar
- 2 × One SL rear surrounds
- Their third-generation Subwoofer
I cannot overstate how great this system sounds. Surely better can be had, but Sonos makes everything so simple. Furthermore, their ability to pipe audio from anywhere to anywhere makes AirPlay 2 look positively barbaric by comparison. Truly. I say this as a person who makes a living talking about how much I love Apple.
Sonos has a couple of really useful features when you’re watching television.
- Night Sound: At lower volumes, quiet sounds will be enhanced and loud sounds will be suppressed
- Speech Enhancement: Increases the volume of speech
These features are super great for nighttime viewing, particularly when your living room is directly below your son’s bedroom. Together, the Sonos will tone down the loud booms that are most likely to wake him up, but also bring up the relative volume of speech, so we don’t need to rely on subtitles.
As great as this is, I never remember to turn them off; instead, I attempt to watch TV the following day — often to watch a guided workout with music behind it — and wonder why everything sounds so wonky. Though it only takes a couple seconds to pop open the app and turn off Night Sound & Speech Enhancement, it gets old when you do it every day. There must be a way to automate switching these off, right?
One of the great things about being a nerd developer is that you can pretty
quickly put together a few tools to make something happen. Last night, I figured
I’d start digging into the Sonos API and see if I could whip something up.
Thankfully, after only a few minutes down that path, I realized there must be
something futher up the stack that I could use.
Enter SoCo-CLI
, which is a command-line front-end to SoCo
.
SoCo-CLI
allows you to do a stunning amount of things with your Sonos
system via the command-line.
For me, I needed to do two things, both of which are easily accomplished using
SoCo-CLI
. Note that my system is called Living Room
, but SoCo-CLI
is
smart enough to match my speaker name by prefix only — Liv
is
automatically parsed to mean Living Room
. With that in mind:
I needed to turn off speech enhancement:
sonos Liv dialogue_mode off
I needed to turn off night sound:
sonos Liv night off
I can also combine these into one command in SoCo-CLI
:
sonos Liv dialogue_mode off : Liv night off
Now I just needed to run this overnight every night. I turned to my trusty Raspberry Pi, which is in my house and always on. I added a new line to my crontab:
0 3 * * * /home/pi/.local/bin/sonos Liv dialogue_mode off : Liv night off
Now, every night at 3 AM, my Raspberry Pi will ask the Sonos to turn off both night sound & speech enhancement. I never have to worry about remembering again, and my workouts in the morning will no longer sound off.
🤘🏻