I have a Sonos Playbar connected to my TV. The living room TV is right under my daughter’s bedroom. If I forget to turn down the volume, the Playbar can be loud enough to wake her up when I turn on the TV. Using Homebridge and some iOS Home app automations, I was able to prevent this.
I love my Playbar. It can wirelessly stream music, it sounds way better than my TV speakers, and it looks great. The problem is that different steaming services seem to have widely different volume levels.
In my experience, Disney+ is super quiet and we have to crank up the volume. If I happen to watch Netflix after my daughter watched some Disney+, the Netflix intro sound could wake my daughter right out of a deep sleep.
Automation (in Theory)
Our TV is a Roku TV that is Homekit enabled, but the streaming service in use can’t be a trigger in automations. The only trigger that is available is when the TV turns on or off. I settled on resetting the volume to 10% when the TV turns off. Unfortunately, my Sonos system is too old to support Homekit. Even if it did support Homekit, the Home app can’t adjust the volume of a speaker. Luckily, there are Homebridge plugins that can add Homekit support and volume control to Sonos speakers.
Homebridge is an application that can integrate non-Homekit smart home accessories with the Home app. It allows control of accessories in the Home app that normally only support Alexa or Google Home. This also exposes those accessories to potential automations.
I installed Homebridge on a Raspberry Pi, but Homebridge supports Windows 10, Mac OS, Linux, Docker and a few other platforms (like a Synology NAS). I won’t go into installing Homebridge, but the Homebridge Wiki has great guides for installation on many different platforms. Once my Homebridge server was running, I installed the Homebridge ZP (zone player) plugin which supports volume control on the Sonos.
Setting Up the Automation
Since it’s non-native support, the plugin has to use workarounds to expose volume control in the Home app. To control the volume, Homebridge can expose the Sonos as a lightbulb or a fan. The brightness or fan speed is the volume of the Sonos (i.e. setting the Sonos “lightbulb” to 50% brightness sets the volume to 50%).
While a little janky, I set the plugin to create a lightbulb accessory for my Sonos. I setup the automation to set the “brightness” to 10% when I turn off the TV. Amazingly, it worked.
In the end, I ended up switching to a fan instead of a lightbulb. Just in case someone used Siri to turn on all the lights to full brightness, I didn’t want my Sonos to turn up to max volume.
I also added a second automation to change the volume when the TV was turned on as well. If I streamed some music with the TV off, the volume could be at a high level.
Finally, I set the TV on and TV off volumes to different levels (10% and 14%) to help diagnose a problem if one of my automations stopped firing.
I’ve been using these automations for a couple weeks now with a lot of success. I’m really happy how they’ve been able to manage the volume of my Sonos Playbar. Since this was so successful, I’m excited to experiment with other Homebridge plugins in the future.