Show and Tell Home Assistant Controller Switch

Show and Tell are completed projects.

Andy

Controlled Chaos
Staff member
1668720558338.png
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
(I'll show off those other ESPhome projects Someday™)

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.

1668717559614.png
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.
1668717655816.png 1668717667020.png
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.
1668717813079.png 1668718004124.png
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.
1668718087552.png
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:
That is so cool, I love the sound it makes! I think tactile switches are a great idea for HA scenes. I have been getting used to my wall tablet controls and slowly evolved to having my favorite scenes and automations be very large square buttons that I can easily tap without dexterity. Tactile buttons or switchers and sliders would be even better though!

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.
I have run into this same thing and it seems weird right? I don't have an alternative but that is how I'm currently managing the triggering of some scenes.
 
Yeah I'm definitely team physical interface. This is the first time I've really messed with bridging that gap (also the first time messing with scenes and automations...), but I'm pretty happy with the result. That clicky switch is the real hero; I was using it as a fidget toy between when it came in and when I built the thing 😂

I'm not opposed to using automation scripts to trigger a scene, but building 4 separate lights, 4 separate outputs, 4 separate inputs, 4 separate scenes, and 4 separate automation scripts seems like an opportunity for consolidation.
Though it did also enable me to pause Spotify and my Roomba when I step into a meeting (and not at any of the other states), so there's at least that.
 
Ooh, this is a fun bump to this--I got wake-on-LAN working on Home Assistant, so now when I flip this switch to "working", it automagically wakes my computer up.
 
Oooh that is super cool! I have never played with WOL before but it always sounded super useful!
 
I've only ever poked at it as a theory. This is the first time it's actually been useful for me
 
Back
Top