Skip to content

Home Theater: Automating my subwoofer with Home Assistant and Node-RED

A while back, we decided to rearrange our living room, get new furniture, etc.  I took this opportunity to expand my home automation addiction and pull more items into Home Assistant.  My plan included running wiring through the ceiling for power and audio, automating my projector, screen, and subwoofer.   This how-to will outline how I’m controlling the power of my remotely mounted subwoofer all from a one-word activation with my Google Home, but more on that in another post. This is the first of multiple posts for automating my home theater experience.

Hardware

While my subwoofer’s power switch has an auto setting that is only supposed to turn on the amp when it’s getting signal from the receiver, this never really worked.  And as we rearranged the room, it’s new location did not allow it to be wired into the receiver’s builtin switched receptacle.  Thus, I needed a way to remotely control the sub being on or off.

Original Subwoofer

The Sonoff Basic is perfect for this job as you are switching 120v for the subwoofer’s power.  It does not matter which version of the Sonoff Basic you use (Original, R2, or R3) as they will perform the same here.  I have a half dozen R2s that came as part of a bulk order, so that’s what I used. Splicing the Sonoff into the subwoofer’s power cable was very straight forward.  All you have to do is cut the cable and insert the Sonoff in the middle, with the plug side of the cable wired to the input side of the Sonoff and the subwoofer side to the output side.

My installation of subwoofer with Sonoff spliced into the power cable

I chose to take a step further by disassembling my subwoofer and installing the Sonoff inside of the subwoofer.  This means it’s spliced on the power cable after the cable enters the subwoofer.  I used a couple of strong zip ties to mount the Sonoff, in its enclosure, to one of the sub’s metal components.

Sonoff mounted to the subwoofer amplifier

Firmware

The overall process is to flash this unit with custom firmware that tightly integrated to Home Assistant.  To get the unit converted from the original firmware, I used a USB FTDI converter combined with ESPHome to get this accomplished.  If you are not familiar with this process, JuanMTech and many others have great detailed steps for this part. Head over to your ESPHome dashboard and create a new device.  Paste the YAML below into the device configuration:

Add the device to Home Assistant

Now, go to the Home Assistant Integrations page (Configuration>Integrations). You should see the ESPHome device show up in the discovered section after a minute or two.  Click configure, and submit, and that’s it.  Alternatively, you can manually add the device by clicking “CONFIGURE” on the ESPHome integration and entering “<NODE_NAME>.local” as the host.

Once the device is added, it will be in the lower part of this page (under Configured).  Clicking through to the device will show you the entity names that are auto-magically created by the ESPHome integration.

Node-RED Automation

Now, you cannot be expected to have to switch on the subwoofer through Home Assistant like a barbarian!  So my fix for this is to automate it with the state of my receiver’s power.  This is a very easy automation to create in Node-RED, my automation engine for Home Assistant.

This automation is looking for any messages about the on/off state of my receiver (media_player.rx_v675) and then outputs that state through an on/off switch (splitter).  If the receiver state becomes on, the flow calls to turn on the subwoofer switch to on. You can copy and paste the JSON flow below to import it into your Node-RED instance.

Concerns

I had some initial concerns that the Sonoff would be subjected to stress/interference that could make it work incorrectly or breakdown faster.  However, after making this modification last May, I’ve had zero issues with this setup.  It just works. If you’ve got any questions, feel free to ping me below.

Published inESPHomeHome AssistantHome AutomationNode-RED
If I've helped yuy me a coffee If I've helped you, buy me a coffee