NxPanel - Replacement Firmware for Sonoff NSPanel

Yes, all normal.

The panel is messaging out asking how it should refresh that page, waiting for OH to reply. If you look up the thread, you’ll see others asking too. You need to create a Channel to get the mqtt events. Then you create a rule to handle the messages, example also above in the thread. The rules get’s the message you showed above and will send back to nxpanel how to show the page. Telling the the icons and buttons you want.

I’m sure others can help you here too, if you can’t figure it from fully reading the thread.

For the weather, you need to install the openweather binding and add a rule for when the weather item changes. when it does, you send;

'{ "weather": {  "temp": 7, "icon": "04n", "feels": 4 } }'

back to the panel.

thnx,i read the entire thread 2-3 times but i am still confused.
i have created the 2 channels

- id: nxpanel_command
    channelTypeUID: mqtt:string
    label: NxPanel Command
    description: ""
    configuration:
      commandTopic: cmnd/nspanel/nxpanel
  - id: nxpanel_page_trigger
    channelTypeUID: mqtt:trigger
    label: NxPanel Page Trigger
    description: ""
    configuration:
      stateTopic: tele/nspanel/RESULT

and created the rule with the groovy script triggered by nxpanel_page_trigger channel.Still cant sync the screen.I dont understand what to do with the nxpanel_command channel also.

i have openweatherMap binding installed ,can i have an example rule for how to send the info?

v1.0.0-beta8

Status page working

image

Refresh event is like this;

'{"refresh":{"pid":18,"name":"Info Page","status":[{"id":1,"text":"Door","value":"Open","icon":2},{"id":2,"text":"Temp","value":"23"}]}}'

Shorter sync event

'{"sync":{"pid":17,"status":[{"id":4,"value":"Big"}]}}'

colours, “icon”: 1-3

pick your own triggers, they are mine

events.sendCommand("ns_temperature",""+ir.getItem("CabinDevices_CabinRoomTemperature").state.intValue())

def weather = ir.getItem("weather_icon_id").state.toString()
def outdoorTemp = ir.getItem("outdoor_temp").state.intValue()
def apparentTemp = ir.getItem("apparent_temperature").state.intValue()
def wind = ir.getItem("forecast_wind_speed").state.intValue()

def json = String.format(
  "{ \"weather\": {  \"temp\": %d, \"icon\": \"%s\", \"feels\": %d } }",
  outdoorTemp, weather, apparentTemp, wind)

events.sendCommand("nxpanel_command",json)

btw, that script is a groovy one so if you use that, be sure to install groovy automation plugin

Any chance to get a portrait mode of this tft for americans? I’m more than willing to be a test dummy.
(I’m currently unaware of any mode for this so correct me if I’m wrong.

Unfortunately, this would be a huge task of redoing everything, as all the components are designed like that.

I do not think there is any real difference that would stop you using the EU one in the US. other than hole size. Maybe an easier option, if NxPanel would work better for you than stock, is just to get an EU one and mount in a EU size hole? Just a suggestion. But doing a version in a different orientation is beyond the scope of work for me.

I think a few people in EU got a US one as part of the screen isn’t behind the bezel on that, with a view of mounting it horizontally, with buttons at right, not below. Even this doesn’t work ideal with Nxpanel, as the onscreen indicator for the hardware buttons are in the wrong place, and internal hidden UI buttons needed for making it work, are shown, so looks a bit messy. For them I can probably hide the buttons, but the indicators are still in wrong place and the display will not look cantered.

So in summary, NxPanel is really totally optimized for the EU version, because that’s what I have and use

Sorry, can’t be of more help.

Changing the hole size isn’t possible for most houses (including mine) I guess I’ll just wait for another solution
Or wait for the source so I can convert it to portrait mode

code, might not be too bad, i could move most of that and just move the components around. most work would be in the gimp for the screens. might look at it after the EU is all complete and 100%. there is not shared code or core libs in nextion, so everthing is duplication all over the place. it would be pointless looking at it until EU was 100% solid, so code didnt need changed in 2 places during development.

I’d say give the EU one a good test and make sure it worked at did everything you need well. bc I wouldn’t be look at doing anthing in a US one that wasn’;t in EU, it would be an “as-is” port.

Yeah I tried it and it was awesome, looked good and worked exactly how it should have. I will patiently wait for this.

Ok I’ve finally managed to get text rules working with this which makes life a lot easier for me. I had to create another channel running of the MQTT message tele/nspanel/result and linking an Item. You can then get at the json strings.

I have the Music screen running. I can pick up the strings you mentioned.

I did the page as follows which I think is causing a problem in the groovy script I’m not sure about how to code the Music page - no title is coming up. I get an error listed below and in the console

case "10" :
      if (refresh) {
      json = makePage(10,'Master Bedroom',6)
      json<<format<<',buttons:['
      json<<makeButton(1,"Walls",1,1)
      json<<makeButton(2,"Bath",1,1)
      json<<makeButton(3,"Blinds",1,10)
      json<<makeButton(4,"Velux",2,10)
      json<<makeButton(5,"Music",10,11,13,11)
      json<<"]}}"
    } else {
      json = '{ "sync": {} }'
    }
    events.sendCommand("nxpanel_command",json.toString())
    logger.info("nxpanel_command: "+json)
    break
  case "11" :
    if (refresh) {
      json = makePage(11,'Music',13)
      json<<format<<',buttons:['
      json<<makeButton(1,"Walls",1,1)
      json<<makeButton(2,"Bath",1,1)
      json<<makeButton(3,"Blinds",1,10)
      json<<makeButton(4,"Velux",2,10)
      json<<makeButton(5,"Music",10,11,13,11)
      json<<"]}}"
    } else {
      json = '{ "sync": {} }'
    }
    events.sendCommand("nxpanel_command",json.toString())
    break
 }

I get the openhab.log error :

2022-02-09 18:23:20.757 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'ca275a12c8' failed: javax.script.ScriptException: java.lang.StringIndexOutOfBoundsException: begin 6, end -1, length 26

And In the console:

18:34:09.820 MQT: tele/NSPanel/RESULT = {"media":{"action":previous"}}
18:34:09.826 BRY: ERROR, bad json: {"media":{"action":previous"}

There’s an extra quote after previous. The sent mqtt message is being improperly formatted.

yes thats the problem! @m-home can you fix it!

I guess I´m not experienced enough… I try to create a page. Like the Status page.
Unfortunately I´m not using Openhab or similar. I work with Loxone Automation and use MQTT.
I can send a JSON Package by the MQTT Function. Weather for example works fine with conversion and all.
But how the heck can I create a page? I guess I´m missing a crucial information here…
Thank you for reading, and your hard work!

1 Like

Making the page is not so hard it’s just json like the weather. but you need to send it in response to some incoming mqtt

NxPanel send MQTT to you
you send panel MQTT back to make page

It’s conversational. Weather is one-way traffic, you just send to the NxPanel.

You need something that can handle messages as well as send. Most system like OH, have a way to define rules. If X happens do Y. In this case, if panel asks for page 1, send page 1 to panel.

I know nothing about your system, so can’t really help. But I’m sure it must do something the same, or it would be useless. You could do it off you system though. Anything on your network could get the message and send the reply.

v1.0.0-beta9

Colours added to status page. add “icon”: [1…3] to the status message. Will prob rename to color, next release, be warned.
image

Fixed missing quotes in media messages.

Videos

Once some people have their systems working slick for them, it would be great to see a few videos of them in action! :slight_smile:

I have a problem with sync
When I restart the unit sends a sync command and it works
But that I move a page no command is sent
And I have a red light
I got this { “sync”: null }"

Have the same issue !

Wish to find a guideline how to define MQTT commands to manipulate NSPanel.

Waiting for that day :slight_smile:

1 Like

v1.0.0-beta10

Media revamp

image

Sorry, I’ve not updated things!!! been a bit busy

Try adding this;


def makeEmptySync(pid) {
  var str = new StringBuilder('{"sync":')
  str<<'{"pid":'<<pid<<'}}'
  return str
}

and then use it like this;

  case "10" :
    movie = ir.getItem("movie_room_lights").state==ON?1:0
    if (refresh) {
      json = makePage(id,'Lounge',format)
      json<<format<<',buttons:['
      json<<makeButton(1,"Movie",1,1,movie)
      json<<makeButton(2,"Cabin",1,1,0)
      json<<makeButton(3,"Hall",2,6)
      json<<makeButton(4,"Bedroom",10,5,5,11)
      json<<makeButton(5,"Temp",10,9,9,12)
      json<<makeButton(6,"Light",1,3)
      json<<makeButton(7,"Heat",10,9,3,15)
      json<<makeButton(8,"Status",10,16,15,17)
      json<<"]}}"
    } else {
      json = makeEmptySync(10)
    }
    events.sendCommand("nxpanel_command",json.toString())
    break

The reason is, I needed to add the page id to the message, so if it’s on the wrong page it can ignore the message. Otherwise, message sent from your system start to update wrong things!!! It was a bug I fixed but forget to notify users of the rule change needed!!

Opps!!!

:slight_smile: