Home Automation Switch Plate (HASP) - DIY touch controller

Are you sure you’re running the latest firmware bin (version 0.37) I uploaded to my Github? I removed the “OFF” event from the JSON state topic, because the events were coming in too fast (and doubling up the button press rule). With the latest code, only the “ON” event is passed, so pressing the plate when turned off will bring it back up to full brightness, but won’t register as a command button press.

Yes I using latest firmware bin found bkpsu/HASwitchPlate/tree/master/Arduino_Sketch

I downloaded and updated it again to be sure. After waiting for the time out I gave it a quick touch to wake it up and still received a touch event in the log.

HASP_Plate01_Button_P2B7 changed from OFF to ON
Just touch the bottom of the screen for now

2019-02-16 23:40:58.651 [ome.event.ItemCommandEvent] - Item ‘HASP_Plate01_Light_Power’ received command OFF
2019-02-16 23:40:58.672 [vent.ItemStateChangedEvent] - HASP_Plate01_Light_Power changed from ON to OFF
2019-02-16 23:40:58.766 [vent.ItemStateChangedEvent] - HASP_Plate01_Light_Status changed from ON to OFF
2019-02-16 23:41:09.747 [vent.ItemStateChangedEvent] - HASP_Plate01_Button_P2B7 changed from OFF to ON
2019-02-16 23:41:09.784 [ome.event.ItemCommandEvent] - Item ‘HASP_Plate01_Light_Power’ received command ON
2019-02-16 23:41:09.802 [vent.ItemStateChangedEvent] - HASP_Plate01_Button_P2B7 changed from ON to OFF
2019-02-16 23:41:09.806 [vent.ItemStateChangedEvent] - HASP_Plate01_Light_Power changed from OFF to ON
2019-02-16 23:41:09.829 [vent.ItemStateChangedEvent] - HASP_Plate01_Light_Status changed from OFF to ON

I got an easy way to fix it just need to be tested.

Ah, I see what the issue is - you’re still using the original Items/Rules I posted. Last weekend, I updated the files to use the latest JSON state format, deleting all of those unnecessary “discrete” items for each button, dimmer, background color, etc…

Check out the Github contrib/openHAB folder, and download the items/rules files from there. They’ll make your configuration much simpler (and get rid of the issue you’re seeing with the backlight).

Ahh yes that’s got It thanks.

It also works good with the change

rule "HASP Master Restore page on connect"
    Item HASP_Plate01_Plate_Status changed to "ON" or
    Item HASP_Plate01_Plate_Refresh received command ON
1 Like

Yup - just tested it on mine and it works perfectly! Refreshes on connection and no extra refreshes after that - thanks! :slight_smile: I’ll update my Github repo to incorporate this improvement.

Hi. Just been playing with HASP and the latest version of the rules and firmware from this thread. Very happy so far.

Can I ask for a point in the right direction on how to process some of the incoming dimmer items?

I had a look at the example for the backlight dimmer in the rules, but need to scale the 0-254 from the slider to 0-100% before sending to a Tasmota based dimmer item.
I dont have a great deal of rules experience, so there may be much more straightforward way to approach this. See code below that seems to extract the dimmer value okay, but fails at the scaling (openhabian 2.3).

 //Insert action to perform if dimmer 2 was moved
                                logInfo("HASP-rule","dimmer rule command ")    
                                logInfo("HASP-rule","dimmer state in = "+ HASP_Plate01_Plate_State_JSON_Value.state.toString
                                var Number incoming_dimmer_number = HASP_Plate01_Plate_State_JSON_Value.state
                                logInfo("HASP-rule","incoming number as a number= "+incoming_dimmer_number)  
                                var Number adjust_incoming_dimmer_number = incoming_dimmer_number*100/255     
                                logInfo("HASP-rule","outgoing= "+adjust_incoming_dimmer_number)

Log shows the original number being extracted okay, but then failing at the scaling line;

2019-02-23 15:26:26.055 [INFO ] [pse.smarthome.model.script.HASP-rule] - dimmer rule command 
2019-02-23 15:26:26.061 [INFO ] [pse.smarthome.model.script.HASP-rule] - dimmer state in = 109
2019-02-23 15:26:26.067 [INFO ] [pse.smarthome.model.script.HASP-rule] - incoming number as a number= 109
2019-02-23 15:26:26.071 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Handle HASP Master': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_multiply(java.lang.Number,java.lang.Number) on instance: null

Can anyone give me a hint, or point in the right direction?


I think the incoming_dimmer_number value is being treated as a string in your conversion formula…try changing the rule to the following:

 //Insert action to perform if dimmer 2 was moved
                                logInfo("HASP-rule","dimmer rule command ")    
                                logInfo("HASP-rule","dimmer state in = "+ HASP_Plate01_Plate_State_JSON_Value.state.toString
                                var Number incoming_dimmer_number = HASP_Plate01_Plate_State_JSON_Value.state
                                logInfo("HASP-rule","incoming number as a number= "+incoming_dimmer_number)  
                                var Number adjust_incoming_dimmer_number = (incoming_dimmer_number*100/255).intValue     
                                logInfo("HASP-rule","outgoing= "+adjust_incoming_dimmer_number)
                                Lounge_SideDimmerTest_Level.sendCommand(adjust_incoming_dimmer_number as Number)

(I also added the “as Number” in your sendCommand routine, to ensure we send a number value to the Tasmota dimmer.

1 Like

Ok so I have had some time and I have put a weather Icon on my 2nd page.


I added this item

String HASP_Plate01_weather_tranformed "Picture Number to Display on Plate 01" { channel="openweathermap:weather-and-forecast:api:local:current#condition-id"[profile="transform:MAP", function="nextionIcon.map"]}


Modify rules file to handle requesting icon being shown on screen

rule "Handle HASP Master Page 2 Status"
     Item HASP_Plate01_weather_tranformed received update or
     Item localCurrentTemperature received update or

//  Other Code here


    if (HASP_Plate01_Page_Current.state == 2)   //Only update page if you're on page 2 (avoid sending too many MQTT messages)
        var jsonString ='["weather.pic=' + HASP_Plate01_weather_tranformed.state + '", ' +

//                                other parts of your string here 
- bartus B K and the HASP team have done awesome job I just adding to it

Nextion Screen
you need to update the screen in the Nextion Editor or just download this one HASwichplate_weather.tf
I just updated it through the 8266 and it worked fine for me. Their is a HMI file in my github here

You can upload your own Icons but you can’t name the picture resource onto the screen. So you must map it to do this I used Map.


I used Map transformation to map the data

Install here - Paper UI >Add-ons >Transformations tab >Map Transformation

You need to crate a map file in your transform directory called nextionIcon.map
Contence of my map file.


The items on the left are the weather conditions and on the right is the picture to display on Nextion. If you change Icons let me know these are 50x50 but 64*64 would be better.

Next I will be putting all my aircon controls on the screen.


@denominator - this is awesome!! Definitely a useful/pretty addition. You should create a PR on aderusha’s GitHub so it can be brought into the master branch (aderusha (luma) updates the firmware on both the ESP & HMI constantly, so you wouldn’t have to add your icons every time he releases a new HMI version it they’re in the master). He’s also working on an HVAC control screen (different button/dimmer layout), so you can wait for that if you don’t want to duplicate efforts.

I have just the Demo of you HASP install, how do I add the state of a MQTT temp sensor to the HASP?
Do I add the item in the rules file, I have no Idea where to start with his one

Stewart - you’d want to send the state of the item state when the MQTT temp sensor state changes. Take a look at the page 2 rule and use it to adapt it to your case:

rule "Handle HASP Foyer Page 2 Status"
    Item <<YOURSENSORITEM>> received update or
    Item HASP_Plate02_Page_Current received update 2
    if (HASP_Plate02_Page_Current.state == 2)   //Only update page if you're on page 2 (avoid sending too many MQTT messages)
        var jsonString = '["p[2].b[4].txt=\\"' + <<YOURSENSORITEM>>.state.format("%.1f °F") + '\\""] '


You should be able to replace <> with your device item and make it work that way.

Thank BK it works but I am not sure how, I created a new rule file and just pasted the sample you gave and changed the item, reloaded the HASP and it works. The way It look to me but
correct me if i am wrong, is that
Item get and update,
it passes the sensor state to p2 b4 (page2 button 4) and then send the command to the HASP

That’s exactly what it’s doing :slight_smile: Whenever you temperature item is updated, you’re using that rule to update the “txt” component on the button (basically, the button text). The way HASP works is it simply provides the buttons/dimmers in a blank configuration, you have to set the actual “state” (value for dimmer, text for button).

Managed to build my HASP and it is connected to Openhab. I was able to configure a couple of buttons to control devices but am unable to get the status page to display anything other than the “Line 1 - 4”. Installed openweathermap and the Sitemap displays all data although the HASP does not want to display the current Temperature. Would appreciate some help. The Date and Time does not even show up

Have to tried to reset the device from the web UI as this worked for me. But failing that BK hobby said that you need to create additional sets of rules so that when an Item or thing get and update it updates the button on the screen.

@ruangreeff - check out my rules for the HASP (https://github.com/bkpsu/openhab2-conf-bartus/blob/master/rules/HASP-Foyer.rules) - line 499 is where the rule to update page 2 starts. Since there have been a few changes since the original post, make sure you:

  1. Download the latest (0.37) firmware for your plate (you can do the firmware upgrade from the plate webpage, since aderusha already approved my pull request for JSON status.
  2. Use the latest .items & .rules file from my repo, since I converted to using all JSON for commands & status.

If you’re already using the latest firmware/rules, I’d check to make sure you have the JSON string being built correctly. It’s very easy to screw that up, with all the opening/closing quotes in the string. The HASP won’t freeze or anything if you send it a bad command string, but it will just ignore it without saying anything.

I made some more changes here is what I have for the Scenes page 1.

In the HASP-master.rules file I changed case 1 to look like

                    case '1':
                            Act on buttons from Page 1 here
                        if (eventbutton == '4')
                            //Insert action to perform if button 4 was pressed
                        else if (eventbutton == '5')
                            //Insert action to perform if button 5 was pressed    


                        else if (eventbutton == '6')
                            //Insert action to perform if button 6 was pressed
                        else if (eventbutton == '7')
                            //Insert action to perform if button 7 was pressed
                        HASP_Plate01_Light_Power.sendCommand(ON) //refresh backlight timer following button press

Of course I needed to add Scene_Master to items

String Scene_Master "Bedroom Scene"

Now to add a rule to change the colour

val scn_en = '28388' //25388 is default grey
val scn_dis = '65535' // white

rule "Show Scene on Nextion"
    Item HASP_Plate01_Plate_Status changed to "ON" or
    Item Scene_Master changed
        if (Scene_Master.state == "Morning")
        HASP_Plate01_Plate_Command_JSON.sendCommand('["p[1].b[4].bco=' + scn_en + '", "p[1].b[5].bco=' + scn_dis + '", "p[1].b[6].bco=' + scn_dis + '", "p[1].b[7].bco=' + scn_dis + '"]')
        else if (Scene_Master.state == "Evening")
        HASP_Plate01_Plate_Command_JSON.sendCommand('["p[1].b[4].bco=' + scn_dis + '", "p[1].b[5].bco=' + scn_en + '", "p[1].b[6].bco=' + scn_dis + '", "p[1].b[7].bco=' + scn_dis + '"]')         
        else if (Scene_Master.state == "Night")
        HASP_Plate01_Plate_Command_JSON.sendCommand('["p[1].b[4].bco=' + scn_dis + '", "p[1].b[5].bco=' + scn_dis + '", "p[1].b[6].bco=' + scn_en + '", "p[1].b[7].bco=' + scn_dis + '"]')         
        else if (Scene_Master.state == "Bedtime")
        HASP_Plate01_Plate_Command_JSON.sendCommand('["p[1].b[4].bco=' + scn_dis + '", "p[1].b[5].bco=' + scn_dis + '", "p[1].b[6].bco=' + scn_dis + '", "p[1].b[7].bco=' + scn_en + '"]')         

Note: I change the colour to a variable

For control on the sitemap add

Switch item=Scene_Master mappings=[Morning="Morning", Evening="Evening", Night="Night", Bedtime="Bedtime"]

When you change on the sitemap it also changes on the Nextion this means you can set the same scene from different devices.

In a separate scene.rules file I have setup my rules like

rule "Set Morning Scene"
    Item Scene_Master changed to "Morning"
    // your logic here

Hi guys thank you very much for your job it’s really AMAZING!
I am done with all the hw/firmware related stuff and i am now moving to OH configuration… now what is not clear at this point is: is there already a solution which includes mqtt2.4 and new status JSON handling? I saw that @pkhajanchi started already something but there is nothing updated, is it correct?
If there is nothing i can start to have a look at it…(i dont have much time at the moment but sure i will share what i can do…)
Let me know!

I just using the old mqtt binding.

With JSON when you refresh too much stuff at once you see a flicker on the screen

Latest 0.37 from from aderusha is not working for me… Tried pre-complied one and also compiling myself… But anyways, your firmware is working fine with JSON. So, using that only as of now…

The good news is that I finally got time and upgraded OH configuration for mqtt2.4. It’s working fine and was very easy to do after you implemented JSON paths. Many thanks to you.

Sorry for the delay guys… Was busy with my work.
@rickitaly @denominator

Please find my attached things files and items files for mqtt2.4. No changes required in the rules files… Hope this helps…
plate01.items.txt (3.6 KB)
plate01.things.txt (1.6 KB)

1 Like