HA SwitchPlate HASPone: DIY In-Wall Touchscreen Home Assistant Controller

HA SwitchPlate HASPone

A DIY touchscreen scene controller that fits in a standard switch box

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

The HASwitchPlate 1.0 (“HASPone”) can display a series of pages, each with a custom set of buttons. There are several default button layouts available out of the box, and each button can be configured from Home Assistant via MQTT for custom text, font size, colors, and actions. Button presses are published back to MQTT for Home Assistant to pick up and react to via blueprints and automations.

The project includes a 3D-printable enclosure (front/back) to fit a 2.4" Nextion LCD touchscreen. Arduino code for an ESP8266 has been developed to interface with the display and communicate with Home Assistant via MQTT. A PCB design is available to safely power the device with AC power.

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 add your own graphics, buttons, or other user controls. The included Arduino code should be flexible enough to support whatever you create as it’s mostly passing through Nextion commands directly.

Below are some example screens. All of these are created by way of sending MQTT commands from Home Assistant to the device, and all are included in the default Home Assistant package:

Scene Controller Status display

Light Toggles Dimmer controls

Alarm Panel Media Controls

HVAC Controls Fan Control

Building this project is straightforward with access to some basic maker tools. The enclosure requires a 3D printer but can be inexpensively outsourced through services like 3D Hubs. A PCB is available and all parts are through-hole making for easy soldering with beginning soldering skills and tools.

Alternately, fully-assembled HASP devices are available to purchase to get you setup and running quickly.

121 Likes

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:

1 Like

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

1 Like

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

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

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.

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.

1 Like

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.

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.

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.

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

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!!!

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

What printer did you get?

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.

1 Like

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

1 Like

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?

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.

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.

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.