HA SwitchPlate - DIY LCD Touchscreen wall switch replacement


#1

HA SwitchPlate

Isometric view

edit: changed the name to avoid any trademark issues, changed the repo link to match, and have added several features!

I’ve been looking for a clean way to control Hass that would fit into a standard single-gang work box / switch panel and lacking good options on the market I’ve decided to design and build one myself.

I’ve designed a 3D-printable enclosure (front/back) to fit a 2.4" Nextion LCD touchscreen and Arduino code for an ESP8266 to interface with the display and communicate with Home Assistant via MQTT. The device can display a series of “pages” each with a custom set of buttons. There are several default button layouts (4 button/8 button/12 button/media/graph) available out of the box, and each button can be configured from Hass via MQTT for custom text, font size, colors, and action. Button presses are published back to MQTT for Hass to pick up and react to via automations.

In this video I run a quick demonstration of the device powering up, receiving its configuration, and controlling scenes in Home Assistant. I’ve created some automations which will do things like send the current time in a large font every minute to a button, creating a clock display. The same can be done with the current weather, sensor status, or anything else Hass knows about. Button presses send out MQTT commands which can trigger scenes (or anything else) in Hass.

Exploded view

The Nextion display used in this project has it’s own command structure which is accessible via MQTT, so you can use the provided display firmware or download their editor to create highly-customized art and graphics. The included Arduino code should be flexible enough to support whatever you create as it’s mostly just passing through Nextion commands directly.

Here are some example screens, all of these are created by way of sending MQTT commands from Hass to the device:

Scene Controller Status display

Media control 3D printer status

Alarm panel Dimmer controls

Both the microcontroller and LCD panel support OTA updates allowing modifications without removing the device from the wall. Extensive demonstration automations are provided to give you a sense of how to interact with the device. The code and models are now (reasonably) complete and ready for user testing.


Replacing light switches with 3.5" pi screens
Use of Nextion NX3224 Screen?
YET another take on an alarm system
Question: can Hass send single-byte MQTT messages without UTF8 conversion?
Son's Daily Meds Checker
[solved] Looking for ideas how to WW LED strip, wifi controller + physical button
Three-way switch wiring question
MQTT Automations firing twice when MQTT discovery is enabled
YET another take on an alarm system
Z Wave wall scene controller
Reload Automations to the packages Folders
#2

This is awesome! Thanks for sharing your hard work. I am looking to do the same thing and came across your post while researching. Out of curiosity, will the LCD panel fit into a padddle switch plate? My wife will NOT approve the 3d printed face-plate :wink:


#3

Very cool! I will order one of the LCD panels and put one together


#4

I don’t have a 3d printer, but it someone wanted to add a relay to this I would buy a couple of them


#5

Thanks for the share :wink: very nice and clever design !!


#6

Sadly, no it won’t fit into a decora paddle plate. I went pretty far down the rabbit hole trying to source a suitable panel for this while also trying to keep the resulting device flexible enough so that the user wouldn’t need to learn bit-level graphics manipulation. The Nextion panel (from the same people that make the Sonoff devices) was the best tradeoff I could find for price, availability, rapid development, and a range of sizes. This is the smallest device they make and it still only barely fits between the screw lugs in a standard box.

My pictures are pretty terrible (something I never learned to do right) but the panel looks pretty good. Still, it doesn’t look injection molded like your traditional switch plate. If you want a better finish, commercial printing services like Shapeways could get it done in a range of materials and finish options. I’ve recently built an MPCNC for wood milling which technically could CNC these plates from Delrin or similar but it isn’t near accurate enough for the tolerances I need on this project so I haven’t given that a shot yet.


#7

Throwing a couple relays into this design would be nearly trivial and I was tinkering with the idea already. I’m going to be travelling for work for a couple weeks which is going to slow down the case and electronic design cycle as I won’t be near my bench, but I do intend to put a protoboard mount inside the back cover to mount the PSU, MCU, and possibly a relay (or several). Also considering a motion sensor (PID or radar) and a haptic motor for screen presses.

Nothing is off the table, so if you have any other ideas of hardware you’d like to see in such a solution, please keep them coming!

In regards to selling them? Not a business I’d immediately be interested in, but I am going to be making several of these for my own house and if I get a sense that the time required + BOM would make it worth the effort to crank out a few more then I might revisit that decision.


#8

I would love a PIR, and a relay would be nice once the PSU issue is resolved.

I have a spot I can put this where I have USB power so I will report back when I’ve got it put together.


#9

I’ve modified the plate a bit to leave more room for screw lugs on the work box and have added an edge around the LCD PCB with cutouts for the microSD card and connector (neither of which would be usable when mounted but can be handy for assembly and testing). I should be able to fit a 4x6 protoboard in the back which will have enough area for the MCU and PSU again with hopes of being able to cram in a relay and/or radar motion sensor.


#10

When you say “the included Arduino code” are you indicating code that comes with the Nextion editor or are you providing your sample code someplace I don’t’ see? Thanks for posting, I really want to try this.


#11

You can download the Arduino sketch from the Github repo here.


#12

It looks super cool, thanks @luma!

I’m interested in the BOM and excited to see your further developments. I guess it’s time to get my 3D printer up and running!!!


#13

So it would only require a Nextion display, esp8266 and power supply to run this? Aside from the printed bezel.


#14

What printer did you get?


#15

Correct. The Nextion panel is a self-contained LCD/touchscreen/microcontroller that interfaces via serial to whatever you want to attach to it. The ESP8266 for the most part is simply gatewaying communication from the panel to Hass via MQTT. So all it needs is the panel, the ESP8266, and a 5V power supply to run them both. If you want to mount it in the wall you’re going to want the switch panel and some sort of power supply that will fit into that box.


#16

I bought a Tronx P802 a couple of weeks ago. But as a kit and haven’t had time to assemble it :frowning:


#17

I bought an ESP8266 and Nextion panel and plan to implement this. One issue I am running into right now is I can get the initial component to be discovered in Home Assistant but I can’t get the other MQTT topics to show up such as the “nextionattr/p1.b4”, etc. I see the binary sensor component and it updates accordingly based on the state ON/OFF, but that’s it. I modified PubSubClient.h to increase the MQTT packet size to 256 and that got the initial component to show up properly. Any tips on how to get the MQTT discovered components to show up on the frontend?

Maybe it’s there and I’m just not understanding how the MQTT discovered components work? Is the binary_sensor component what is discovered and the MQTT topics are just there but not exposed as a component to the frontend?


#18

after some more digging around and playing with it I figured it out. It’s just as I guessed. The component on the frontend is just for the initial device discovery and for visibility on the frontend. There’s almost no interaction with that device. But once the ESP8266 connects to the MQTT server, all of the other topics are there and I can subscribe/publish to the topics.


#19

You got it exactly. The auto-discovered component is a “connectivity” device_type which is turned on when MQTT connects and off when it disconnects for some reason by way of a Last Will and Testament message. You can use that switch device to trigger initialization commands when the device comes online.

I’m made some major code changes and added a second autodiscover device of type “light” which can control the panel dimming. I’ve got my power supplies and am currently working through finishing up the enclosure design to accommodate everything. Expect a bunch of updates this coming week, some of which will break any automations made against the currently-published code.


#20

Sweet! I look forward to the updates. I’m playing around with panel sleep on no touch with a timeout of 5 minutes. I have it wake on touch input, but the clock doesn’t update until the automation is called so I think I need to have the automation to update trigger on touch input. If the panel is sleeping, regardless of ‘thup’ value, it will still pass x,y touch coordinates. Another thing I’m still wrapping my head around is how to use the numeric inputs within Home Assistant so I can use it like a keypad for an alarm control panel.

I do have to say this is a pretty neat project and I give you props for all the work you’ve done.