-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for ITead's SONOFF NSPanel touchscreen display (ESP32 with custom Nextion HMI screen)? #1469
Comments
I am backing the NSPanel so hope to get one ASAP, but without it in front of me I cannot make any assumptions about how it works. I have seen the IO pinout and actually spent an hour or 2 looking at the fcc pictures and had all of the pins listed right before they posted that update on kickstarter 🤦♂️ |
@jesserockz Suggest that you write a short mail to "Jeri Shi" jerry.shi@itead.cc, "Stan Li" Stan.li@itead.cc, and "Daniel Zhan" daniel.zhan@itead.cc telling them who you are and ask them nicely if they would be willing to send you a prototype or preview sample unit in advance of them shipping general availability of the Kickstarter early-bird units, maybe even be so bold and ask them to also send some units to your fellow ESPHome and Home Assistant core developers. I am sure that they would appreciate it if some of the popular open-source firmware projects could already support it before it gets shipped to end-users. |
I will do just that @Hedda. Thanks =) |
FYI, Tasmota developer blakadder now discovered that SONOFF NSPanel uses Nextion Discovery 3.5” NX4832F035 screen type part: https://nextion.tech/datasheets/nx4832f035/ NX4832F035 Nextion 3.5″ Discovery Series HMI Touch Display can be purchased as a separate unit directly from ITead for $29.90 (US) if need it for development or want to test it in an ESP32 DIY project: https://itead.cc/product/nx4832f035-nextion-3-5-discovery-series-hmi-touch-display/ blakadder (in Tasmota discussions): "With this discovery we confirm it is possible to upload custom GUI created in Nextion Editor." https://nextion.tech/nextion-editor/#_section1 blakadder has posted updated information on his findings here: https://blakadder.com/nspanel-teardown/ Note that the main PCB is marked with “E32-MSW-NX” and “NSPanel-EU” if you open it. and specific flashing instructions here: https://templates.blakadder.com/sonoff_NSPanel.html and looks like he is also planning on posting code here: https://github.com/blakadder/nspanel blakadder wrote: I’ve also successfully decoded most of the NSPanel custom protocol, just need to figure out why the touch function stops working when doing some actions. Here’s a list of objects pulled by a nice tool coded by MaxZ from Nextion Unoffficial Discord: https://gist.github.com/blakadder/7928279bd95ad47b54f705b7a121a7e1 Again, more discussion here on Home Assistant community forum: Over at the https://unofficialnextion.com/t/welcome-to-the-unofficial-nextion-tjc-user-forum/8 we’ve been making some discoveries:
Also ESPhome only sends the connect command to the Nextion. That doesn’t work because the NSPanel is in Protocol Reparse mode. You need to send the full escape sequence from the Nextion Upload Protocol v1.1 1 instead to exit Protocol Reparse mode. You need to have GPIO4 pulled low so the screen boots. Then send the escape reparse mode string DRAKJHSUYDGBNCJHGJKSHBDNÿÿÿ and you can use all standard nextion commands. https://gist.github.com/blakadder/7928279bd95ad47b54f705b7a121a7e1 |
Although not locked down to Nextion, but: https://haswitchplate.github.io/openHASP-docs |
blakadder (who now managed to get Sonoff NSPanel display working with Tasmota) said that openHASP can't be reused for this: "Nextion screens have a different design philosophy and will not work with LVGL and therefore openHASP" blakadder continuously keeps updating his findings both on a few web-pages and in this GitHub repo: https://blakadder.com/nspanel-teardown/ https://templates.blakadder.com/sonoff_NSPanel.html https://github.com/blakadder/nspanel https://blakadder.github.io/nspanel/ https://gist.github.com/blakadder/7928279bd95ad47b54f705b7a121a7e1 As noted it does not use standard Nextion so they reference Nextion Instruction Set and the Nextion HMI Project Upload Protocol: https://nextion.tech/instruction-set/ https://nextion.tech/2017/12/08/nextion-hmi-upload-protocol-v1-1/ Again, the community at the unofficial Nextion/TJC chat room on Discord has made most of the discoveries about this display: https://unofficialnextion.com/t/welcome-to-the-unofficial-nextion-tjc-user-forum/8 |
FYI, blakadder now said that he is trying to replicate the original default firmware but using MQTT to be able to integrate it in HA. Everything neatly laid out here for hacking it and configuring Tasmota and blakadder said will be updated as support progresses: https://templates.blakadder.com/sonoff_NSPanel Michel from espthings.io also updated his teardown and test of flashing ESPHome: https://www.espthings.io/index.php/2021/10/10/sonoff-nspanel-first-impressions/ Again, also be sure to check out this teardown as an introduction to the hardware: |
Awesome stuff! Will keep an eye on esphome/esphome#2702 and your Twitter while waiting for ITead to ship Sonoff NSPanel! |
@jesserockz Thank you so much for this component! |
I've flashed my NSPanel with jesserockz's code and it's working pretty fine. I've found how to declare widgets in the YAML configuration. It's clear that "devices" are not currently supported but "groups" are. Regarding "devices", "CURTAIN: 11" is missing in the code.
For example, with this code: - type: group
name: Salon
uiid: SWITCH_VERTICAL_TRIPLE
items:
- name: "Open"
on_click:
- homeassistant.service:
service: cover.open_cover
data:
entity_id: cover.salon_volet_roulant
- name: "Close"
on_click:
- homeassistant.service:
service: cover.close_cover
data:
entity_id: cover.salon_volet_roulant
- name: "STOP"
on_click:
- homeassistant.service:
service: cover.stop_cover
data:
entity_id: cover.salon_volet_roulant If I click on OUTLET1 or 2 or 3, only the last on_click action is triggered, here it is |
When trying to compile with Jesse's code, I'm getting the error below. Any idea what can be wrong?
|
On ESPHome 2021.12.1, I'm seeing a similar error on compilation as what @TyzzyT is getting:
The yaml config I used is available here. EDIT: It compiled fine using the dev release of ESPHome. |
Yeah I'm not alone using ESPHome with a NSPanel 👍
Also, you need to change 1 thing in your YAML:
Restore Mode for the screen power switch must now be set to ALWAYS_OFF |
Hey @mbo18,
|
Currently we can only use scene or empty.
|
Thanks @mbo18, you're the best! This is working for me. |
Is there any support for changing the orientation of the screen yet? I have the portrait-orientation NSPanel but it displays landscape. |
That’s in NSPanel settings and not in ESPHome I think. Slide your finger from the top of the screen to the bottom |
I can't get mine to register when I try to change orientation. I see the option to do it. |
I can’t help you, this option does not exist in the EU version |
@mkaatman When I tapped the option for orientation, nothing changed on-screen. However, after power cycling, it appeared with the orientation I had selected. |
That was it. I must have done the old triple tap prior. Now how do you get Fahrenheit to stick? |
Under |
Sorry, still catching up on Github notifications. Great to see people are receiving their NSPanels and using ESPHome on them ❤️ A few things:
Please do keep sending in your issues/feedback and I will try to make this work the best I can. Jesse |
Hi @jesserockz! thanks for working on this.
which will be sensors form HA:
Regarding devices, do you plan to add And finally, regarding groups, a binary sensor and a switch sensor per HA light or switch could do the job? like:
then NSPanel group's state and action could come from the switch template. The configuration could look like:
|
@mbo18 Ah something I added in my local config, but not in the PR for weather: api:
services:
- service: weather_data
variables:
icon: int
temperature: int
min: int
max: int
then:
- lambda: id(nspanel_id).send_weather_data((nspanel::WeatherIcon)icon, temperature, min, max); The icons list is here: https://github.com/esphome/esphome/pull/2702/files#diff-90cb7313b616f9d6e69e3358d14b0325f04255d8e84891a20431dd5eb57a7543R17-R32
I do like this approach and I think that might work nicely.
Not anytime soon, that will be a big task in itself.
I had done something similar although skipped the template switch and just set the group item state directly from the |
For the light |
@DeanoXX Thank you for you code!! I'm using it now for my lights, covers and plugs all with the original GUI. |
Excellent - glad it was helpful :) |
@DeanoXX thank you for your work and sharing the code :D I also managed to use stock UI with ESP firmware and create awesome HA integration <3 |
@peetereczek I've shared my code here |
@DeanoXX did you managed to control display brightness? |
@peetereczek It seems while using the nspanel UI the brightness can only be controlled from the UI itself. There are no messages received when you change it in UI. The |
Maybe it is possible to expose brightness control? |
Then using the ~~custom~~ STOCK screen, it is possible. However a little awkward. the
~~custom~~ STOCK screen runs in reparse mode, so you dont talk to the Nextion
directly. But you could escape from that mode by sending;
DRAKJHSUYDGBNCJHGJKSHBDN
recmod=0
this will get you in Nextion mode, you can then send the dim command.
once that's done, you can switch back to reparse mode with
recmod=1
…On Thu, 3 Feb 2022 at 21:48, peetereczek ***@***.***> wrote:
@peetereczek <https://github.com/peetereczek> It seems while using the
nspanel UI the brightness can only be controlled from the UI itself. There
are no messages received when you change it in UI. The dim=50 command is
a nextion command, but not a NSPanel command.
Maybe it is possible to expose brightness control?
—
Reply to this email directly, view it on GitHub
<#1469 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKBSYTH42DPOZ6SH4SNMEX3UZLZ2ZANCNFSM5GI6C43Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Point is to use original UI. And now ESP software blocks sending nextion command. That's why I'm asking |
"Point is to use original UI. And now ESP software blocks sending nextion command. That's why I'm asking" Sorry, the thing I said above, that's how to on the STOCK screen, not custom. Typo !! :) It's the breakout, so you can then send Nextion command. How you do in ESPHome I dont know as I use tamsota. You could try my NxPanel firmware for the device. It does all the stock one does and more. easy to revert back to. You can send JSON to do the DIM too.
among other things. |
So what is the nextion command sequence that needs to be sent ? |
Hi @DeanoXX. While it's in reparse mode, which is the json command version, you simply need to write this specific sequence of bytes;
This will temporally stop that mode. The reparse mode is recmod=1 mode. So as soon as you have send that sequence, you send the command
This will put it back in normal nextion command mode. You can then issue your dim or any other commands.
to put it back how it was before. Also, what do you think the chances are of you making a tweaked version of your interface for talking to stock hmi, to talk to my modified nxpanel screen firmware? If you have done the stock one, then it should be trivial changes for mine. But then you can do a lot more than stock, without needing any nextion and you can do it all via json just like the stock one? Have a look here to see if you think it might be useful? Thanks. |
ESPHome version 2022.3.1 push NSPanel breaks integration / puts device into bootloop reporting [W][json:079]: Increasing memory allocation. Config:
|
@peetereczek wait for 2022.3.2. And while waiting, add this to your code: external_components:
- source: github://pr#2702
components: ["nspanel"]
- source: github://pr#3331
components: ["json"] |
these two lines were missing, now I have added them, was this the reason?
|
hello how get another heat temp reading in room and use the reading from that |
@wifi75 FYI, probably best to ask in the Home Assistant community forum thread or the Unofficial Nextion User Chat on Discord: https://unofficialnextion.com/t/welcome-to-the-unofficial-nextion-tjc-user-forum/8 |
The stock GUI has two bars which indicate the state of relay. |
Hopefully someone will correct me if I'm wrong but I don't believe you can with the stock display. |
And is there a nice/good way to add the weather? |
I don't know how similar the calibration is from unit to unit, but this is what I'm using so far. - platform: ntc
id: temperature
sensor: resistance_sensor
calibration:
#b_constant: 3950
#reference_temperature: 25.03889°C
#reference_resistance: 11.7kOhm
- 11.7kOhm -> 25.03889°C
- 12.1kOhm -> 24.12222°C
- 13.7kOhm -> 20.55556°C
name: $friendly_name Temperature
unit_of_measurement: "°F"
filters:
- lambda: return x * (9.0/5.0) + 32.0;
Yes, there are a few different approaches but check out DeanoXX's example on github: https://github.com/DeanoXX/esphome-config It works great. |
Thanks^^ I just hoped it's possible to use weather from same source so that the WebUI and Panel show the same data but I will just use this. |
I am having an issue with sending my TFT to my NSPanel. I am using a wifi mesh (Google Nest) but keep getting: INFO 192.168.86.99: Ping timed out! Any help would be appreciated! [secrets files, blanked out where necessary] api_pwd: "..."
tft_prefix: "http:192.168.86.90:8123/local"
tft_office_switch: "http:192.168.86.90:8123/local/officeswitch.tft"
ota_pwd: "..."
wifi_ssid: "..."
wifi_pwd: "..."
latitude: ...
longitude: ...
office-switch-ip: 192.168.86.99 Below is my config: # Set some variables for convenience
substitutions:
node_name: office-switch
device_name: office-switch
# Note: this may not be needed if the pull request has been merged.
# Check https://github.com/esphome/esphome/pull/2956 for current status.
external_components:
- source: github://pr#2956
components: [nextion]
refresh: 1h
esphome:
name: $node_name
comment: $device_name
esp32:
board: esp32dev
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pwd
manual_ip:
static_ip: 192.168.86.99
gateway: 192.168.86.1
subnet: 255.255.255.0
dns1: 192.168.86.1
dns2: 8.8.8.8
reboot_timeout: 0s
power_save_mode: light
fast_connect: true
# Enable logging
logger:
# Enable wireless updates
ota:
password: !secret ota_pwd
# Enable Home Assistant API
api:
password: !secret api_pwd
services:
# Service to play a song
- service: play_rtttl
variables:
song_str: string
then:
- rtttl.play:
rtttl: !lambda 'return song_str;'
- service: upload_tft
then:
- lambda: 'id(disp1)->upload_tft();'
# A reboot button is always useful
button:
- platform: restart
name: Restart $device_name
# Define some inputs
binary_sensor:
- platform: gpio
name: $device_name Left Button
pin:
number: 14
inverted: true
on_click:
- switch.toggle: relay_1
- platform: gpio
name: $device_name Right Button
pin:
number: 27
inverted: true
on_click:
- switch.toggle: relay_2
- platform: nextion
name: $device_name Play Button
page_id: 0
component_id: 2
- platform: nextion
name: $device_name On Button
page_id: 0
component_id: 3
- platform: nextion
name: $device_name Off Button
page_id: 0
component_id: 4
- platform: nextion
name: $device_name Red Button
page_id: 0
component_id: 6
sensor:
- platform: wifi_signal
name: $device_name WiFi Signal
update_interval: 60s
- platform: ntc
id: temperature
sensor: resistance_sensor
calibration:
b_constant: 3950
reference_temperature: 25°C
reference_resistance: 10kOhm
name: $device_name Temperature
- platform: resistance
id: resistance_sensor
sensor: ntc_source
configuration: DOWNSTREAM
resistor: 11.2kOhm
- platform: adc
id: ntc_source
pin: 38
update_interval: 10s
attenuation: 11db
# Grab current temperature from Home Assistant
- platform: homeassistant
id: current_temperature
entity_id: weather.home
attribute: temperature
on_value:
# Push it to the display
then:
- lambda: 'id(disp1).set_component_text_printf("temp", "%.1f ""\xb0""F", x);'
# Define some outputs
switch:
# The two relays
- platform: gpio
name: $device_name Relay 1
id: relay_1
pin:
number: 22
- platform: gpio
name: $device_name Relay 2
id: relay_2
pin:
number: 19
# Pin 4 always needs to be on to power up the display
- platform: gpio
id: screen_power
entity_category: config
pin:
number: 4
inverted: true
restore_mode: ALWAYS_ON
number:
platform: template
name: $device_name Brightness
id: brightness
entity_category: config
unit_of_measurement: '%'
min_value: 0
max_value: 100
step: 1
initial_value: 30
set_action:
then:
- lambda: 'id(disp1).set_backlight_brightness(x/100);'
# Configure the internal bleeper
output:
- platform: ledc
id: buzzer_out
pin:
number: 21
# Enable ringtone music support
rtttl:
id: buzzer
output: buzzer_out
# Configure UART for communicating with the screen
uart:
id: tf_uart
tx_pin: 16
rx_pin: 17
baud_rate: 115200
# Configure the screen itself
display:
- platform: nextion
id: disp1
uart_id: tf_uart
tft_url: !secret tft_office_switch
# A little fun...
on_setup:
then:
- number.set:
id: brightness
value: 30
- lambda: |-
id(disp1).set_component_text_printf(
"temp", "%.1f ""\xb0""F", id(current_temperature).state
);
- rtttl.play: "twobits:d=4,o=5,b=220:c6,8g,8g,a,g,p,b,c6" And my log file:
|
Describe the problem you have/What new integration you would like
Request support in ESPHome for SONOFF NSPanel touchscreen display by ITead = ESP32 based with custom Nextion HMI screen:
https://itead.cc/product/sonoff-nspanel-smart-scene-wall-switch/
It is listed at MSRP $74.90 but early-bird version is currently sold via this Kickstarter campaign for around $54 each or $99 for two:
https://www.kickstarter.com/projects/sonoffnspanel/sonoff-nspanel-smart-scene-wall-switch/
A lot of information had already leaked via its FCC certification (FCC ID 2APN5NSPANEL):
https://fccid.io/2APN5NSPANEL
https://fccid.io/2APN5NSPANEL/User-Manual/User-Manual-5481421.pdf
https://fccid.io/2APN5NSPANEL/External-Photos/External-Photos-5481413.pdf
https://fccid.io/2APN5NSPANEL/Internal-Photos/Internal-Photos-5481415.pdf
https://fccid.io/2APN5NSPANEL/Label/ID-Label-and-Label-Location-5481414.pdf
Many tech review bloggers/vloggers who received preview prototype units seem to complain about its lack of integrated motion sensor for presence detection so can automatically turn on the screen backlighting, (and I like to also add the request for its DS18B20 temperature-only sensor to be replaced with a DHT22, AM2301, or Si7021 temperature and humidity combo sensor).
https://www.youtube.com/watch?v=cGXJnzS7D9g
https://www.youtube.com/watch?v=hQZk3MKJXzI
https://www.youtube.com/watch?v=vg_Jq4Y9b_s
https://www.youtube.com/watch?v=vg_Jq4Y9b_s
https://www.youtube.com/watch?v=DUvWwtvtd6k
Looks like a model each for Europe and North America; “NSPanel-EU” and “NSPanel-US”. It also contains a temperature + humidity sensor and two integrated low-amp relays for 220V/300W or 110V/150W capacity respectively, but the point is really for it to act as remote control of scenes and running widgets (local applications or scripts) such as for example an HVAC thermostat.
As I understand all Nextion displays as their own integrated microcontroller unit (STM32GO ARM Cortex-M0+ 64MHz Onboard MCU Processor) so that will off-load most of the heavy lifting work and all text and graphics, animations, etc. are created using Nextion Editor software, and then then the project files/assets are uploaded directly into the Nextion screen. The screen then has serial commands mapped to UI elements and can be sent and received from ESPHome firmware to control it.
There is some interesting discussions on the Home Assistant community forum about hacking it with ESPHome and/or Tasmota:
https://community.home-assistant.io/t/sonoff-nspanel-smart-scene-wall-switch-by-itead-coming-soon-on-kickstarter/332962/
HA-TB303 and blakadder are two that have especially connected a lot of information about the internal workings of these:
https://espthings.io/nspanel
https://blakadder.com/nspanel-teardown/
Also, the community at the unofficial Nextion/TJC chat room on Discord have been making some discoveries about its display:
https://unofficialnextion.com/t/welcome-to-the-unofficial-nextion-tjc-user-forum/8
The first thing they discovered it that has practically been designed it to be hacked and flashed with third-party firmware. Especially when taking into consideration that Efuses are not burned and pin headers on the board are easy to use for a solderless flash.
The information so far is that it does not use the protocol that ESPHome support for Nextion HMI but instead a custom protocol:
Nextion HMI Project Upload Protocol specifications:
https://nextion.tech/2017/12/08/nextion-hmi-upload-protocol-v1-1/
ITead has also posted specific IO (Input-Output) definition documention for Sonoff NSPanel in a new Kickstarter campaign update:
Please describe your use case for this integration and alternatives you've tried:
Additional context
The text was updated successfully, but these errors were encountered: