Building a physical volume controller for Home Assistant using ESPHome

Disclosure: This post contains affiliate links. If you click through and make a purchase, I will earn a commission, at no additional cost to you. Read my full disclosure here.

Today, we'll dive into an intriguing project conceived and coded by GitHub user adamaze. It's a nifty, hands-on volume knob for every media entity within Home Assistant. As this invention leans on ESPHome, it slots into Home Assistant without a hitch, enabling you to manipulate the sound levels of any media gadget linked to Home Assistant.

A physical volume controller for Home Assistant using ESPHome

Get your ESPHome inspiration here

Being an ESPHome enthusiast, I'm always on the prowl for fresh projects, and I reckon you're in the same boat. Hence, I'm kicking off a series of featured ESPHome projects. These aren't my brainchildren, but rather the fruit of the collective genius of the Home Assistant and ESPHome community.

Gathering your ESPHome volume controller essentials

As is standard with the majority of ESPHome projects, the engine behind this one is a LOLIN D1 mini board. This board, in turn, is driven by the ESP8266 microchip. Affixed to it is a free-spinning rotary encoder with a push button, which will orchestrate the volume's increase and decrease. The free-spinning aspect ensures the controller doesn't need to march to the beat of Home Assistant.

The priciest component of this DIY endeavour is probably the 3D printer. If you don't boast one in your tech arsenal already, you'll need to invest in one. However, rest assured this won't be a one-hit wonder in your project line-up. Favoured 3D printers among the crowd are those from Ender 3 series. It's worth your while to peruse some reviews before making your pick.

Aside from that, your shopping list should include a soldering iron, solder wire, and a handful of isolated wires. To power and establish a connection to the ESP8266, you'll need a Micro-USB cable and, if you prefer, a power supply.

How the physical volume controller functions

If you apply the code shared by adamaze, this volume controller isn't simply a one-trick pony. It's got five tricks up its sleeve:

The beauty of this project lies in its simplicity. All you need to bring these functions to life are just over a hundred lines of YAML. Plus, there's no need for you to install any automation or script in Home Assistant. A total win-win!

How to build the physical volume controller

As mentioned, this project's casing will be crafted using a 3D printer, thanks to adamaze, who has generously provided the .stl files in his GitHub repositoryy. The first task is to get the rotary encoder attached to the ESP8266 board. This will require four wires in total – two for the rotary encoder, one for the button, and one for ground. Once that's done, this piece can be fitted onto the case's lid. The D1 mini ESP8266 board will comfortably nestle in the lower section of the case, drawing power from the Micro-USB input.

Adjusting the code

The existing code presumes that you've stored your Wi-Fi SSID and password in the secrets.yaml file. If that isn't the case, or if you use different descriptors, then you'll need to tweak that bit of the code.

You'll also need to specify the speaker that this device will control. The current version of the code is set up for a speaker named media_player.kitchen_speakers, but your setup will obviously differ. You might also consider changing the node's name and the individual IDs for a more personalized touch.

The code leverages the homeassistant.service action, a nifty feature that allows an ESPHome device to carry out Home Assistant commands. In layman's terms, this means you don't have to set up any automation or script for the volume control—pretty neat, right? Plus, you can completely customize the long-press function to your preference.

A portrait photo oif Liam Alexander Colman, the author, creator, and owner of Home Assistant Guide wearing a suit.

About Liam Alexander Colman

is an experienced Home Assistant user who has been utilizing the platform for a variety of projects over an extended period. His journey began with a Raspberry Pi, which quickly grew to three Raspberry Pis and eventually a full-fledged server. Liam's current operating system of choice is Unraid, with Home Assistant comfortably running in a Docker container.
With a deep understanding of the intricacies of Home Assistant, Liam has an impressive setup, consisting of various Zigbee devices, and seamless integrations with existing products such as his Android TV box. For those interested in learning more about Liam's experience with Home Assistant, he shares his insights on how he first started using the platform and his subsequent journey.

Leave a comment

Share to...