Engage party mode
I have been using Home Assistant for a while to automate my house, and have also been using ESPhome to add automation to the devices that don't normally have automation. In my office, I have the following connected to Home Assistant:
- My overhead lights are on a smart dimmer switch
- My server cabinet has temperature sensors and automated fans, controlled via an ESP32/ESPhome
- My monitors have bias lighting behind them with patterns controlled by an ESP32/ESPhome
- Just outside my office is an indicator to my family, giving them a heads up of what I'm doing in the office, controlled via ESP32/ESPhome
These have been great, but switching all of those individually for different work contexts is tedious. For example, when I step into a meeting, I want my overhead lighting to be dimmer, my server rack's fans to turn off, my bias lighting set to give me better lighting, and my status screen to give people a heads up that they're about to be on camera if they walk in. I also expect to have more devices in the future, which will make this process more tedious. Obviously, the only solution is to throw more ESPhome at it!
The idea
I'd like to have a physical controller that could toggle between the 4 main states that my office is in (off/unused, goofing off, working, on a video call). After thinking about a couple of different ideas, I decided a 4-position rotary switch would be compact and still have that satisfying tactile feel.
The hardware
There are a couple of ways that I could have built this, but I decided on a 3D printed case in 2 parts: a base that held the ESP32 board, which slid inside of a shell that holds some indicator LEDs and the switch. After a trip through my parts bin, I found everything but the switch. A bit of trial-and-error with printing the case, and I had everything I needed.
Some day I'll get my model right on the first try, but it is not this day
I thought about a couple of ways to attach everything to the case, and decided to use hot-melt glue, since it was fast and easy, and least likely for me to mess up and, say, glue myself to the project.
Do I recommend this for your project? Hell no! But it did mean that I didn't have to think about making posts in my print or mess with heat-set inserts, so
I tied all of the LED ground lines together, connected them to the center post of the switch, and connected that to the ground pin of the ESP32. I then brought each positive line from the LEDs and each position from the switch out to the relevant pins on the ESP32.
Snarky comments on my soldering skills welcome
I left the wires a bit longer so that I could open this back up in the future. I don't expect to get back inside this, but it's good to know that I have the option without breaking things. With that in mind, I zip-tied the wires together and glued the bundle in place to encourage the wires to coil how I wanted and to take any strain off of the delicate resistors.
If you're having power problems I feel bad for you son; I got 99 problems and hot glue ain't one.
Also, hell yes I soldered directly to the ESP's pins #YOLO
The software
Once everything was built, I built a pretty straightforward program in ESPhome. Basically, it's 4 binary switches, 4 monochromatic lights, and 4 outputs. When one of the switches is flipped to "on" for more than 200ms, the indicator light that was previously on turns off, and the indicator at the new position turns on.
Inside of Home Assistant, I then created 4 different scenes, which set the different devices how I want them, and then created 4 automations to watch for each switch to activate, which then triggers the appropriate scene. Related, if someone knows an easier way to do this, I'm all ears--I like the idea of creating scenes so I can trigger them from more than this device, but adding 4 automations to the mix feels like annoying overkill.
The result
View attachment switch.mp4
This works much better than I thought it would. The switch is super clicky, and the delay between changing states is perfect to allow jumping directly to any state that I want. I would like to have made this entire unit heavier so that it wouldn't slide around, but it's heavy enough to generally toggle one-handed and I don't imagine I'll be knocking it off my desk. The automation seems pretty bulletproof so far, immediately setting everything as it should. Managing everything through Home Assistant scenes seems like it'll be helpful, because I plan to add more devices in the future, and I'll be able to do so without messing with ESPhome or programming--I just add it to the relevant scene and I'm done. I still need to make some sort of label for each position (possibly with a labelmaker, but likely some icons printed with black filament and glued to the front).
Last edited: