Sonoff NSPanel Setup

yes toggles for lights and a color widget to control my wled strip.As for the nest termostat yes i want set temperature and to show me the current temperature of the Nest.

v1.0.0-beta5

Some small fixes around sync refreshing

IMPORTANT To keep things in order I renamed the id field that is sent to the rule to be pid as below;


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

You’ll need to change that, and the 6 to 7 in the substring as it’s a char longer now.

i have created a widget for my spotlights working really well,toggle it and i get

{"NSPanel":{"ctype":"group","id":"1","params":{"switch":"on","switches":[{"switch":"on","outlet":0}]}}}

or

{"NSPanel":{"ctype":"group","id":"1","params":{"switch":"off","switches":[{"switch":"off","outlet":0}]}}}

being the coding noob i am just need an example how to create a channel to read and command the state of this widget …

Looks like you are using the stock firmware not nxpanel. support for stock will be limited here, as I think most in this thread are using nxpanel now. You’d be able to call your spotlights “Spotlights” and not “outlet1” if your did :slight_smile:

But, in the channel you need to chain together two expression plugins in the input mapping field of the channel. The REGEX(text) one to filter those messages that only relate to the switch you are dealing with (as it will get all messages). and chain that with the JSON one so you can do NSPanel.params.switch to get at the value you are after. If you search you should find examples of chaining REGEX to get at values in JSON.

But, i’d suggest looking at NxPanel on the device before you spend a lot of time on a dead horse.

Hi Michael,
Thanks for posting this, and especially your nspanel code on Github.
I’m doing much the same as you: porting old ESP32 and Nextion code to an NSpanel.
Nothing would work until I read the above, and looked at your code.
Fancy swapping pins 16 and 17, AND needing pin4 low.

i have found a weird bug(?) …using the original blakadder’s nspanel.be .When i change the thermostat’s setting for example from 19 to 20 i get at mqtt

{"NSPanel":{"ATCMode":0,"ATCExpect0":20}}

and everything is working ok parsing and transforming reading the number setpoint in openhab
but when i set to 21 and only then i get

{"NSPanel":{"ATCMode":0,"ATCExpect0":21}B}}

that “B” at the end is cause error

[WARN ] [t.generic.ChannelStateTransformation] - Executing the JSONPATH-transformation failed: An error occurred while transforming JSON expression.

This is only happening with “21” value…
my openhab incoming Value Transformation is

REGEX:(.*ATCExpect0.*)∩JSONPATH:$.NSPanel.ATCExpect0

Anyone knows why this is happening?

Yes. I remember seeing that too. But I didn’t really use stock long enough to dig too much, I don’t see anything like that nxpanel, so I’m seeing it’s some bug or corruption in the Nextion part, also sending data to the nextion has CRC checking to see if corruption over serial happened, there is no such thing coming back. so there is alwasy a risk of getting interferecing over serial causing weird stuff. But I don’t think this error is that, as it’s always a B near end of message.

can i change my transformation to something else to workaround it?

could try chaining a regex expression before that to do a substiution?

s/}B}/}}/

As in here

seems cant make it work around… i ve tried transformation chains like

REGEX:(.*ATCExpect0.*)∩REGEX:(s/}B}/}}/)∩JSONPATH:$.NSPanel.ATCExpect0

but nothing seems to work ,i posted the bug at blakadder/nspanel github issues.

I’m not sure that’s going to help. Blakadder’s part is right, he’s just passing on what the nextion sends, which is correct. Not much more he can do. The issue is the HMI or the comms, either of which he can do much about because is closed stock. I think you’d be better looking for help on how to make the REGEX work, because that should sort it easiest. You might also want to put weblog 4 on and check it is just a B and not some other dodgy chars hiding in there

Just wanted to post my current project state plus try and get som help…
I’m an Openhab user using ESPHome. Hope my progress can be of use to someone.
I’ve tried to create something with the main purpose of easy control of lights in all rooms but with the possibility to go deeper into each room to control basically everything. Plus dynamic pages that pop up on special events: Knock on door, coffee brew, deactivate alarm. Use MQTT to communicate with Openhab.

Help is about the fact that I can’t add any more components to the code because that causes the ESP to not boot up. The code compiles and gets uploaded but it then just gets stuck with a flashing first page. Very annoying since I’ve come so far with the project. Flash memory is about 65% use but it feels like it has to much to initiate at boot up so it just gives up. Anyone have any ideas of what the root cause could be?

Yaml and HMI file is uploaded on Github:
https://github.com/lillaeriika/NSPanel

Even though it wouldn’t run, becuase you are ESPHome, have you tried flashing Tasmota and then uploading your TFT with that? You’d at least know if it’s an issue with the TFT or with the ESPHome flashing process.

Im pretty sure it is not a problem with the TFT file. The TFT file works. I haven’t changed that. It is adding code to ESPHome that makes it not boot.

Edit: I’ve done some more investigation. Working theory right now is that I was using retained messages on my MQTT channels in Openhab. I thought that would be a good idea so a newly started panel would get the latest value on all components. But thinking about it I don’t think the ESP likes receiving data from 20 mqtt topics on boot plus a lot of code that is supposed to execute for each received message. At the same time it is trying to initialize every ESP component as well. Looks like I can add some more stuff for the moment at least.

I look in the Tasmota console and this message keeps repeating 1/sec.

00:25:17.584 MQT: stat/nspanel/RESULT = {“NxPanel”:“Done”}

The MQTT server is getting both the stat and the cmnd topics getting messages about 1/sec

cmnd/nspanel/nxpanel {“sync”:{“pid”:10,“bid”:2,“state”:0}}

stat/nspanel {“NxPanel”:“Done”}

I can’t track down what is doing it. I have disabled and reenabled rules. Is this expected behavior to repeat these messages even when the panel isn’t being touched?

Turn on weblog 4 so you can see all the detailed messages in and out.

When you see these messages, does the display have red sync light on?

If this is the case, it’s because your nxpanel is sending a page request for a specific page id and you backend is either not sending anything, or it’s sending a refresh or sync message for a different pid other than the one requested.

@Erik_Bergstrom Glad it’s going, this is prob not the best thread if you are using ESPHome though, this is really around the Tamsota variant of communication. There are specifc thread based solely around the ESPHome way, you’d probably getter more useful help there.