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

Arduino sketch v0.2.3 has been uploaded to GitHub. There are some performance improvements along with web-based firmware update through the admin panel. Currently this only supports uploading from a local file. You’ll still need to use the Arduino IDE once for the initial programming, but afterwards you can download the compiled .bin file from GitHub and upload it to the device without the Arduino IDE

To enable this capability we’re going to need some more room for flash space. In the Arduino IDE select Tools > Flash Size: > 4M (1M SPIFFS).

I’m pushing toward GitHub integration, which will one-click updating but I’m stuck on an issue with GitHub’s SSL cert and the ESP8266’s handling of it. Once we get past that problem future firmware updates will be a one-click operation. Everything there is working against non-HTTPS servers and against other SSL-protected systems, but I strongly prefer to have it pointing directly at GitHub vs spinning up my own OTA server for everyone to use. If no resolution comes from this I’ll see what alternatives I can come up with.

Enclosure ideas

This project originally started with trying to source an LCD touchscreen that I could mount between the top/bottom screw pattern in a standard workbox. The Nextion panel selected was the only option I found which would fit (and for which I could actually program against without enormous effort), but even then it only barely fits. I’ve been designing against the common blue-plastic workbox you see everywhere along with some online dimension drawings I’ve found for the same. I’ve been running a single HASP device in my office which fit fine, but now that I have some PCBs I’m ready to start deploying these around the rest of my house and have found that the existing design is a very tight fit in some of my other boxes, to the point where I had to dremel one out to get the case in. This doesn’t seem ideal.

I’ve also been monkeying around with how I can better enclose this thing such that there are no exposed components in the finished design for safety reasons while still fitting between those two screw holes.

With the current published model there are two places where we have holes open to the outside that aren’t going to be easy to address (the USB access port is simply for dev work and with OTA updating is no longer necessary). These are the openings for the LCD PCB and 4-pin XHP connector, and the opening for AC power connection.

AC Power connection

The incoming power connection sticks out of the top of the unit and has a pretty large gap to insert wires. This is a huge safety problem, it exposes the only high-voltage contacts in the system and opens them facing upward, perfect for dust or whatever to fall directly into the box. This seems bad so I’ve been kicking around some ideas to address it.

I started with designing a retainer plug and printing it in semi-flex TPU to clamp in the wires, fill the gap, and provide some modicum of strain relief. This approach actually worked OK but it still has cables egressing out of the top of the device in what is already going to be a cramped box. Pics below show the design and printed results along with another part I’ll be discussing in a moment:


While chewing this over with @zombu2 on Discord he suggested running the power cables out of the back. The more I thought about this approach the more I like it. I have a rigid surface back there with room for a grommet, it moves the cables away from the already-tight perimeter, and it wouldn’t require a change to the PCB. I can simply remove the screw connector, insert the incoming AC cables from the back side and solder them to the PCB on top. I’ve ordered some grommets to test fit some ideas around strain relief, but I think this approach might be how I move forward with the design. It neatly solves the safety problem, provides for sturdy cable capture, and removes the cable harness from the already-cramped top/bottom of the box making for an easier fit in your existing box.

I don’t have those grommets quite yet so I’m testing printing a basic design with holes for the wires. Note the much deeper cutouts for work box screw mounts, something possible now that I’ve moved everything out of the way top/bottom. With the screw connector gone I can also put the 4th screw mount for the LCD and front panel back in place which is a nice bonus.

LCD PCB and connector

In the current design the top and bottom edges of the LCD panel are exposed. On the bottom this is simply due to room between the screw mounts and saving myself a single mm by leaving just that edge exposed to the outside. On the top it also has the 4-pin JST-ish XHP-kinda connector up top which we never have been able to use. All existing builds (at least those that have been put into a box) have required soldering the wires directly to the solder pads of the connector. That doesn’t bother me so much, but having the connector itself exposed to the outside top of the box is problematic for all the reasons outlined above (only this time w/ 5VDC instead of 120VAC).

My first approach to solving this problem was the same as above - print a semi-flexible plug that I can stuff into the connector as a dust cap and hope for the best. While this covers the exposed pins it still leaves open gaps around the perimeter and takes up a fair bit of real estate. After stewing on this for a bit it occurred to me that this whole thing would be better if the connector itself were simply gone. A few moments with the hot air station proved this out pretty well:

With the connector out of the way I am now able to fully enclose the case such that no conductive parts are exposed to the outside which is critical for safety. We can do it without changes to the HASP PCB (which is handy because I’ve already sold a handful) but at the cost of requiring the assembler to have access to some means of removing the connector which is going to be tricky with a standard soldering iron. You’re really going to want a hot air station to make that happen.

I’m still running some prints and have some parts on the way (grommets/screws/etc) to test out some ideas, so this is all very much work in progress. If anyone has any thoughts or ideas to share, I’m all ears!

1 Like

Really like this work.
I orderded a Nextion a week ago.

Installed de arduino sketch to an nodeMCU whitout problems.
But the nextion Firmware file (tft) hangs, the nextion boots but hangs on “SD Card Update…”. I’m currently running Linux, so i have to use the SD update method.
Any one else encounterd this problem?

Can you post a link to the exact panel you ordered?

That should be the standard (not enhanced) unit, which means there shouldn’t be any issue there. I would make sure you’re using FAT format, try a smaller SD card (like, a 1GB or 8GB to make sure the partition is going to be an acceptable size), or source a Windows machine/VM and try to run the Nextion editor for upload.

Anybody tried something similar For a European enclosure?

1 Like

I tried a few different SD Cards 1GB, 8GB and 32GB. But no luck!

i’l try to get my hands on an windows machine. Thanks.

I could only get the SD card to work from my windows machine. There’s something the panel doesn’t like about Linux/macOS formatted devices. Even though I used MSDOS FAT format, there’s something the touch screen doesn’t like about it. An alternative is to get a USB to TTL converter and program the panel that way. It’s slightly faster and provides firmware updates to the panel as well.

I’ve updated the documentation to include directions on flashing the firmware without using Arduino, which should greatly simplify the process for getting this up and running.

I am really impressed with your efforts @luma

3 Likes

Is the USB to TTL method also available for Linux? I have a TTL/USB cable lying aroud at Home.

You may be able to flash the LCD using an MQTT command. Place the TFT file on a web server somewhere where HASP can access it and publish an MQTT message something like this:

mosquitto_pub -t 'hasp/plate01/command/update' -m 'http://192.168.0.10:8123/local/HASwitchPlate.tft'

New automation examples

I’ve added a folder in the repo for example configurations demonstrating various automation tasks using HASP. If you have unique or interesting solutions you’ve developed, please share them with the world here!

@squirtbrnr submitted a PR a while back that I’ve worked into the new packages format. This package will create sensors to reflect current the status of a Kodi media player.

I created an automation to adjust the backlight dimmer based on the sun’s elevation. I recently installed a HASP into our bedroom which receives a lot of natural sunlight. This automation will set the backlight to 255 when the sun is >= 10° above the horizon. Between 10° above the horizon and 10° below, it will gradually dim the light down to brightness 5.

1 Like

Had the same problem but I used the nextion software and it did a software update then uploaded the screens everything all good now happy happy camper

Love it! Amazing work @luma

I’m going to need to get my hands on a 3d printer to finish the project…

Have you considering making a bigger screen version? (Comes with an enclosure too!)

https://www.itead.cc/nextion-nx8048k070-011r-011c.html

I hate that enclosure, the bevel is far too big!

But the basis of the code should work with any size, you’ll have to create an HMI file for the bigger screen.

While the Arduino code should work with any Nextion HMI software and hardware, the power supply we’re using is rated for 600ma and that panel wants 510ma of that, which doesn’t leave enough for the microcontroller. You can change the PSU, but then you’ll need a bigger PCB, bigger enclosure, etc etc.

So yes, while it should be possible to make the software presented here work with that device, the hardware won’t.

Testing out some ideas for rear power cable egress:



1 Like

Version 0.24 release - web update enabled!

I’ve had HTTP updates working for a bit but was struggling to get HTTPS updating working against GitHub. The SSL stack on the ESP8266 is pretty limited under the best of circumstances, and it has become apparent that running a full firmware update under the current SSL stack is a losing proposition. Given that HTTP is going to be a hard requirement, and also given that I want to keep all of this running on GitHub, I put together a ridiculous plan to make this work.

http://haswitchplate.com is now live and redirecting all incoming requests to the GitHub repo except requests for the firmware image. For that it’s proxying requests to GitHub over SSL and sending the result to the requestor over HTTP. From a security perspective this is a nightmare but… ESP8266. It’s bein’ all it can be.

Once you have updated to version 0.24 you will now be able to click a button to update your devices to the latest code. Here’s the complete process:


Once you click on that button it will download the latest Arduino binary from GitHub (by way of HTTP and my proxy host), flash it to your device, then restart with the new version. At some point I’m going to need to implement version reporting back and forth to trigger an “Update Available” sort of notification but for now… yay it’s finally working!

There have also been the usual handful of bugfixes and reliability improvements.

1 Like