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

to switch nightmode on

- service: mqtt.publish
  data:
   topic: "hasp/plate01/command/json"
   payload: '["thsp=10", "thup=1"]'

and when nightmode switches off

- service: mqtt.publish
  data:
   topic: "hasp/plate01/command/json"
   payload: '["thsp=0", "thup=1"]'

to disable the auto sleep.

However sometimes my plate seems to loose connection when sent to sleep mode. and I have to reboot.

only works when the display is awake. so one need to send

- service: mqtt.publish
  data:
   topic: "hasp/plate01/command/json"
   payload: '["sleep=0"]'

first

You should be able to do ["sleep=0","thsp=10", "thup=1"] as the commands will be sent to the Nextion in order.

If thatā€™s not working, try: ["sleep=0","delay=1","thsp=10", "thup=1"]

cool thanks. Iā€™ll see how it works for a few days and will report back. Iā€™ve noticed that the automations seem to be slower. by a little bitā€¦

I suspect performance will be a bit better once we can template MQTT triggers. Right now all automations are triggering a lot, and then using conditions to stop execution if they shouldnā€™t have been triggered. This compounds as the number of automations increases. I suspect I wonā€™t be releasing this ā€œofficiallyā€ until that feature is available, as it will have me making some changes to basically every blueprint to add that feature.

Iā€™m really happy with itā€¦ If the performance increases it would be even better.

the wifi seems to be a new feature of the new firmware. Sometimes the plate seems to loose connection. And after a cold boot it is not connecting to wifi - I have to plug out/in again to make it connect. The older firmware was rock-solid in that regard. Did you change anything wifi related? timeouts maybe?

One other thing. I want the status page to be shown when after a certain timeout. I created an automation that switches to page2 every 2 minute. That works but is not ideal as sometimes this interferes with the operation.

Is there a way to catch all messages from hasp? So to trigger the automation letā€™s say 1 minute after the last message was received?

With an automation itā€™s reasonably straightforward to do what youā€™re asking there. In rough steps:

  • Create a timer object
  • Watch MQTT topic hasp/[your plate name]/state/json. A button press looks like this: {"event_type":"button_short_press","event":"p[1].b[5]","value":"ON"}
  • condition template: {{trigger.payload_json.event_type == "button_short_press"}}
  • reset your timer

When the timer expires, you can issue the command to go to your idle page.

Soā€¦ why donā€™t I have a blueprint that does this for you already?

First, blueprints cannot create a timer object, so a user would have to create one with the correct name first which isā€¦ likely to break. I could make one and have the user create their own timer, and then enter the name, but thatā€™s really clunky and Iā€™d like to avoid people having to go edit configuration.yaml if at all possible.

HOWEVER, there is another way to make this happen. Automation mode set to restart will stop execution of an automation and restart it if triggered again. So, create a trigger like the one above, have the first action in the sequence be a delay (60sec or whatever), and then any additional incoming messages simply reset the entire automation. If it finally makes it past the delay without being reset, then switch to your default page.

Problem here is that without MQTT topic filters, itā€™s going to catch a lot more things than just button presses from a single HASP. It will catch all messages from all HASPs instead. I expect the next release of Home Assistant is likely to include this PR, which will let me publish a solution that should work like youā€™d expect.

Finally, Iā€™ve also noticed the WiFi behavior and I canā€™t for the life of me figure out why. I can reset the device 10 times w/ the reset button, and one of those times it will not connect. Reset again and it connects right away. I am working on a cheap hack for this - attempt the first connection, if it fails, manually reset the radio, try to connect, if fail, repeat a few times, and then eventually give up. That approach appears to be working, if I run into whatever edge case is causing the initial connection to fail, resetting the radio allows it to connect the second time. Using the exact same sequence, but without resetting the radio, fails to connect no matter how many times you try.

if someone is interested I modified the clock blueprint and created a blueprint for day of week:


The preview image has to be changed but itā€™s working :wink:

1 Like

Iā€™ve pushed a new firmware image to the dev tree with the WiFi connection workaround. It isnā€™t pretty, but it appears to work reliably.

Hello
I am in France, I made the new installation everything works well except what to do to have the date and day in French
thank you
(sorry for google english).

I apologize that this is a little OT, Does anyone know how well the nextion basic screen works through acrylic? I am thinking of putting one in an outside location to control my spa pool music and lights. Thinking of putting it in a waterproof box something like this, and running switchplate of course. https://www.jaycar.co.nz/black-plastic-enclosure-box-120-x-70-x-30mm/p/HB6082.

I installed the latest dev release and the connection issues when starting seem to be gone : nice. However I still loose mqtt connection while in sleep mode. I can still see the HMI events via telnet but no mqtt connections go in/out.

and unfortunately the sleep function does not work for my use case.
I have the plate on my nightstand and when I wake up at night I want to be able to check the time by touching the display. Now with it not updating this kind of defeats the purpose.

I think Iā€™ll be switching back to just turning if the backlight. This however mans that every blueprint needs a condition to check if the backlight is on/off so that the automations only fire if the backlight is on. The only automation that should run upon switching touching the plate is turning the backlight on.

Or is there any easy command to push an update of a single page upon waking up?

I doubt that Iā€™ll work well itā€™s a resistive screen. So you actually have to press itā€¦

now is also have connection loss while the display is active. Thats really a pity as before HASP was the one thing about my home-assistant installation that never failed.

it doesnā€™t seem connected but I get this error:

[+721.490s] MQTT IN: 'hasp/plate01/command/p[2].b[7].txt' : '\"Cloudy\"'
[+721.494s] HMI OUT: 'p[2].b[7].txt=\"Cloudy\"'
[+721.496s] HMI IN: [4 bytes]: 0x1a 0xff 0xff 0xff
[+721.498s] HMI IN: [Invalid Variable name or attribute] 0x1a
[+721.501s] MQTT OUT: 'hasp/plate01/state/json' : '{"event":"nextion_return_data","return_code":"0x1a","return_code_description":"Invalid Variable name or attribute"}'
[+721.509s] MQTT IN: 'hasp/plate01/command/p[2].b[6].txt' : '"-8.6Ā°C"'
[+721.517s] HMI OUT: 'p[2].b[6].txt="-8.6Ā°C"'
[+751.444s] MQTT IN: 'hasp/plate01/command/p[2].b[4].txt' : '"13:09"'
[+751.449s] HMI OUT: 'p[2].b[4].txt="13:09"'

I think using automations to manipulate the backlight makes a lot more sense than sleep mode. As above, I will for sure be deploying blueprints for ā€œdefault pageā€ and ā€œdim after inactivityā€ once we have templated MQTT triggers. The default page one is a big deal for me just because itā€™s an easy way to add a 4th screen to your setup.

Hm. Any chance that this will happen before the next Home-assistant release? I probably will have to revert to the old firmware / automations because right now its a bit unusable.

I was so excited about the much cleaner blueprints implementation. Maintaining and debugging the packages automations was a PITAā€¦

How many HASPs do you have installed? I could throw one together with the current state of things, but itā€™s going to trigger on all installed HASPs.

In regards to the connection loss - what serial speed are you running at right now?

So if i have 5 plates running .40, i setup a new one with the blueprints it will screw the other ones up.
I have it all ready to go but havenā€™t setup blueprints yet.
PS great job. The only thing that bugged me about .40 (very small bug) was the # of automations i had to look threw, new blueprint idea great work.