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

I was running into the same thing, but once I named the pages (and configured the input sliders to have the buttons go to a page number) it worked as expected

image

But that’s where I stopped. I don’t entirely like the behavior as-is so I’ve been trying to wrap my head around the entire setup. To me it seems more intuitive that the middle button is a “return home” button to a main set of things (4 switches?), and if already at home it could bring up a page selector or something similar while the left and right buttons could cycle left and right pages.

I haven’t decided if the page management is going to run on the Nextion directly and send its status back in the case of those changes… this way the page changes would be very fast (and you could at least have the panel respond to touch even if the MQTT server/node-red/connection is down) even though it may not pull in data.

I also am trying to use Node-RED as I’m just not familiar with HA automations at all so I’ve had to start by moving all of the automations over to a Node-RED flow and getting everything to work again.

2 Likes

Ah thank you… I didn’t realise I needed to add them to the HA pages, Sorted not

@1337hium appears to have something like that… arrows and a home button. How did you do that please?

##############################################################################
# select haswitchplate_pagebutton1_page in response to page button 1
- alias: HASwitchPlate1_PageButton1_Action
  trigger:
 - platform: mqtt
topic: 'homeassistant/haswitchplate/HASwitchPlate1/state/+'
payload: 'ON'
  condition: 
condition: template
value_template: '{{ trigger.topic.split("/")[-1].split("].b[")[1].strip("]")|int == 1 }}'
  action:
  - service: mqtt.publish
data_template:
  topic: 'homeassistant/haswitchplate/HASwitchPlate1/command/page'
  payload_template: "{{states.input_number.haswitchplate_active_page.state|int -1}}"

##############################################################################
# select haswitchplate_pagebutton2_page in response to page button 2
- alias: HASwitchPlate1_PageButton2_Action
  trigger:
  - platform: mqtt
topic: 'homeassistant/haswitchplate/HASwitchPlate1/state/+'
payload: 'ON'
  condition: 
    condition: template
    value_template: '{{ trigger.topic.split("/")[-1].split("].b[")[1].strip("]")|int == 2 }}'
  action:
  - service: mqtt.publish
data_template:
  topic: 'homeassistant/haswitchplate/HASwitchPlate1/command/page'
#      payload_template: "{{states.input_number.haswitchplate_pagebutton2_page.state|int}}"
  payload_template: '1'      
 ##############################################################################
 # select haswitchplate_pagebutton3_page in response to page button 3
- alias: HASwitchPlate1_PageButton3_Action
  trigger:
  - platform: mqtt
topic: 'homeassistant/haswitchplate/HASwitchPlate1/state/+'
payload: 'ON'
  condition: 
 condition: template
value_template: '{{ trigger.topic.split("/")[-1].split("].b[")[1].strip("]")|int == 3 }}'
  action:
  - service: mqtt.publish
data_template:
  topic: 'homeassistant/haswitchplate/HASwitchPlate1/command/page'
  payload_template: "{{states.input_number.haswitchplate_active_page.state|int +1}}"

Something like that, forgive me, i had this for ages :stuck_out_tongue:
Here is my Full automation for the Plate:

3 Likes

Brilliant… Thank you. So how did you get the arrows inserted please? I cannot work that out either :slight_smile: I found some on the character map but they just down work when entering on the frontend of HA. Cheers Mark

There you go :slight_smile:

configuration.yaml


input_text:
  haswitchplate_pagebutton1_label:
    name: HASP Page Button 1 Label
    icon: mdi:book-open-page-variant
    initial: "-"
  haswitchplate_pagebutton2_label:
    name: HASP Page Button 2 Label
    icon: mdi:book-open-page-variant
    initial: Home
  haswitchplate_pagebutton3_label:
    name: HASP Page Button 3 Label
    icon: mdi:book-open-page-variant
    initial: "+"
2 Likes

Finally went about re-learning KiCad enough to fix up the PSU footprint and replace the radar motion sensor header that never did work right with a more general-purpose pin header that can be put to your own devices. I’m out of town for work at the moment, so it’ll be a few days before I get home and print a physical copy of the board to confirm that everything fits and the pieces are still in alignment with the original enclosure and protoboard builds. I’d like the PCB to be a (strongly recommended) option, allowing folks to test things out on protoboard before committing to get PCBs made. There’s still some work to do but I’m happy with how things look at the moment.

There may be a change to the rear enclosure to offer a little more depth so that courageous users could mount something like this on top of the WeMos, allowing this device to switch 120VAC.

So long as everything fits, I should be able to send these off, test the results, and then publish a link where you can download and order your own boards, to be followed shortly by a Tindie store so I can build a handful of these units for sale. I won’t be including the relay shield as I still think it’s a risky idea, but I do want to allow for users adding their own shield and so the design has been setup to allow for that. I don’t intend to make a business out of this, but I do think that making assembled units available could help out folks with better software skills than I to improve upon the HAss automations and/or Arduino sketch (maybe a component some day?), without forcing skilled software devs to inhale any solder fumes :smiley:

5 Likes

I wanted to highlight this post here because it reflects my own intentions for this project - I created a very plain-vanilla set of pages and examples with the hopes that others will tear it apart and use the pieces as scaffolding for their own projects. The Arduino sketch is probably the one thing that should work as-is without too much modification, but the included Nextion HMI and Hass automations are very basic and easy to modify, so don’t hesitate to start making extensive modifications. The sample applications as only there to act as starting points.

I submitted 2 bugs I found (1 I know the fix for the other I can’t figure out) and an enhancement on GitHub for the project. Sorry for blowing up the project. :slightly_smiling_face:

EDIT: On the topic of taking this and running with it (using the it as scaffolding as you alluded to), I should probably fork your project and upload my changes. I really appreciate the work you put into it. My wife and I use this everyday and love it.

Truthfully I haven’t spent much time on it lately! But I’m feeling comfortable enough with nodered now to get the automations moved over. I’ve been watching things pretty closely and just have a panel sitting around on my desk because I haven’t bought any white PLA/ABS for a face plate. I’ve got a spot I’d like to place one with a motion sensor but it feels like there’s a couple of hurdles to get over all at once so I’m a bit stuck.

Definitely waiting on you to release the PCB for the project as that’ll help since I can get it into a useful location and that’ll force me to finish it!

This looks like a really promising controller. I have one important question though. Is it possible to switch of the backlight of the LCD? It would be a no go for me to have a couple of those guys illuminating my bedroom at night. So a timeout for the backlight would be a must. Something like a proximity sensor would be even better…

yes you can… it appears as a light in HA and can be dimmed

Thanks. So I have to control it from Hass? Or can it switch on upon touch as well?

There is a way to get the screen backlight to timeout on the device and turn off but I don’t know if you can turn it on with touch. You would need to look at the display commands and modify the Arduino sketch to do this. I started working on it but haven’t put much effort towards it lately. I believe the command is “thsp”. Other commands are “ussp”, “thup”, “sleep”, and “dim”. The commands can be found near the bottom of this page. Otherwise you can setup an automation in home assistant and a script with delay and turn the screen off after a period of time until input is received. Or you can combine it with a motion detector. At one time the original creator did attempt to put a proximity sensor on the device itself. Read through this thread to find info on it.

Hello all,…

Many thanks to luma for this fantastic project. While figuring out how I wanted to implement it I found a few options.

If you don’t have a 3d printer (like me but only for a while), these might help if you don’t mind having the unit protrude from the wall a bit (1 3/8 inches seems to be the shallowest depth available):

https://www.amazon.com/Legrand-Wiremold-NMW2-D-Raceway-Outlet/dp/B000GIGT6A
https://www.leviton.com/en/products/42777-1wb

I also found 4d Systems which makes a “IoD” (internet of displays) line up including bezels and dev tools. It’s more expensive than your setup but I thought I’d list it as a reference data point.

https://www.4dsystems.com.au/product/gen4-BEZEL/
https://www.4dsystems.com.au/product/gen4_IoD/

The Legrand-Wiremold and/or Leviton parts could also enable the use of 3.2" displays, especially in the case of the 4D Systems bezel which fits exactly to these boxes. You would have to file down the plastic tangs that hold the box to the baseplate a little if using 3.2" display since they might “hang on” to tightly. I envision mounting the display to the box and then snapping it onto the base plate while the mfgr instructions lead me to believe that normal use is to snap the box onto the baseplate then screw on the face plate with switch or receptacle.

If you were to go the 4D route, one might have to code the MQTT stuff independently, I didn’t see any references in the quick survey I did of their stuff.

Anyways, some food for thought. Thanks again for all your hard work.

1 Like

I’m now waiting for round 3 of the PCB which I’m confident is going to work and fit correctly this time (I hope). Rev 2 had issues with placement of the mounting holes and I want to maintain compatibility with existing protoboard setups so I needed to move those to their original locations. The new PCB will require a modification to the rear of the enclosure which is unavoidable - the original build used a hacky way to fit the WeMos on the protoboard by way of not soldering in the outside row of pins, but this doesn’t seem ideal and with a custom PCB it’s not required. However, the space underneath the board where those pins would be sticking out has a lip to support the board which I need to remove. Not a big change, but it will require re-printing the rear enclosure (or some dremel work). I’ve made the required changes to the model and will publish both the PCB and the new rear enclosure once I am 100% certain that everything is going to work together. I expect it to take a little over a week to receive the new boards and complete that testing.

Other changes:

  • I’ve removed the motion sensor pins because the microwave radar doesn’t really work through the LCD screen, causing a lot of false positives.
  • In place of the motion sensor breakout I’ve added a set of 8 pins that connect to GND/+3.3V/+5V along with A0, 3 GPIO pins, and D8 for serial debug output. This will allow the easy addition of your own modules inside the enclosure if one should want to add additional sensors, inputs/outputs, etc.
  • The stock WeMos relay shield isn’t going to fit due to the way it hangs over the USB port. We could move the WeMos back, get rid of the breakout mentioned above, and remove the hole for access to the USB port (which would be compliant with NEC…), but I’d far rather have USB access than a dodgy relay hack.
1 Like

PCBs are NOT ready!

Ughh! ONCE AGAIN I SCREWED THIS ALL UP!

Everything fits except… THE MOUNTING HOLES ARE MISSING! Good lord I’m horrible at this. Please standby, I’ll order another round.

edit: on the off chance that anyone actually executed an order with the PCBs I had posted here, IM me and we’ll work something out, I don’t want you to have to pay for my screw up.

3 Likes

Bugger I saw your post this morning and came back this evening to pick up on ordering some. I’ll wait, good things are worth waiting for!

Looking fwd to the perfect finished product keep up the hard work

1 Like

Things are looking better. I still need to do some final testing (learning some lessons here) but the board appears to work and everything fits like I would expect. I should have links to order boards up within 24 hours…

2 Likes

Allright everything is tested, this time I mean it - THE PCBs ARE READY!

PCB source files if you want to modify things in KiCad
PCB Gerbers to send to your PCB fab of choice.
Link order boards and kickback some credit for me to buy more (see below)

Throughout this process I’ve now used 3 different PCB fabs, one in the US and two in China. The US shop (which I won’t name) was slow as hell and apparently was recently sold to another company. I won’t be using them again. Second round was sent to JLCPCB who manufactured and shipped very quickly, and the results were to my expectations. Good price, fast service, decent quality. The low price is a limited deal - as soon as you select nearly anything except a 2 layer board with green/white solder mask/silkscreen the price goes up quickly. I had a good experience there and I wouldn’t hesitate to send future orders to JLCPCB.

HOWEVER - for this last round I checked out PCBShopper which is a price-comparison site for PCB fabs. I chose the lowest-price option from a place called AllPCB fully expecting to receive a sloppy mess. Instead I received the best looking boards of the bunch. The silkscreen and masks are laser-sharp, everything is aligned as perfectly as my eyeballs can determine, the edges are super smooth with no visible scoring from the panelization, and they work a treat. They offer a handful of color options, some of which don’t blow up the price. I received twice as many boards from AllPCB with the color scheme I wanted, slightly better quality, with the same shipping speed and almost the exact same price as JLCPCB.


AllPCB on the left, JLCPCB on the right

The ordering process was a little challenging - their website isn’t great (and is completely offline as I write this). Logins happen unsecured, and when you finally do get flipped over to HTTPS it’s on port 442 for some awful reason, so you might have problems reaching the site (even when it is online) if you’re behind a corporate firewall that blocks everything outside of 80/443. The upload process wouldn’t work at all for me under Chrome so I had to use IE to complete the ordering process. All of these things were glaring red flags but I went ahead anyway and am glad I did - the results are perfect and they for sure will be seeing future orders from me.

edit: moments after posting this I checked their site again and it’s back online and they apparently have heard my concerns about HTTPS because now the entire site is secured and running on the normal HTTPS port. That’s a huge improvement and addresses the major issue I had with the site.

So here’s the deal - THEY ARE PAYING ME FOR THIS REVIEW (I hope). The deal for that is in the link there, and I want to be perfectly transparent that I might receive all of 10 dollars of credit for writing about my experience there. I can assure you that I’m not pimping their service for the princely sum of $10, but it doesn’t hurt their game any either :smiley: I can in all sincerity declare that I’m thrilled with the result, I’ve been through several shops and AllPCB is the new hotness, paid reviews or not.

5 Likes