Sonoff NSPanel Setup

All thought things should work as is, via the expected process. For example.

when you go the the playlist page, it will sent an mtqq message that that place list screen has been enter for lounge (this will be known form the button before that linked to the page)… the backend openhab get message and works out what playlist items needs sent back, by any means you wish to implement, there will be manym but you will have full control… once done all you need to do is send the json to fill the list back, which nxpanel will render on screen.

Then when you pick a play list, same again a message will go back to say playlist one picked for lounge, your OH rules then can look at this and start sonos or whatever music serive you choose. When this being and plays the track, the playing item will update and send another mtqq back to panel to update than on the now playing screen.

They key, is all screens will have a room/context linked to them, so you dont just have one music player, you have many, for each room if you want. they is only one screen in the panel, but it know what room it’s for when you open it, so can go back get correct backend to sync view too

The status page should work for testing. it’s doesn’t sync when opened yet, but will process messages if open. check latest version;

There’s an info button in lounge…

send this kind of thing via mtqq…

'{"status": {"page_id":0, "items": [ { "id":4, "label": "Temperature", "status": "Hot" }, { "id":8, "clear":1} ] } }'

commands to cmnd/<nspanel-dev>/screen, as always

Obviously, work in progess!! :slight_smile: but helps get the idea of how you’ll integrate :slight_smile:

1 Like

Just flashed! Great job so far.Looks to good to be truth :wink:

That screen should say something to us?

It was my test one to work out how the packets worked for the advanced comms mode! lol

It’s deleted now in next version. moved on to a test swipe gesture one, which is working now
also have auto dim options. getting closer to a proper beta release

Any other significant pages people think should be in for a version 1 release?

Updated version dim/sleep (for homescreen only just now)
swipe gestures (only added to home for now)
also started the config page, swipe up from home to access
swipe right to get to first set of buttons

will add to all pages when i know it works on home.

Latest tft;

Latest berry;

IMPORTANT!

name change for the berry file, it now called nxpanel.be not nextion.be
you wll need to change your autoexec.be to load this verison instead.

2 Likes

Swipes works fine as well as dimming and turning off (excited) !

Looks great so far and working reliably for an alpha version, some thoughts for extras…

  1. Could spare space on first page be used for device status, so MQTT, WIFI connection, power outage. Button could link to a log screen. Would be useful if notifications/warnings missed etc…
  2. Could web content be loaded into a component, would be useful for loading simple web interfaces such as tasmota or possibly even OH3 widgets
  3. Could video be streamed to a component, useful for video doorbells, security camera etc…
  4. Could the screen setup be saved in a local settings file and have the driver autoload on change (or load from settings screen)

Are there examples of JSON for Alarms and component on main screen bottom left (temperature?)

Overall though, works great. nspanel is only missing a microphone/speaker for voice interaction and would be the ideal room controller. Maybe in the next version, Sonoff??

I will certainty try to accommodate all useful suggestions I can. But, I’m fighting against some serious limitations on the device. For example, a decent PC has 34,359,738,368 bytes of memory to work with, this has 3,584 bytes to delivery all the functionality! :slight_smile:

  1. Possible. But in my case my wifi & mqtt seem rock solid, so would be same 99.9% of time, which is prob not best use of the space. but possible, if defined in a way that was workable and useful.

  2. I don’t think that’s possible at all. It’s beyond the limits of the incredible limited resources you have in the Nextron. You have to just through hoops to make it does have the stuff it does.

  3. Again, no. It’s really not even close to being able. You can’t even display any content or images not built in when compiled, even the fonts you use need selected and compiled in. It’s such a limited device (the Nextion screen).

  4. Yes, the screen settings will be saved. They will be send back from the screen to tasmota and it will persist them on a restart.

As for syncing. The main screen will be global, so when you are on other screens and updates are sent, they are sent to the home screen so when you move back it’s in sync. As for the other screens, they will mtqq as you move and the backend will then sent a reply with update to sync the screen (via rules). while on the screen any updates will be refreshed real time.

because it’s dynamic and fully customisable screens at runtime, the buttons are configured as you move to a screen. so you see the refresh as you enter. Again, you move to a screen it sends mqtt to OH saying I’m going to a 4 button screen for lounge and OH sends back the json to configure it (via rules). You see this being drawn - takes a second or two. Again this is due to mem, there is just not enough to hold state locally for all combinations. It will remember the room/group used for each screen type. So if you move back to the 4 button screen for lounge, and it was there last time on lounge, it will not need to redraw all the button again, just the state. However, it was used for a 4 button screen for a bedroom say, it would need to redraw all the buttons again. So it will work for all, but will look smoother, if one room per button group type.

This is the trade off between writing a bespoke screen for one use case and writing one that can be customised and used for anyone with one screen firmware.

Maybe it will even need to load all screens each time, I will not know for sure until I do the final build and see what I have been able to cram into my 3500 bytes!!

Will try and do a video soon so you can visualise the issue. But image you open the screen, the buttons are blank, and over 1 or 2 secs, the icons appear on the buttons. get me? This is worst case, if you have more than one room using the same button group type.

1 Like

As for the perfect device. I think it would be an Android device, that could fit in a light socket like the NS does. Then you’d have full functionally for all the things above and more. To me, that’s the main issue with all the other tablet systems - is fitting and power. so one that would replace a light socket is perfect. maybe just a little bigger than the NS. perfect.

1 Like

Hey
How do you control the lighting buttons

On the stock screen, or on my customer nxpanel screen firmware?

on your customer nxpanel screen firmware
I don’t see anything published when i press the button

You cannot get water out of a stone.

But would be great :smiley:

Mike has progress day by day so beta version would come soon I guess

no they don’t ,it wasn’t quite there on that yet.

i think next version should be a semi working. it will have no ‘play/demo’ buttons, it will have real one built from your backend.

the panel will send a message like

{ "page": { "format": f, "pid": page_id: "type": "refresh" } }

Your system will need to watch for these and send a reply back

f will the source page;

11 - 2 Button
12 - 3 Button
13 - 4 Button
14 - 6 Button
15 - 8 Button

you can prob ignore that tho.

the page_id is your unique room/view number. Example, 101 for Lounge. you the return what button config you want for that. you’ll need to send back buttons to match the format.

{ "refresh" : { "pid": 101, "name": "Lounge", "buttons": [
  { "bid": 1, "label": "Light", "type": 1, "state": n, "icon": 1 },
  { "bid": 2, "label": "Hall", "type": 10, "state": 14, "next": 201, "icon": 7 },
  { "bid": 3, "label": "Fan", "type": 1, "state": n, "icon": 3 } ] } }

type would be

00 - Unused
01 - Toggle
02 - Push
03 - Dimmer 
04 - Dimmer RGB
10 - Page Link

state would be 0/1 for toggles, or the page type if link to other buttons page, there it’s type 10 (Page Link), next would be the page id to pull back the config for that page, and so on.

A refresh message would be to build the whole page, if the nxpanel sent a “sync” one, you just need to return the states of things.

Anyway. just to give you a heads up

To start with you’ll need to send the json back via your scripts. but later I thank it will be possible to add your items to specifc groups which will cause the json to be send automatic, but that’s later… you should be able to get a working version by sending it youself tho for now

pressing a button will send

{ "button": { "pid": id, "bid": n, "state": s } }

It’s almost compete. I hope to have a working version of a beta release at the weekend.

For now here is an almost compete version in which you can actually configure your setup!! :slight_smile:

You need a thing channel and a rule;

  - 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

import org.slf4j.LoggerFactory

def logger = LoggerFactory.getLogger("org.openhab.core.automation.nspanel")

/*
 * Utility functions
 */

def makeButton(bid,label,type,icon=null,state=null,next=null) {
  var str = ""<<((bid==1)?"":",")
  str<<'{"bid":'<<bid<<',"label":"'<<label<<'","type":'<<type
  if (next!=null) {
    str<<',"next":'<<next
  }
  if (state!=null) {
    str<<',"state":'<<state
  }
  if (icon!=null) {
    str<<',"icon":'<<icon
  }
  str<<'}'
  return str
}

def makePage(pid,name,format) {
  var str = new StringBuilder('{"refresh":')
  str<<'{"pid":'<<pid<<',"name":"'<<name<<'","format":'<<format<<',buttons:['
  return str
}

def str = event.getEvent()
if (str.indexOf('{"page":')!=0) {
  logger.info("ignore: "+str)
  return
}

/*
 * Get data from the page message
 * (would be good to use JsonSluper here but currently can't access)
 */

var i = str.indexOf("\"id\"")
var i2 = str.indexOf(",",i+6)
var id = str.substring(i+6,i2)
i = str.indexOf("\"format\"")
i2 = str.indexOf(",",i+10)
var format = str.substring(i+10,i2)

// check if a full refresh or just a status update
var refresh = str.indexOf("refresh")>0

var json

switch (id) {
  
  /*
   * MakePage has these params;
   *  pid - you unique id for the page (max 99)
   *  name - 25 chars of description
   *  format - The style of page (will be set from what calls it, but this is to validate)
   *   1  - home
   *   2  - 2 buttons
   *   3  - 3 buttons
   *   4  - 4 buttons
   *   5  - 6 buttons
   *   6  - 8 buttons
   *   7  - dimmer Brightness
   *   8  - dimmer Color
   *   9  - Thermostat
   *   10 - Alert 1
   *   11 - Alert 2
   *   12 - Alarm
   *   13 - Media Player
   *   14 - Media Playlist
   *   15 - Status Panel
   *
   * 10 is the root button page from the home screen
   * it's set to be an 8 button panel for now, but you'll be able to change
   *   
   * MakeButton has these params;
   *  bid - number of button (1-8), keep in correct order, can leave blank
   *  label - the label under the button (8 chars max)
   *  type:
   *   0  - Unused
   *   1  - Toggle
   *   2  - Push
   *   3  - Dimmer (press on/off, long press for advanced)
   *   4  - Dimmer RGB (press on/off, long press for advanced)
   *   10 - Page Link
   *  icon: (can add more on request!)
   *   0  - Blank
   *   1  - Bulb
   *   2  - Dimmer 1
   *   3  - Dimmer 2
   *   4  - Vaccum
   *   5  - Bed
   *   6  - House
   *   7  - Sofa
   *   8  - Bell
   *   9  - Heat
   *   10 - Curtains
   *   11 - Music
   *   12 - Binary
   *  state - button 0=off, 1=on (for toggles), or page format for links (type 10)
   *  next  - id of next page from the section below
   *    
   */
  
  case "10" :
    movie = ir.getItem("movie_room_lights").state==ON?1:0
    if (refresh) {
      json = makePage(10,'Lounge',format)
      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<<"]}}"
      print json
      print json.length()
      events.sendCommand("nxpanel_command",json.toString())
    }
    break
  case "11" :
    if (refresh) {
      json = makePage(10,'Hall',format)
      json<<makeButton(1,"A",1,4)
      json<<makeButton(2,"B",1,5)
      json<<makeButton(3,"C",1,6)
      json<<makeButton(4,"D",2,7)
      json<<makeButton(5,"E",2,8)
      json<<makeButton(6,"F",2,9)
      json<<"]}}"
      print json
      print json.length()
      events.sendCommand("nxpanel_command",json.toString())
    }
    break
  case "12" :
    if (refresh) {
      // TODO
    }
    break
}

The above is just a little 2 page example to get the idea.

Make sure you are on latest nxpanel.be & nxpanel.tft

How do you think that is?

NxPanel Specific Thread moved here;

i just want to ask something before i order one for my livingroom.Flashing tasmota and using the stock firmware can i use all the features with mqtt and openhab?What are the limitations and what can i do using stock?For example i want to use the 2 buttons as switches and 2 virtual buttons for 2 scenes plus the thermostat readings maybe control my wleds color …that kind of stuff.Do i have to flash Nxpanel for that or i can do using stock?

you can do some stuff with stock and control it to a degree. it was my first way, but it’s not great and pretty limited. and having the buttons only say ‘outlet’ when you go into the sub pages is useless. so you will be able do those things, but it will be a time consuming fight, I think. But you could.

Once you get tasoma on it’s a 5 min easy job to switch from stock to nxPanel and back. So i’d suggest having a play with each for a while, the see which suit your needs best.

But I don’t think you can go wrong getting one, for the price, it’s a very cool thing!

1 Like

thnx mate i got one in my hands today,flashed and using the nspanel.be…reading your stuff and blakadder’s ,trying to understand the protocol and make my own changes.My goal is to make a widget screen with 3 toggles and a color and to make thermostat screen to show and command my nest thermostat.Any tips are very welcome.

Yes, use NxPanel it will do that for you and save you a load of work! :slight_smile:

Describe it clearer. You want 2 on/off toggles, for what? lights?

What do you mean to ‘make a color’?

for a thermostat, you mean on/of and set a temperature?

1 Like