NxPanel - Replacement Firmware for Sonoff NSPanel

Something strange on the new media page?

I put a temp vol slider on after you said about volume, just so it sent events. but i hated it so did it properly! lol

image

You have a version in the middle, just get the lastest and it should be fine. it will send

{"media":{"volume":60}}

on mqtt, when you use it.

pause/play is now a toggle button, sending;

11:34:32.275 MQT: tele/nspanel/RESULT = {"media":{"action":"play","volume":70}}
11:34:32.942 MQT: tele/nspanel/RESULT = {"media":{"action":"pause","volume":70}}

Incoming, you’d send;

{ refresh: {pid:n, name:x, media: { album: a, track:t, artist:a, volume:v }}}

(obviosuly, in valid json with all the quotes, not my shorthand)

Home Page Messages

Here is a summary in shorthand of control messages for home screen;

{start: {pid: x, format:x (1-15)}}
{favorite: {pid: x, format:x (1-15)}}
{dim: {low:n, normal:n}}
{notifications: {text: x, [or] reset:1}}
{weather: {temp:x, summary:x, feels:x, icon:x (openweather list)}}
{clock: {date:x, hour:x, min:x, month:x, weekday:x}} // called by tasmotoa
{switches: {switch1:x, switch2: x}} // called by tasmotoa
{summary: {title:x, temp:x, [or] text:x}}
{warnings: [{id:x (1-4) , type:x (0-7) , state:x (1-3)]},...]}} 
2 Likes

If you can send me that I can have a go at it.

This is the rule code …

import org.slf4j.LoggerFactory

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

def str = event.getEvent()
if (str.indexOf('{"button": ')!=0) {
  return
}

// {"button": {"pid": 15, "bid": 1, "state": 1, "next": 0}}

var i = str.indexOf("\"pid\"")
var i2 = str.indexOf(",",i+7)
var pid = str.substring(i+7,i2) as int
i = str.indexOf("\"bid\"")
i2 = str.indexOf(",",i+7)
var bid = str.substring(i+7,i2) as int
i = str.indexOf("\"state\"")
i2 = str.indexOf(",",i+9)
var state = str.substring(i+9,i2) as int

if (pid==10 && bid==1) {
  events.sendCommand("movie_room_lights",state==1?"ON":"OFF")
}
else if (pid==10 && bid==2) {
  //
}

@m-home are you sure you have uploaded? I just downloaded from github and I still have the volume at the top.

I thought I had, it was late, so maybe I forget. I’ll release again shortly with a few other tweeks

v1.0.0-beta11

  • Media Pages Impoved
  • Home Page warnings fixed
  • New start message to assign first swipe page
{"start": {"pid":n, "format":n}}

Thanks I’ll give it a try.

I’m going around in circles here a bit - what is the best way to update the home screen. I’m currently doing the following:

Create an MQTT channel with payload cmnd/NSPanel/screen eg: mqtt:topic:7e07b147f2:dd3a2fe5ec:nx_panel_notify

Link a string item eg:
NSPanel_NxPanelNotification

Create a trigger rule to send a command with a string eg: events.sendCommand("NSPanel_NxPanelNotification", + alarm)

I then look in some example above and it seems you can send a MQTT command without going through the whole channel setup.

Can you explain how to do this?

I want to update the home screen with the favorite, or just update some of the values.

17:34:08.749 MQT: tele/NSPanel/RESULT = {“init”: {“nx-panel”: “v1.0.0-beta10”, “berry”: “”, }}UU
17:34:08.757 BRY: ERROR, bad json: {“init”: {“nx-panel”: “v1.0.0-beta10”, “berry”: “”, }}UU

Not sure this is important but I got this message after the flash.

It has an extra comma at end. I think you see it because you have weblog 4 on?
It’s not important, but I’ll remove.
It’s the messgage it sends after boot, so your backend can know the nxpanel has booted. in case you might want a rule to set the default hotkey, or right swipe after a boot. I’m still not sure what is best for the user. for it remember last by saving to device and get from server…

You can send directly from a script without doing that, correct. It’s just nice to have item you can use to do it in addition, because you can then do it via the basic OH things that just change the item, but in scripts it’s probably better to send directly.

You do this sort of thing;

rule "Init xmasDefault"^M
when^M
    System started^M
then^M
    mqttActions = getActions("mqtt", "mqtt:broker:422c3d88")^M
end^M
^M
rule "Xmas Lights on"^M
when^M
  /*^M
  Channel "astro:sun:local:eveningNight#event" triggered START^M
  */
  Channel "astro:sun:local:nauticDusk#event" triggered START
then
  
  mqttActions.publishMQTT("cmnd/rf_bridge/rfkey1","")
  mqttActions.publishMQTT("cmnd/rf_bridge/rfkey2","")
  */
  mqttActions.publishMQTT("cmnd/cabin-socket/POWER","ON")
  logInfo("Lights","Xmas on at sunset")
end

This is a standard rule not a groovy one, becuase I think you are more ok with that style? But it just the same in groovy and javascript. You get the mqtt broker channel from the sytem, then publish your mqtt to it directly.

Hope that was what you meant.

v1.0.0-beta11 #2

  • 2nd attempt to fix warnings
  • US Version - Landscape support! (early version)
{"landscape": 1}

The warning bar had a bell when sending notifications
What happened to him?

var index = this.event.toString().indexOf("{");

var jsonObject = JSON.parse(this.event.toString().substr(index,this.event.toString().length()));

if (this.event.toString().includes("button") ){ 
  var pid = parseInt(jsonObject["button"]["pid"],10);
  var bid = parseInt(jsonObject["button"]["bid"],10);
  var state = parseInt(jsonObject["button"]["state"],10);
  
  // double switch statement hell
  switch(pid){ // Pages go here
    case 10:
      switch(bid){ // Individual buttons and stuff go here
        case 1:
            items.getItem('BedroomFan_Power').sendCommand(state==1?"ON":"OFF");
          break;
        default:
          console.log("Failed to decode message bid");    
      }
      break;
   default:
    console.log("Failed to decode message pid");  
  }
}

Sorry it took me so long, it turns out i already did make one so here you go.

1 Like

Yes, looks like I broke that. fixed in beta12. should be there now to download.

How are you getting on with this?

Yes it loads fine. Now I’ve got @Pentium4 JavaScript I can decode the button pushes easier. Will have a go later today if I have time.

Thanks, what does the string length 10 refer to? I will need to adapt this for other screens.

Hi there, i first want so say thank you! I just received my NSPanel last weekend and was since then researching how to get a custom UI that fits my needs on it. This project looks awesome and I really feel this took you a lot of effort.

One question: is this ns-flash.jar thing still needed? As i saw at another project (https://github.com/joBr99/nspanel-lovelance-ui) they are using the FlashNextion command directly with the TFT file instead of using chunk files: FlashNextion http://192.168.75.30:8123/local/nspanel.tft

Are they using an improved/different implementation of the command?