NxPanel - Replacement Firmware for Sonoff NSPanel

I think you added the rule to the wrong thing. It’s not the item, it’s the channel you add it to directly. it’s trying to call method of the event, as thought it was a channel event. since you are triggering it off an item, it’s an item event. and that does not have the same methods which the rule is expecting.

This is my trigger for that rule

Hi Mike,

with Major Update the flash process is workig, for whatever reason, thanks!

I understand. And the software can do it. I still struggle with the syntax in mqtt, though.
I´d be happy if you could create a simple example fo the status screen as JSON payload. From there I can adjust it to my needs.
I am confused by (favorite, status, refresh, etc)

 mosquitto_pub -t "cmnd/nspanel/nxpanel" -m '{"refresh":{"pid":17,"name":"Info Page","status":[{"id":1,"text":"Door","value":"Open"},{"id":2,"text":"Temp","value":"4","icon":3}]}}'

I am confused as well :frowning:

A guide to how it works

Can you confirm a few things first.

Do you have a working rule that will return your button page for the first button screen “10”?

Refresh Event

As soon as you swipe from home, nxpanel will send;

{"page": {"format": 6, "pid": 10, "type": "refresh"}}

meaning, tell me how to draw a “8 Button Screen” (type 6) for that page with id 10.

Your rule (as described above in this thread) should then send the reply refresh message to tell nxpanel how to render the button page, such as;

{"refresh":{"pid":10,"name":"Lounge","format":6,buttons:[{"bid":1,"label":"Movie","type":1,"state":1,"icon":1},{"bid":2,"label":"Lounge","type":1,"state":0,"icon":1},{"bid":3,"label":"Hall","type":2,"icon":6},{"bid":4,"label":"Bedroom","type":10,"next":11,"state":5,"icon":5},{"bid":5,"label":"Temp","type":10,"next":12,"state":9,"icon":9},{"bid":6,"label":"Light","type":1,"icon":3},{"bid":7,"label":"Dimmer","type":10,"next":13,"state":8,"icon":3},{"bid":8,"label":"Status","type":10,"next":17,"state":15,"icon":16}]}}

At this point, you button screen should look fine.

Please confirm you get this far?

You should be clear on how this fundamental process works before continuing.

@Jens_Wensing asked about the status page. In the above example my button 8 links to the status page.

{"bid":8,"label":"Status","type":10,"next":17,"state":15,"icon":16}

This says;

  • type: 10, the button is a link to another screen
  • next:17, the page it links to has an id of 17
  • icon: 16, use the information icon on the label
  • state: 15, this is the page type, 15 is the status page

So, when you press this button, if will open the status page for id 17, this again (just like the button page) will make nxpanel send another request how to render that page;

{"page": {"format": 15, "pid": 17, "type": "refresh"}}

It’s asking you backend how to draw the status page for id 17. It’s send the 15 (status page), but it’s more for reference and not needed. You should know your id 17 is a status page and send appropriate json for that, without being told the 15.

Your rule, once again, will be passed in the 17 so it knows what to do, since 17 is a status page your rule will send back the json for that page, which will be something like this;

{"refresh":{"pid":17,"name":"Info Page","status":[{"id":1,"text":"Door","value":"Open"},{"id":2,"text":"Temp","value":"4","icon":3}]}}

This is the process for all pages.

  • You move to a page
  • NxPanel sends the page id request over mqtt
  • You backend rule get the message, via a rule listening to the channel
  • Based on the page id, the rule returns the json needed for that specific page to render

Sync event

The below, is for perfomance, you should do it. But make sure you fully understand the above first.

The only slight deviation from that process is the sync event. This is to make things faster. If you move to a screen (button screen) and that screen was last used to render page id (10, for example) and you want the button screen rendered as 10 again. It know that all the labels and icons are correct, so it doesnt need to ask the backend how to refresh the whole page. So instead of send a;

{"page": {"format": 6, "pid": 10, "type": "refresh"}}

It will send a

{"page": {"format": 6, "pid": 10, "type": "sync"}}

This means your backend doesn’t need to send everything about the page. The only things that would be visually different could be the on/off states of the button, so that’s all you’d need to send;

{"sync":{"pid":10,buttons:[{"bid":1,"state":1},{"bid":2,"state":0}]}}

This makes the page faster to sync. You could have just send a refresh like first time. That would have worked. But a sync will make it faster. You can only do this for the button pages as I assumed this would be the important pages. All other pages will never send a ‘sync’ they will always send a refresh so you will send a full refresh back.

3 Likes

Thank you.
Based on that information I will try to setup the first page.
Great job from your side!

For those not aware. There is a great command line tool which lets you send mqtt on the fly. It’s very handy when testing things out before you have your rules 100%

 mosquitto_pub -t "cmnd/nspanel/nxpanel" -m '{"refresh":{"pid":17,"name":"Info Page","status":[{"id":1,"text":"Door","value":"Open"},{"id":2,"text":"Temp","value":"4","icon":3}]}}'

It lets you send commands nice and easy. If the status page was active as pid 17, the above would set the display on it.

Linking switches on the NxPanel to OH items without rules

This works great!

Create a new channel on your NSPanel like this;

  - id: nxpanel_movie_light
    channelTypeUID: mqtt:switch
    label: Movie Light - 10:1
    description: ""
    configuration:
      postCommand: true
      formatBeforePublish: '{"sync":{"pid":10,"bid":1,"state":%s}}'
      commandTopic: cmnd/nspanel/nxpanel
      transformationPattern: 'REGEX:(.*\"pid\": 10.*\"bid\": 1.*)∩JSONPATH:$.button.state'
      stateTopic: tele/nspanel/RESULT
      off: "0"
      on: "1"

Then, instead of creating a new item for it, just link it to the existing item used for the switch. They are now both in sync and work perfectly. Thanks to @jonny211 for pointing me in right direction for the nice solution! :slight_smile:

UPDATE 1: The above meoth does not work 100% for me yet. Still needs some investigating. I works great from a UI perspective, both OH item and NSPanel button control the the light perfecty, changing either keeps the other in sync. The issue is using the phyical switch, it does not push the state back right, see here for more details! :confused:

UPDATE 2: Sorted! With some excellent support from @rossko57. Create your NxPanel channel as described above. Add this channel to your existing switch item, ensuring you use the follow profile. The key points in making this work are; 1 - Using follow on NxPanel channel and, 2 - Setting Is Command on the channel too!

1 Like

The rule for sync two itme and work for me

rule “sync lights”
when
Item lamp_A changed or
Item lamp_B changed
then
if(lamp_A.state != newState) lamp_A.sendCommand(newState.toString)
if(lamp_B.state != newState) lamp_B.sendCommand(newState.toString)
end

glad it’s working for this :slight_smile: I find in OH there is often many ways to do the same thing, and it’s not always clear which is the best!

Version 1.0.1

This is the first release after the improved upgrade flashing was added, so the first test it works!! :slight_smile: No bugs please! lol

It will auto do it within 24hrs for those that have enabled auto updates and testing ones. You can force the update by typing 9998 Red, in any alarm page, or by typing autoflash in the tasmota console.

Feedback on how it worked, good or bad, would be nice.

The main change in this version is a fix to a long standing, but hard to track down , bug where some messages would get lost and an error appeared in console.

It’s getting very close to what I would say is a stable release now.

I will try and do some proper documentation after that.

How are people getting on in general? I appreciate it has been harder to set up without full documentation and during development.

I changed the .be file and now I can not sync the unit with OH
I get {“Command”:“Unknown”} in the console of tasmota

Please send the log file with “weblog 4” set. when you think it’s trying to sycn, so I can see the message to and from the nxpanel.

16:56:51.397 CMD: InstallNxPanel
16:56:51.412 MQT: stat/tasmota_7DDCCC/RESULT = {“Command”:“Unknown”}

you need to send more of the log so I can see what lead up to that. and enable detail logs by typing

weblog 4

needs enabled by entering that in the tasmota console, so you can see what was sent to result in that message.

It would be better to type;

restart 1

which reboots the device, then send me all the logs from the boot until the error. So I can see the issue.

did you reboot after putting the new nxpanel.be file there? It kinda looks like it’s just not using the new one.

this look like this not connection

17:07:21.355 CMD: Grp 0, Cmnd ‘WEBLOG’, Idx 1, Len 1, Data ‘4’
17:07:21.366 MQT: stat/tasmota_7DDCCC/RESULT = {“WebLog”:4}
17:07:21.873 WIF: Checking connection…
17:07:41.873 WIF: Checking connection…
17:08:01.873 WIF: Checking connection…
17:08:21.873 WIF: Checking connection…

00:00:00.003 HDW: ESP32-D0WD-V3
00:00:00.004 HDW: FoundPSRAM=0 CanUsePSRAM=0
00:00:00.079 UFS: FlashFS mounted with 288 kB free
00:00:00.183 CFG: Loaded from File, Count 155
00:00:00.199 QPC: Count 1
00:00:00.201 CFG: CR 362/699, Busy 0
00:00:00.208 CFG: CR 362/699, Busy 0
00:00:00.210 ROT: Mode 1
00:00:00.212 BRY: GC from 1418 to 1418 bytes, objects freed 0/1 (in 1 ms)
00:00:00.225 BRY: GC from 3621 to 3043 bytes, objects freed 5/29 (in 0 ms)
00:00:00.294 BRY: GC from 4409 to 3849 bytes, objects freed 3/47 (in 1 ms)
00:00:00.294 BRY: Berry initialized, RAM used=3849
00:00:00.319 BRY: no ‘preinit.be’
00:00:00.323 SRC: Restart
00:00:00.327 Project tasmota - Tasmota Version 10.1.0(tasmota)-2_0_1_1(2021-12-08T14:50:20)
00:00:00.880 BRY: GC from 7843 to 6712 bytes, objects freed 15/98 (in 2 ms)
00:00:00.925 BRY: GC from 13592 to 12632 bytes, objects freed 16/186 (in 1 ms)
00:00:00.956 BRY: Exception> ‘syntax_error’ - /autoexec.be:285: ‘tcpclient’ undeclared (first use in this function)
00:00:00.958 stack traceback:
00:00:00.969 : in native function
00:00:00.969 : in function load
00:00:00.970 : in function load
00:00:01.141 WIF: Checking connection…
00:00:01.142 WIF: Attempting connection…
00:00:01.641 WIF: Connecting to AP1 jonnys Channel 5 BSSId F0:2F:74:C6:FF:E0 in mode 11n as tasmota-7DDCCC-7372…
00:00:02.653 WIF: Checking connection…
00:00:02.654 WIF: Attempting connection…
00:00:03.653 WIF: Checking connection…
00:00:03.654 WIF: Attempting connection…
00:00:03.654 WIF: Checking connection…
00:00:03.655 WIF: Attempting connection…
00:00:05.654 WIF: Checking connection…
00:00:05.655 WIF: Connected
00:00:05.762 NTP: Synch time…
00:00:05.887 RTC: UTC 2022-02-17T15:21:37, DST 2022-03-27T02:00:00, STD 2022-10-30T03:00:00
17:21:37.000 NTP: Synched
17:21:37.028 HTP: Web server active on tasmota-7DDCCC-7372 with IP address 10.0.0.32
17:21:38.906 MQT: Attempting connection…
17:21:38.946 MQT: Connected
17:21:38.955 MQT: tele/tasmota_7DDCCC/LWT = Online (retained)
17:21:38.978 MQT: cmnd/tasmota_7DDCCC/POWER =
17:21:38.981 MQT: Subscribe to cmnd/tasmota_7DDCCC/#
17:21:38.988 MQT: Subscribe to cmnd/tasmotas/#
17:21:38.995 MQT: Subscribe to cmnd/DVES_7DDCCC_fb/#
17:21:39.001 MQT: Unsubscribe from homeassistant/status
17:21:39.014 MQT: tele/tasmota_7DDCCC/INFO1 = {“Info1”:{“Module”:“NSPanel”,“Version”:“10.1.0(tasmota)”,“FallbackTopic”:“cmnd/DVES_7DDCCC_fb/”,“GroupTopic”:“cmnd/tasmotas/”}}
17:21:39.034 MQT: tele/tasmota_7DDCCC/INFO2 = {“Info2”:{“WebServerMode”:“Admin”,“Hostname”:“tasmota-7DDCCC-7372”,“IPAddress”:“10.0.0.32”}}
17:21:39.057 MQT: tele/tasmota_7DDCCC/INFO3 = {“Info3”:{“RestartReason”:“Software reset CPU”}}
17:21:39.066 MQT: stat/tasmota_7DDCCC/RESULT = {“POWER1”:“OFF”}
17:21:39.072 MQT: stat/tasmota_7DDCCC/POWER1 = OFF
17:21:39.079 MQT: stat/tasmota_7DDCCC/RESULT = {“POWER2”:“OFF”}
17:21:39.085 MQT: stat/tasmota_7DDCCC/POWER2 = OFF
17:21:39.098 TFS: File ‘autoexec.bat’ not found
17:21:39.113 SRC: MQTT
17:21:39.115 CMD: Grp 0, Cmnd ‘RESULT’, Idx 1, Len 27, Data ‘{“NSPanel”:{“ATCEnable”:0}}’
17:21:39.130 MQT: stat/tasmota_7DDCCC/RESULT = {“Command”:“Unknown”}
17:21:39.164 SRC: MQTT
17:21:39.166 CMD: Grp 0, Cmnd ‘NXPANEL’, Idx 1, Len 52, Data ‘{“page”: {“format”: 6, “id”: 10, “type”: “refresh”}}’
17:21:39.179 MQT: stat/tasmota_7DDCCC/RESULT = {“Command”:“Unknown”}
17:21:39.774 QPC: Reset
17:21:41.763 APP: Boot Count 87
17:21:42.697 CFG: Saved, Count 156, Bytes 4096
17:21:44.367 BRY: GC from 18263 to 3808 bytes, objects freed 58/44 (in 6 ms)
17:21:44.381 MQT: tele/tasmota_7DDCCC/STATE = {“Time”:“2022-02-17T17:21:44”,“Uptime”:“0T00:00:13”,“UptimeSec”:13,“Heap”:144,“SleepMode”:“Dynamic”,“Sleep”:0,“LoadAvg”:371,“MqttCount”:1,“Berry”:{“HeapUsed”:3,“Objects”:44},“POWER1”:“OFF”,“POWER2”:“OFF”,“Wifi”:{“AP”:1,“SSId”:“jonnys”,“BSSId”:“F0:2F:74:C6:FF:E0”,“Channel”:5,“Mode”:“11n”,“RSSI”:66,“Signal”:-67,“LinkCount”:1,“Downtime”:“0T00:00:05”}}
17:21:44.432 MQT: tele/tasmota_7DDCCC/SENSOR = {“Time”:“2022-02-17T17:21:44”,“ANALOG”:{“Temperature1”:-7.5},“ESP32”:{“Temperature”:52.2},“TempUnit”:“C”}
17:21:48.789 MQT: tasmota/discovery/4417937DDCCC/config = {“ip”:“10.0.0.32”,“dn”:“Tasmota”,“fn”:[“Tasmota”,“”,null,null,null,null,null,null],“hn”:“tasmota-7DDCCC-7372”,“mac”:“4417937DDCCC”,“md”:“NSPanel”,“ty”:0,“if”:0,“ofln”:“Offline”,“onln”:“Online”,“state”:[“OFF”,“ON”,“TOGGLE”,“HOLD”],“sw”:“10.1.0”,“t”:“tasmota_7DDCCC”,“ft”:“%prefix%/%topic%/”,“tp”:[“cmnd”,“stat”,“tele”],“rl”:[1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],“swc”:[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1],“swn”:[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],“btn”:[0,0,0,0,0,0,0,0],“so”:{“4”:0,“11”:0,“13”:0,“17”:0,“20”:0,“30”:0,“68”:0,“73”:0,“82”:0,“114”:0,“117”:0},“lk”:0,“lt_st”:0,“sho”:[0,0,0,0],“ver”:1} (retained)
17:21:48.805 MQT: tasmota/discovery/4417937DDCCC/sensors = {“sn”:{“Time”:“2022-02-17T17:21:48”,“ANALOG”:{“Temperature1”:-7.5},“ESP32”:{“Temperature”:52.2},“TempUnit”:“C”},“ver”:1} (retained)
17:21:59.108 WIF: Checking connection…

this is wrong.

I download the nxpanel.be from the git location and reinstalled on mine. it’s def right one.

you def have this?

I’d make sure you are on a current tasmota too.

I’m with the same version VERSION = “1.1.2”
Do I need to change something inside the file?

no, you need to change nothing in the file. don’t!!

Should get this;

00:00:00.003 HDW: ESP32-D0WD-V3 (PSRAM)
00:00:00.139 UFS: FlashFS mounted with 276 kB free
00:00:00.276 CFG: Loaded from File, Count 295
00:00:00.292 QPC: Count 1
00:00:00.880 BRY: Berry initialized, RAM used=4097 bytes
00:00:00.923 Project tasmota - NS Panel Version 11.0.0.1(tasmota)-2_0_2_1(2022-02-16T11:30:27)
00:00:02.332 NXP: Initializing Driver

can you delete the .bec file. This is the compiled version tasmota makes if one not there. you shouldnt need to, but try. also, upgrade you tamsota to make you are on latest one, ones from around christmas had a tcpclient bug in them
image
this looks old…