Blackymas / NSPanel_HA_Blueprint

This allows you to configure your complete NSPanel via Blueprint with UI and without changing anything in the code
1.44k stars 258 forks source link

After flashing new device, Nextion is not connected #641

Closed doron1 closed 1 year ago

doron1 commented 1 year ago

After flashing 3.2.2 to a new nspanel-eu, I get repeated messages (every second):

[01:22:24][W][nextion:072]: Nextion is not connected! [01:22:24][E][uart:015]: Reading from UART timed out at byte 0! [01:22:24][W][nextion:072]: Nextion is not connected! [01:22:25][E][uart:015]: Reading from UART timed out at byte 0!`

Subsequently, "Update TFT Display" fails. The display is active, with Sonoff stuff. Seems like esphome is unable to write to the display.

I've seen a few issues and threads about similar issues, but none of the the solutions resolve the problem here. Reduced the uart to 9600 and it doesn't change anything.

Not sure whether this is a blueprint / esphome / hardware issue. I hope my new device is not bricked... Any feedback would be appreciated!

doron1 commented 1 year ago

The full sequence is:

[02:12:40][D][nextion_upload:175]: Requesting URL: http://192.168.111.112:8123/local/nspaneleu.tft [02:12:40][D][nextion_upload:209]: Updating Nextion NX4832F035_011C... [02:12:41][D][nextion_upload:235]: Waiting for upgrade response [02:12:41][E][uart:015]: Reading from UART timed out at byte 0! [02:12:41][E][uart:015]: Reading from UART timed out at byte 0! [02:12:41][E][uart:015]: Reading from UART timed out at byte 0! [02:12:41][E][uart:015]: Reading from UART timed out at byte 0! [02:12:41][E][uart:015]: Reading from UART timed out at byte 0! [02:12:41][E][uart:015]: Reading from UART timed out at byte 0! [02:12:41][E][uart:015]: Reading from UART timed out at byte 0! [02:12:41][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:42][E][uart:015]: Reading from UART timed out at byte 0! [02:12:43][E][uart:015]: Reading from UART timed out at byte 0! [02:12:43][E][uart:015]: Reading from UART timed out at byte 0! [02:12:43][D][nextion_upload:239]: Upgrade response is 19 [02:12:43][D][nextion_upload:242]: Available 0 : 0x00 [02:12:43][D][nextion_upload:242]: Available 1 : 0x00 [02:12:43][D][nextion_upload:242]: Available 2 : 0x00 [02:12:43][D][nextion_upload:242]: Available 3 : 0x00 [02:12:43][D][nextion_upload:242]: Available 4 : 0x00 [02:12:43][D][nextion_upload:242]: Available 5 : 0x00 [02:12:43][D][nextion_upload:242]: Available 6 : 0x00 [02:12:43][D][nextion_upload:242]: Available 7 : 0x00 [02:12:43][D][nextion_upload:242]: Available 8 : 0x00 [02:12:43][D][nextion_upload:242]: Available 9 : 0x00 [02:12:43][D][nextion_upload:242]: Available 10 : 0x00 [02:12:43][D][nextion_upload:242]: Available 11 : 0x00 [02:12:43][D][nextion_upload:242]: Available 12 : 0x00 [02:12:43][D][nextion_upload:242]: Available 13 : 0x00 [02:12:43][D][nextion_upload:242]: Available 14 : 0x00 [02:12:43][D][nextion_upload:242]: Available 15 : 0x00 [02:12:43][D][nextion_upload:242]: Available 16 : 0x00 [02:12:43][D][nextion_upload:242]: Available 17 : 0x00 [02:12:43][D][nextion_upload:242]: Available 18 : 0x00 [02:12:43][D][nextion_upload:248]: preparation for tft update failed 0 "" [02:12:43][D][nextion_upload:310]: Restarting Nextion [02:12:44][D][nextion_upload:313]: Restarting esphome WARNING nspfront.local: Connection error occurred: [Errno 104] Connection reset by peer INFO Processing unexpected disconnect from ESPHome API for nspfront.local WARNING Disconnected from API INFO Successfully connected to nspfront.local [02:12:55][E][uart:015]: Reading from UART timed out at byte 0! [02:12:55][W][nextion:072]: Nextion is not connected! [02:12:56][E][uart:015]: Reading from UART timed out at byte 0! [02:12:56][W][nextion:072]: Nextion is not connected! [02:12:56][E][uart:015]: Reading from UART timed out at byte 0! [02:12:56][W][nextion:072]: Nextion is not connected! [02:12:57][E][uart:015]: Reading from UART timed out at byte 0! [02:12:57][W][nextion:072]: Nextion is not connected!

edwardtfn commented 1 year ago

Have you tried uploading the nspanel_blank.tft?

doron1 commented 1 year ago

Have you tried uploading the nspanel_blank.tft?

Thanks. I did. Same result. It doesn't get to the point of writing it (or anything) to the Nextion - it just gives the "Nextion is not connected!" stuff in a loop.

doron1 commented 1 year ago

It appears as if the code does something to the Nextion to put the UART in this state. I do get "Connected", then requesting the file, then updating the Nextion, then waiting for response - and only then does it get into this unresponsive UART state. BTW all this time the Nextion remains with the Sonoff UI, active (sort of) and responsive (to the extent that the Nextion UI is responsive).

edwardtfn commented 1 year ago

Why don't you try restarting the whole process from the beginning?

From creating a new ESPHome device, installing into the panel, etc?

doron1 commented 1 year ago

I did the whole process a few times but never went on to completely delete all remains from HA. Just did that per your suggestion. Completely removed, compiled a fresh f/w, installed etc. Same behavior. Until I try to push the TFT all seems well; when I do that, the above situation is recreated.

nogueirasa commented 1 year ago

I have the same problem. "Nextion is not connected "

I'm using ESPHome 2022.11 because if I upgrade to 2023.3, my ESPHome can't compile. 32 bits OS issues.

Important to says that HA is communicating because I can switch the Relays on and off.

andersagerskov commented 1 year ago

+1

I bought 10 NSPanels in one batch, have done 3 so far with success (slow process as I need to change the wall box for mount and cables). Did another one yesterday, same process as previous, but get the "Nextion is not connected!" issue.

I have tried alternate Webserver as suggested in other threads, always using http.

One thing I noticed in the logs is also that the entire Nextion Info section is blank:

[10:01:21][C][nextion:118]: Device Model:
[10:01:21][C][nextion:119]: Firmware Version: [10:01:21][C][nextion:120]: Serial Number:
[10:01:21][C][nextion:121]: Flash Size:
[10:01:21][C][nextion:122]: Wake On Touch: True

This seems to be a growing issue :-(

/Anders

hessedoggy commented 1 year ago

hi, I also have the same problem.

[10:21:58][E][uart:015]: Reading from UART timed out at byte 0! [10:21:58][W][nextion:072]: Nextion is not connected! [10:21:59][E][uart:015]: Reading from UART timed out at byte 0! [10:21:59][W][nextion:072]: Nextion is not connected! [10:22:00][E][uart:015]: Reading from UART timed out at byte 0! [10:22:00][W][nextion:072]: Nextion is not connected! [10:22:00][E][uart:015]: Reading from UART timed out at byte 0! [10:22:00][W][nextion:072]: Nextion is not connected! [10:22:01][E][uart:015]: Reading from UART timed out at byte 0!

I used the actual Esp home version in HA regards Stefan

edwardtfn commented 1 year ago

This seems to be a growing issue :-(

I'm not sure if this is growing. I have this same error months ago when installing one of my panels for the first time and also had to go thru lots of different tries in order to get it back working. In the end, my feeling is that this TFT transfer is very sensitive to the network + Web server stability and if anything goes wrong you get to this state. This is probably the reason that nspanel_blank.tft works most of the time, as it is a 257kb file compared to the +6mb of the final TFT.

But anyways, how are you with this panel where you have Nextion is not connected error? Can you install the nspanel_blank.tft at least?

andersagerskov commented 1 year ago

But anyways, how are you with this panel where you have Nextion is not connected error? Can you install the nspanel_blank.tft at least?

No, not able to install any TFT, blank nor EU. I can see from my webserver log and from ESP logs that connection to the URL is correct, and correct size reported, then I get the same as initial poster:

[10:30:09][D][button:013]: 'nsputilityroom Update TFT display' Pressed.

[10:30:09][D][nextion_upload:175]: Requesting URL: http:///nspanel_eu.tft [10:30:09][D][nextion_upload:209]: Updating Nextion ... [10:30:09][D][nextion_upload:235]: Waiting for upgrade response [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:10][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][E][uart:015]: Reading from UART timed out at byte 0! [10:30:11][D][nextion_upload:239]: Upgrade response is 19 [10:30:11][D][nextion_upload:242]: Available 0 : 0x00 [10:30:12][D][nextion_upload:242]: Available 1 : 0x00 [10:30:12][D][nextion_upload:242]: Available 2 : 0x00 [10:30:12][D][nextion_upload:242]: Available 3 : 0x00 [10:30:12][D][nextion_upload:242]: Available 4 : 0x00 [10:30:12][D][nextion_upload:242]: Available 5 : 0x00 [10:30:12][D][nextion_upload:242]: Available 6 : 0x00 [10:30:12][D][nextion_upload:242]: Available 7 : 0x00 [10:30:12][D][nextion_upload:242]: Available 8 : 0x00 [10:30:12][D][nextion_upload:242]: Available 9 : 0x00 [10:30:12][D][nextion_upload:242]: Available 10 : 0x00 [10:30:12][D][nextion_upload:242]: Available 11 : 0x00 [10:30:12][D][nextion_upload:242]: Available 12 : 0x00 [10:30:12][D][nextion_upload:242]: Available 13 : 0x00 [10:30:12][D][nextion_upload:242]: Available 14 : 0x00 [10:30:12][D][nextion_upload:242]: Available 15 : 0x00 [10:30:12][D][nextion_upload:242]: Available 16 : 0x00 [10:30:12][D][nextion_upload:242]: Available 17 : 0x00 [10:30:12][D][nextion_upload:242]: Available 18 : 0x00 [10:30:12][D][nextion_upload:248]: preparation for tft update failed 0 "" [10:30:12][D][nextion_upload:310]: Restarting Nextion

Also tried a complete refresh of the process, deleted everything, no luck.

/Anders

edwardtfn commented 1 year ago

Take a look at this post: https://github.com/Blackymas/NSPanel_HA_Blueprint/issues/619#issuecomment-1501606719

andersagerskov commented 1 year ago

Using an earlier version of the nspanel_esphome.yaml in a local file (Latest commit d74b70f 3 weeks ago) everything works without any changes, alternative webservers, config, etc.

So I do still suspect something that was pushed with the the latest esphome config is the cause of the issue that I am seeing at least. I will try to investigate if I can find the setting that kills it for me when I have some more time.

Just for reference, only thing I did was get the previous edition and change local device config to:

substitutions:

###### CHANGE ME START ######

  device_name: "nsputilityroom" 
  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password

  nextion_update_url: "http://<HAIP>/local/nspanel_eu.tft" # URL to local tft File
#  nextion_update_url: "https://raw.githubusercontent.com/Blackymas/NSPanel_HA_Blueprint/main/nspanel_us.tft" # URL to Github

##### DO NOT CHANGE ANYTHING! #####

packages:
  ##### download esphome code from Github
  #remote_package:
  #  url: https://github.com/Blackymas/NSPanel_HA_Blueprint
  #  ref: main
  #  files: [nspanel_esphome.yaml]
  #  refresh: 300s
  localpack: !include nspanel_esphome_local.yaml

##### DO NOT CHANGE ANYTHING! #####

I will try the nginx as suggested, but again I don't think that is actually were we should be looking to find the root.

/Anders

doron1 commented 1 year ago

The nginx exercise did not change anything for me. Same issue. @andersagerskov , how did you make the esphome code use a previous release of the blueprint package?

andersagerskov commented 1 year ago

The nginx exercise did not change anything for me. Same issue. @andersagerskov , how did you make the esphome code use a previous release of the blueprint package?

I downloaded the content of a previous version of the nspanel_esphome.yaml from GIT that I know worked before: "https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/d74b70f8648a72219e463ddfcb39c6f7e61cc491/nspanel_esphome.yaml" and placed in a local YAML file.

I then changed the ESP YAML for the device to not use the local file instead of remote - see below:

`substitutions:

###### CHANGE ME START ######

  device_name: "nsputilityroom" 
  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password

  nextion_update_url: "http://<haip>/local/nspanel_eu.tft" # URL to local tft File
#  nextion_update_url: "https://raw.githubusercontent.com/Blackymas/NSPanel_HA_Blueprint/main/nspanel_us.tft" # URL to Github

##### DO NOT CHANGE ANYTHING! #####

packages:
  ##### download esphome code from Github
  #remote_package:
  #  url: https://github.com/Blackymas/NSPanel_HA_Blueprint
  #  ref: main
  #  files: [nspanel_esphome.yaml]
  #  refresh: 300s
  localpack: !include nspanel_esphome_local.yaml

##### DO NOT CHANGE ANYTHING! #####`

After installing OTA to the ESP device, I could upload TFT with no issues.

/Anders

doron1 commented 1 year ago

Okay. First, @andersagerskov, an apology - I read your previous comment via an e-mail github notification, where it appeared seriously garbled for some reason, hence my stupid question.

With that said - this is massive progress, thank you! Indeed, using this previous version of the code did indeed do that trick. In spite of a few UART timeouts, the writing of the TFT file did actually work and the Nextion now has nspanel_eu.tft installed! As you said, this clearly demonstrates that the issue has crept in with some recent update.

It gets more interesting: After I had the Nextion loaded, I reflashed the latest (3.2.2). Then, just for testing, I did another upload of the TFT. Lo and behold, it worked.

Bottom line, it seems like the newer changes do not interface well with the original Sonoff Nextion code; they do work when the Blackymas TFT file is already preloaded.

This is certainly worth fixing.

nogueirasa commented 1 year ago

@doron1 , make sense because the last update release says to first upgrade the TFT and than upgrade the esphome and blueprint. But if its a fresh install, it will not work with the latest release.

beachie13 commented 1 year ago

@doron1 where is the nspanel_esphome.yaml normally stored? Did you just copy paste or add the file?

doron1 commented 1 year ago

@beachie13 normally it is part of the remote package, you can find it under .../esphome/.esphome/packages/... . In this exercise I just downloaded and placed it in .../esphome/ . Generally speaking it is not a very good idea since esphome sees it and thinks it's a new device config. However since this is all temporary, I placed it there, referred to it and flashed the TFT unto the Nextion. Once I had that done, I just removed the file and reverted to remote_package, per version 3.2.2.

I hope this issue is fixed soon, but for the time being this is a perfectly usable workaround.

bbbenji commented 1 year ago

@andersagerskov thank you, that worked for me.

Philnascimento commented 1 year ago

@beachie13 normally it is part of the remote package, you can find it under .../esphome/.esphome/packages/... . In this exercise I just downloaded and placed it in .../esphome/ . Generally speaking it is not a very good idea since esphome sees it and thinks it's a new device config. However since this is all temporary, I placed it there, referred to it and flashed the TFT unto the Nextion. Once I had that done, I just removed the file and reverted to remote_package, per version 3.2.2.

I hope this issue is fixed soon, but for the time being this is a perfectly usable workaround.

Hey, tried your solution and got the error:

`INFO Reading configuration /config/esphome/nspanel.yaml...
ERROR Error while reading config: Invalid YAML syntax:

mapping values are not allowed here
  in "/config/esphome/nspanel_esphome_local.yaml", line 27, column 66:
     ... le" content="{&quot;groups&quot;: [], &quot;environmentKey&quot; ... 
                                         ^`

any suggestions?

doron1 commented 1 year ago

@Philnascimento you didn't download the actual file, but rather, the github html page that presents it. You want to click on "raw", and only then wget or curl it :-)

Philnascimento commented 1 year ago

@Philnascimento you didn't download the actual file, but rather, the github html page that presents it. You want to click on "raw", and only then wget or curl it :-)

Still nothing

INFO Reading configuration /config/esphome/nspanel.yaml...
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
Failed config
doron1 commented 1 year ago

@Philnascimento can you share your config file? Not sure how you got to this error.

Philnascimento commented 1 year ago

@doron1 This is the config im using

substitutions:

###### CHANGE ME START ######

  device_name: "nsphil" 
  wifi_ssid: "MYWIFI"
  wifi_password: "MYPW"

  nextion_update_url: "http://192.168.31.22:8123/local/nspanel_us.tft" # URL to local tft File
#  nextion_update_url: "https://raw.githubusercontent.com/Blackymas/NSPanel_HA_Blueprint/main/nspanel_us.tft" # URL to Github

##### CHANGE ME END #####

##### DO NOT CHANGE ANYTHING! #####

packages:
  ##### download esphome code from Github
  remote_package:
    url: https://github.com/Blackymas/NSPanel_HA_Blueprint
    ref: main
    files: [nspanel_esphome.yaml]
    refresh: 300s
  localpack: !include nspanel_esphome_local.yaml
##### DO NOT CHANGE ANYTHING! #####
doron1 commented 1 year ago

@Philnascimento please comment out the five lines beginning with the "remote_package" line. See the example above. Leave the "localpack" active.

Philnascimento commented 1 year ago

@doron1 ty, it worked, now all i need to do, is fix some blueprint error and stuck on loading.

Timmwardion commented 1 year ago

I flashed my NSPanel today and have been battling the dreaded UART timed out issue that we all seem to be having. I've tried the blank.tft technique mentioned above and in other posts and I've also played around with the baud, using the slightly older nspanel_esphome_local.yaml file. None of this has worked.

I added in some debug lines into the local yaml for the UART and it is reporting a boguscommand. See below:

##### UART FOR NEXTION DISPLAY #####
uart:
tx_pin: 16
  rx_pin: 17
  baud_rate: 9600 #115200
  id: tf_uart
  debug:
    direction: BOTH
    dummy_receiver: false
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

And one of the debug logs is as follows:

[D][uart_debug:158]: >>> "boguscommand=0\xFF\xFF\xFFDRAKJHSUYDGBNCJHGJKSHBDN\xFF\xFF\xFFconnect\xFF\xFF\xFF"

So I'm wondering if there is an issue with how the ESPhome nextion platform is functioning

deejaybeam commented 1 year ago

@Timmwardion this is because of:

esphome:
  name: ${device_name}
  min_version: 2022.10.2
  on_boot:
    priority: 601
    then:
      - lambda: id(disp1).send_command_printf("DRAKJHSUYDGBNCJHGJKSHBDN");

see: https://github.com/esphome/esphome/pull/2956

this is the "old" version of the nextion-component we have used If you have a look at the comments, it looks like, this command is required to bring a factory display out of reparse-mode. I don´t have a factory-display, but added this command as recommended.

On an display where our tft is already installed, this command is "obsolete" because instruction in the tft sets the display to run with disabled reparse-mode.

Timmwardion commented 1 year ago

@Timmwardion this is because of:

esphome:
  name: ${device_name}
  min_version: 2022.10.2
  on_boot:
    priority: 601
    then:
      - lambda: id(disp1).send_command_printf("DRAKJHSUYDGBNCJHGJKSHBDN");

see: esphome/esphome#2956

this is the "old" version of the nextion-component we have used If you have a look at the comments, it looks like, this command is required to bring a factory display out of reparse-mode. I don´t have a factory-display, but added this command as recommended.

On an display where our tft is already installed, this command is "obsolete" because instruction in the tft sets the display to run with disabled reparse-mode.

I see. That makes sense. I thought those characters looked familiar!

Ok then, well despite trying everything it seems that I'm still getting that UART timeout.

deejaybeam commented 1 year ago

@Timmwardion this is because of:

esphome:
  name: ${device_name}
  min_version: 2022.10.2
  on_boot:
    priority: 601
    then:
      - lambda: id(disp1).send_command_printf("DRAKJHSUYDGBNCJHGJKSHBDN");

see: esphome/esphome#2956 this is the "old" version of the nextion-component we have used If you have a look at the comments, it looks like, this command is required to bring a factory display out of reparse-mode. I don´t have a factory-display, but added this command as recommended. On an display where our tft is already installed, this command is "obsolete" because instruction in the tft sets the display to run with disabled reparse-mode.

I see. That makes sense. I thought those characters looked familiar!

Ok then, well despite trying everything it seems that I'm still getting that UART timeout.

do you have factory nextion (tft) installed? If yes, try to remove the on_boot-part, and try again

Timmwardion commented 1 year ago

I have the screen that comes with the NSPanel if that's what you mean.

deejaybeam commented 1 year ago

I have the screen that comes with the NSPanel if that's what you mean.

Yes, that was my question.

It would be nice, if you could use the "full" esphome-yaml and remove the "boot-part" to check if this changes something

Timmwardion commented 1 year ago

Ok. This seems strange.

My NSPanel yaml is the following:

substitutions:

###### CHANGE ME START ######

  device_name: "hallwaycontrol" 
  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password

  nextion_update_url: "http://192.168.1.127:8123/local/nspanelblank.tft" # URL to local tft File
#  nextion_update_url: "http://192.168.1.127:8123/local/nspaneleu.tft" # URL to local tft File
#  nextion_update_url: "https://raw.githubusercontent.com/Blackymas/NSPanel_HA_Blueprint/main/nspanel_us.tft" # URL to Github

##### DO NOT CHANGE ANYTHING! #####

packages:
  ##### download esphome code from Github
  #remote_package:
  #  url: https://github.com/Blackymas/NSPanel_HA_Blueprint
  #  ref: main
  #  files: [nspanel_esphome.yaml]
  #  refresh: 300s
  localpack: !include nspanel_esphome_local.yaml

##### DO NOT CHANGE ANYTHING! ####

And the nspanel_esphome_local.yaml is as per:

https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/d74b70f8648a72219e463ddfcb39c6f7e61cc491/nspanel_esphome.yaml

Neither of which include the on_boot: section mentioned above. Yet - the logs still contain

[D][uart_debug:158]: >>> "boguscommand=0\xFF\xFF\xFFDRAKJHSUYDGBNCJHGJKSHBDN\xFF\xFF\xFFconnect\xFF\xFF\xFF"

Can't find the source - so I assume it means that call is made in other related packages - or the flashing process isn't working as reliably as I'd expect.

Timmwardion commented 1 year ago

I have the screen that comes with the NSPanel if that's what you mean.

Yes, that was my question.

It would be nice, if you could use the "full" esphome-yaml and remove the "boot-part" to check if this changes something

At any rate - just ran this and got the same results. Still throwing the UART timeout error.

deejaybeam commented 1 year ago

this is, because you use the "simple" esp-config (from install-wiki) under packages you see from where to load the rest (or full-config) to "merge" those. In your case, you have changed to use a local file instead of using the git-version.

But this does not matters - easiest way, if you don´t have much esp-home experiance and you want "local-full-control" is to just insert the code from: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/main/nspanel_esphome.yaml "over" the "simple-config" in esphome-dashboard (edit-device). Of course - you need to set your substitution to your needs

You can check the resulting "full-config" if you click on the validate-button of the device-config.

With the full-config direct in your device-editor, you have full-controll to all aspects of the code

deejaybeam commented 1 year ago

if the config you posted is correct, than the content of your esphome-device (editor) shold look like this:

#####################################################################################################
##### NSPANEL ESPHOME created by Blackymas - https://github.com/Blackymas/NSPanel_HA_Blueprint  #####
##### ADVANCED CONFIG + FULL ESPHOME CODE!                                                      #####
##### PLEASE only make changes if it is necessary and also the required knowledge is available. #####
##### For normal use with the Blueprint, no changes are necessary.                              #####
#####################################################################################################

##### ADVANCED CONFIGURATION - activate only when you know what you do ##############################
substitutions:
  # ## usage of secrets-file ## -> comment in ###### Change ME ######
  device_name: "hallwaycontrol" # Wird im Blueprint benötigt!
  wifi_ssid: !secret wifi_ssid # add in your esphome secrets file.
  wifi_password: !secret wifi_password # add in your esphome secrets file. -> per default this is also used for ota_password and web_password
  # ota_password: !secret nspanel_ota_password # add in your esphome secrets file. - manual change in code required to activate
  # web_password: !secret nspanel_web_password # add in your esphome secrets file. - manual change in code required to activate
  # api_password: !secret nspanel_api_password # add in your esphome secrets file. - manual change in code required to activate
  nextion_update_url: "http://192.168.1.127:8123/local/nspanelblank.tft # add in your esphome secrets file. Example: "http://"HOME ASSISTANT IP":8123/local/nspanel/nspanel.tft"

  # ## static ip config ##
  # ip: "10.0.0.7"
  # gw: "10.0.0.138"
  # subnet: "255.255.255.0"
  # dns: "10.0.0.138"
  # domain: ".local"

##### if you rename this file to .nspanel_esphome.yaml then you can activate nested config
##### use the ADVANCED CONFIG-Section as device configuration
##### https://esphome.io/guides/configuration-types.html#yaml-insertion-operator
# <<: !include .nspanel_esphome.yaml

##### END OF ADVANCED CONFIGURATION ##############################################################

##### WIFI SETUP #####
wifi:
  ssid: ${wifi_ssid}
  password: ${wifi_password}
  power_save_mode: none
  ##### advanced config - uncomment to use static IP-Config #####
  # manual_ip:
  #   static_ip: ${ip}
  #   gateway: ${gw}
  #   subnet: ${subnet}
  #   dns1: ${dns}
  # domain: ${domain}
  ##### Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${device_name}"
    password: ${wifi_password}

##### Functionality for the Nextion display #####
# external_components:
#   - source: github://pr#2956
#     components: [nextion]
#     refresh: 1h

##### ESPHOME CONFIGURATION #####
esphome:
  name: ${device_name}
  min_version: 2022.10.2
  # on_boot:
  #   priority: 601
  #   then:
  #     - lambda: id(disp1).send_command_printf("DRAKJHSUYDGBNCJHGJKSHBDN");

##### TYPE OF ESP BOARD #####
esp32:
  board: esp32dev

captive_portal:

web_server:
  port: 80
  auth:
    username: admin
    password: ${wifi_password}
    ##### advanced config - change to use web_password #####
    # password: ${web_password}

##### OTA PASSWORD #####
ota:
  password: ${wifi_password}
  ##### advanced config - change to use ota_password #####
  # password: ${ota_password}
  safe_mode: true
  reboot_timeout: 3min
  num_attempts: 3

##### LOGGER #####
logger:
#  baud_rate: 0
#  level: WARN

##### CONFIGURE INTERNAL BUZZER #####
output:
    ##### BUZZER FOR PLAYING RINGTONES #####
  - platform: ledc
    id: buzzer_out
    pin:
      number: 21

##### ENABLE RINGTONE MUSIC SUPPORT #####
rtttl:
  id: buzzer
  output: buzzer_out

##### UART FOR NEXTION DISPLAY #####
uart:
  tx_pin: 16
  rx_pin: 17
  baud_rate: 115200
  id: tf_uart

##### START - BUTTON CONFIGURATION #####
button:
  ###### REBOOT BUTTON #####
  - platform: restart
    name: ${device_name} Restart
    id: restart_nspanel

  ##### UPDATE TFT DISPLAY #####
  - platform: template
    name: ${device_name} Update TFT display
    icon: mdi:file-sync
    id: tft_update
    entity_category: config
    on_press:
      - delay: 16ms
      - lambda: id(disp1).upload_tft();

##### START - API CONFIGURATION #####
api:
  ##### advanced config - activate to use api_password #####
  # password: ${api_password}
  services:

    ##### SERVICE TO UPDATE THE HMI FILE #####
    - service: upload_tft
      then:
        - lambda: 'id(disp1)->upload_tft();'

    ##### SERVICE TO UPDATE THE TFT FILE from URL #####
    - service: upload_tft_url
      variables:
        url: string
      then:
        - lambda: 'id(disp1)->set_tft_url(url.c_str());'
        - lambda: 'id(disp1)->upload_tft();'

    ##### Service to send a command "printf" directly to the display #####
    - service: send_command_printf
      variables:
        cmd: string
      then:
        - lambda: 'id(disp1).send_command_printf("%s", cmd.c_str());'

    ##### Service to send a command "text_printf" directly to the display #####
    - service: send_command_text_printf
      variables:
        component: string
        message: string
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: 'id(disp1).set_component_text_printf(component.c_str(), "%s", message.c_str());'

    ##### Service to send a command "component_value (Dualstate Button)" directly to the display #####
    - service: send_command_value
      variables:
        component: string
        message: int
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: 'id(disp1).set_component_value(component.c_str(), message);'

    ##### Service to send a command "hide componente" directly to the display #####
    - service: send_command_hide ### unused ###
      variables:
        component: string
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: 'id(disp1).hide_component(component.c_str());'

    ##### Service to send a command "show componente" directly to the display #####
    - service: send_command_show ### unused ###
      variables:
        component: string
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: 'id(disp1).show_component(component.c_str());'

    ##### Service to send a command "show ALL componente" directly to the display #####
    - service: send_command_show_all ### unused ###
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: 'id(disp1).show_component("255");'

    ##### Service to send a command "font color" directly to the display #####
    - service: send_command_font_color
      variables:
        component: string
        message: int
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: 'id(disp1).set_component_font_color(component.c_str(), message);'

    ##### Service to send a command "background color" directly to the display #####
    - service: send_command_background_color
      variables:
        component: string
        message: int
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: 'id(disp1).set_component_background_color(component.c_str(), message);'

    ##### Service to show a notification-message on the screen #####
    - service: notification_show
      variables:
        label: string
        text: string
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: |-
            id(disp1).send_command_printf("page notification");
            id(disp1).set_component_text_printf("notification.notifi_label", "%s", label.c_str());
            id(disp1).set_component_text_printf("notification.notifi_text01", "%s", text.c_str());
            id(notification_label).publish_state(label.c_str());
            id(notification_text).publish_state(text.c_str());
        - switch.turn_on: notification_unread
        - if:
            condition:
              switch.is_on: notification_sound
            then:
              - rtttl.play: "two short:d=4,o=5,b=100:16e6,16e6"

    ##### Service to clear the notification #####
    - service: notification_clear
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: |-
            id(notification_label).publish_state("");
            id(notification_text).publish_state("");
        - switch.turn_off: notification_unread

    ##### Service to set entity-information for settings-page(s)
    - service: set_settings_entity
      variables:
        entity: string
      then:
        - wait_until:
            switch.is_on: nextion_init
        - lambda: |-
            id(settings_entity).publish_state(entity.c_str());

    ##### Service to play a rtttl tones #####
    # Example tones : https://codebender.cc/sketch:109888#RTTTL%20Songs.ino
    - service: play_rtttl
      variables:
        song_str: string
      then:
        - rtttl.play:
            rtttl: !lambda 'return song_str;'

    # Service to show a QR code on the display (ex. for WiFi password)
    - service: qr_code
      variables:
        qrdata: string
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: |-
            id(disp1).send_command_printf("page qrcode");
            id(disp1).set_component_text_printf("qrcode.qrcode_value", "%s", qrdata.c_str());

    #### Service to send thermostat cycle state ####
    - service: send_thermostat_cycle_state
      variables:
        value: float
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: |-
            //ESP_LOGD("nextion", "thermostat sendig value %f", value);
            int v = int(2 * std::min(std::max(value - 13.5, 0.0), 5.0));
            int left = v + (v ? 19 : 16); // 16 is empty left.
            v = int(2 * std::min(std::max(value - 18.0, 0.0), 4.0));
            int mid = v + (v ? 29 : 17); // 17 is empty mid.
            v = int(2 * std::min(std::max(value - 21.5, 0.0), 5.5));
            int right = v + (v ? 37 : 18); // 18 is empty right.
            // sends the 3 images to the display
            //ESP_LOGD("nextion", "thermostat left %i", left);
            //ESP_LOGD("nextion", "thermostat mid %i", mid);
            //ESP_LOGD("nextion", "thermostat right %i", right);
            id(disp1).send_command_printf("climate_left.pic=%i", left);
            id(disp1).send_command_printf("climate_middle.pic=%i", mid);
            id(disp1).send_command_printf("climate_right.pic=%i", right);
            // send target-temp
            id(disp1).set_component_text_printf("target_temp", "%.1f°", value);
            id(display_target_temp).publish_state(value);

    #### Service to set the buttons ####
    - service: set_button
      variables:
        btn_id: string
        btn_pic: int
        btn_bg: int
        btn_icon_font: int
        btn_txt_font: int
        btn_bri_font: int
        btn_icon: string
        btn_label: string
        btn_bri_txt: string
      then:
        - wait_until:
              switch.is_on: nextion_init
        - lambda: |-
            // ESP_LOGD("nextion", "set button %s", btn_id.c_str());
            std::string btnicon = btn_id.c_str() + std::string("icon");
            std::string btntext = btn_id.c_str() + std::string("text");
            std::string btnbri = btn_id.c_str() + std::string("bri");
            id(disp1).send_command_printf("%spic.pic=%i", btn_id.c_str(), btn_pic);
            id(disp1).set_component_background_color(btnicon.c_str(), btn_bg);
            id(disp1).set_component_background_color(btntext.c_str(), btn_bg);
            id(disp1).set_component_background_color(btnbri.c_str(), btn_bg);
            id(disp1).set_component_font_color(btnicon.c_str(), btn_icon_font);
            id(disp1).set_component_font_color(btntext.c_str(), btn_txt_font);
            id(disp1).set_component_font_color(btnbri.c_str(), btn_bri_font);
            id(disp1).set_component_text_printf(btnicon.c_str(), "%s", btn_icon.c_str());
            id(disp1).set_component_text_printf(btntext.c_str(), "%s", btn_label.c_str());
            // id(disp1).set_component_text_printf(btnbri.c_str(), "%s", btn_bri_txt.c_str());
            if (strcmp(btn_bri_txt.c_str(), "0") != 0) {
              id(disp1).set_component_text_printf(btnbri.c_str(), "%s", btn_bri_txt.c_str());
            } else {
              id(disp1).set_component_text_printf(btnbri.c_str(), " ");
            }

##### START - GLOBALS CONFIGURATION #####
globals:

  ##### Save Display Brightness for NSPanel reboot #####
  - id: display_brightness_global
    type: int
    restore_value: true
    initial_value: '100'

  ##### Save Display DIM Brightness for NSPanel reboot
  - id: display_dim_brightness_global
    type: int
    restore_value: true
    initial_value: '10'

  ##### Temperature Correction #####
  - id: temperature_correction_global
    type: float
    restore_value: true
    initial_value: '0.0'

  ##### Save Display DIM Brightness for NSPanel reboot
  - id: sleep_modus_global
    type: int
    restore_value: true
    initial_value: '0'

  ##### lastclick_general State #####
  - id: lastclick_general_global
    type: std::string
    restore_value: no
    initial_value: ''

  ##### lastclick_lightsettings State #####
  - id: lastclick_lightsettings_global
    type: std::string
    restore_value: no
    initial_value: ''

  ##### lastclick_coversettings State #####
  - id: lastclick_coversettings_global
    type: std::string
    restore_value: no
    initial_value: ''

  ##### lastclick_climatesettings State #####
  - id: lastclick_climatesettings_global
    type: std::string
    restore_value: no
    initial_value: ''

  ##### lastclick_currentpage State #####
  - id: currentpage_global
    type: std::string
    restore_value: no
    initial_value: ''

##### START - BINARY SENSOR CONFIGURATION #####
binary_sensor:

  ###### LEFT BUTTON BELOW DISPLAY TO TOGGLE RELAY#####
  - platform: gpio
    name: ${device_name} Left Button
    id: left_button
    pin:
      number: 14
      inverted: true
    on_click:
      then:
        - if:
            condition:
              and:
                  - switch.is_on: relay1_fallback
                  - not:
                      api.connected:
            then:
              - switch.toggle: relay_1
              - if: 
                  condition:
                    switch.is_on: relay_1
                  then:
                    - lambda: id(disp1).send_command_printf("home.left_bt_pic.pic=78");
                    - lambda: id(disp1).send_command_printf("home.icon_top_01","\U0000E3A5");
                  else:
                    - lambda: id(disp1).send_command_printf("home.left_bt_pic.pic=77");
                    - lambda: id(disp1).send_command_printf("home.icon_top_01","\U0000FFFF");

  ##### RIGHT BUTTON BELOW DISPLAY TO TOGGLE RELAY #####
  - platform: gpio
    name: ${device_name} Right Button
    id: right_button
    pin:
      number: 27
      inverted: true
    on_click:
      then:
        - if:
            condition:
              and:
                  - switch.is_on: relay2_fallback
                  - not:
                      api.connected:
            then:
              - switch.toggle: relay_2
              - if: 
                  condition:
                    switch.is_on: relay_2
                  then:
                    - lambda: id(disp1).send_command_printf("home.right_bt_pic.pic=78");
                    - lambda: id(disp1).send_command_printf("home.icon_top_02","\U0000E3A8");
                  else:
                    - lambda: id(disp1).send_command_printf("home.right_bt_pic.pic=77");
                    - lambda: id(disp1).send_command_printf("home.icon_top_02","\U0000FFFF");

  ##### JUMP PAGE TO SETTING PAGE #####
  - platform: nextion
    name: $device_name setting page
    page_id: 0
    component_id: 52
    internal: true
    on_multi_click:
      - timing:
          - ON for at least 1s #LONG Press
        then:
          - lambda: 'id(disp1).send_command_printf("page settings");'

  ##### Restart NSPanel Button - Setting Page #####
  - platform: nextion
    name: ${device_name} Restart
    page_id: 7
    component_id: 13
    internal: true
    on_click:
      - button.press: restart_nspanel

  ##### Restart NSPanel Button - Boot Page #####
  - platform: nextion
    name: ${device_name} Restart
    page_id: 8
    component_id: 4
    internal: true
    on_click:
      - button.press: restart_nspanel

  ##### Sleep Modus NSPanel Button #####
  - platform: nextion
    name: ${device_name} Sleep Modus
    page_id: 7
    component_id: 14
    internal: true
    on_click:
      - switch.toggle: sleep_modus

  ##### Hotwater Charge #####
  # - platform: nextion
  #   name: ${device_name} Hotwater Charge
  #   page_id: 6
  #   component_id: 20
    # on_click:
    #   - homeassistant.service:
    #       service: switch.toggle
    #       data:
    #         entity_id: ${ha_hotwater_charge}

##### START - SENSOR CONFIGURATION #####
sensor:

  ##### Uptime #####
  - platform: uptime
    name: ${device_name} uptime
    disabled_by_default: true

  ##### WIFI Signal stregth
  - platform: wifi_signal
    name: ${device_name} RSSI
    update_interval: 60s
    on_value:
      - if:
          condition:
            wifi.connected:
          then:
            - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\U0000E5A8");
          else:
            - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\U0000FFFF");

  ##### INTERNAL TEMPERATURE SENSOR, ADC VALUE #####
  - platform: adc
    id: ntc_source
    pin: 38
    update_interval: 60s
    attenuation: 11db

  ##### INTERNAL TEMPERATURE SENSOR, adc reading converted to resistance (calculation)#####
  - platform: resistance
    id: resistance_sensor
    sensor: ntc_source
    configuration: DOWNSTREAM
    resistor: 11.2kOhm

  ##### INTERNAL TEMPERATURE SENSOR, resistance to temperature (calculation) #####
  - platform: ntc
    name: ${device_name} Temperature
    id: temp_nspanel
    sensor: resistance_sensor
    calibration:
      b_constant: 3950
      reference_temperature: 25°C
      reference_resistance: 10kOhm
    filters:
      - lambda: return x + id(temperature_correction_global);
#    on_value:
#      then:
#        - wait_until:
#            switch.is_on: nextion_init
#         - lambda: id(disp1).set_component_text_printf("home.current_temp", "%.1f°", id(temp_nspanel).state); # onboard temp (thermostat temp) to home page.
#         - lambda: id(disp1).set_component_text_printf("climate.current_temp", "%.1f", id(temp_nspanel).state);

  ##### current value of page-climate target_temp #####
  - platform: template
    name: ${device_name} Display Target Temperature
    id: display_target_temp
    lambda: return {};
    update_interval: 10s

  ###### Display Brightness GET VALUE FROM NSPanel SLIDER #####
  - platform: nextion
    id: brightslider
    name: ${device_name} brightness Slider
    variable_name: brightslider
    internal: true
    on_value:
      then:
        - wait_until:
            switch.is_on: nextion_init
        - number.set:
            id: display_brightness
            value: !lambda 'return int(x);'
          # send text field percentage of current_lightslider_val
        - lambda: id(disp1).set_component_text_printf("settings.a03", "%i", id(display_brightness_global));

  ###### Display DIM Brightness GET VALUE FROM NSPanel SLIDER #####
  - platform: nextion
    id: dimslider
    name: ${device_name} dim brightness slider
    variable_name: dimslider
    internal: true
    on_value:
      then:
        - wait_until:
            switch.is_on: nextion_init
        - number.set:
            id: display_dim_brightness
            value: !lambda 'return int(x);'
          # send text field percentage of current_lightslider_val
        - lambda: id(disp1).set_component_text_printf("settings.a04", "%i", id(display_dim_brightness_global));

  ###### Send current page to HA
  # - platform: nextion
  #   id: current_page
  #   name: "${device_name} Current Page"
  #   variable_name: dp
  #   update_interval: 1s
  #   accuracy_decimals: 0
  #   filters:
  #     - delta: 1.0
  #     - lambda: return int(x);

##### START - TEXT SENSOR CONFIGURATION #####
text_sensor:

  ##### ESPhome version used to compile the app #####
  - platform: version
    name: ${device_name} ESPhome Version
    disabled_by_default: true

  - platform: wifi_info
    ip_address:
      name: ${device_name} IP
      disabled_by_default: true
      id: ip_address
    ssid:
      name: ${device_name} SSID
      disabled_by_default: true
    bssid:
      name: ${device_name} BSSID
      disabled_by_default: true

  - platform: template
    name: ${device_name} Notification Label
    id: notification_label

  - platform: template
    name: ${device_name} Notification Text
    id: notification_text

  - platform: template
    name: ${device_name} Settings Entity
    id: settings_entity

  ##### last click sensor, the main action variable - push to HA #####
  - platform: nextion
    nextion_id: disp1
    name: ${device_name} Last Click
    id: disp1_lastclick_general
    update_interval: 50ms
    component_name: lastclick
    internal: false
    filters:
      - lambda: |-
          if (strcmp(x.c_str(), id(lastclick_general_global).c_str()) != 0) {
            return x;
          } else {
            return {};
          }
    on_value:
      then:
        - globals.set:
            id: lastclick_general_global
            value: !lambda return x;
        - lambda: |-
            id(page_timer)->execute(int(id(page_timeout).state));

  ##### last click lightsettings page, the main action variable - push to HA #####
  - platform: nextion
    nextion_id: disp1
    name: ${device_name} last click lightsettings
    id: disp1_lastclick_lightsettings
    update_interval: 50ms
    component_name: lightsetting
    internal: false
    filters:
      - lambda: |-
          if (strcmp(x.c_str(), id(lastclick_lightsettings_global).c_str()) != 0) {
            return x;
          } else {
            return {};
          }
    on_value:
      then:
        - globals.set:
            id: lastclick_lightsettings_global
            value: !lambda return x;
        - lambda: |-
            id(page_timer)->execute(int(id(page_timeout).state));

  ##### last click coversettings page, the main action variable - push to HA #####
  - platform: nextion
    nextion_id: disp1
    name: ${device_name} last click coversettings
    id: disp1_lastclick_coversettings
    update_interval: 50ms
    component_name: coversetting
    internal: false
    filters:
      - lambda: |-
          if (strcmp(x.c_str(), id(lastclick_coversettings_global).c_str()) != 0) {
            return x;
          } else {
            return {};
          }
    on_value:
      then:
        - globals.set:
            id: lastclick_coversettings_global
            value: !lambda return x;
        - lambda: |-
            id(page_timer)->execute(int(id(page_timeout).state));

  ##### last click climate page, the main action variable - push to HA #####
  - platform: nextion
    nextion_id: disp1
    name: ${device_name} last click climatesettings
    id: disp1_lastclick_climatesettings
    update_interval: 50ms
    component_name: climatesetting
    internal: false
    filters:
      - lambda: |-
          if (strcmp(x.c_str(), id(lastclick_climatesettings_global).c_str()) != 0) {
            return x;
          } else {
            return {};
          }
    on_value:
      then:
        - globals.set:
            id: lastclick_climatesettings_global
            value: !lambda return x;
        - lambda: |-
            id(page_timer)->execute(int(id(page_timeout).state));

  ##### currentpage sensor, the main action variable - push to HA #####
  - platform: nextion
    nextion_id: disp1
    name: ${device_name} currentpage
    id: disp1_currentpage
    update_interval: 50ms
    component_name: currentpage
    internal: false
    filters:
      - lambda: |-
          if (strcmp(x.c_str(), id(currentpage_global).c_str()) != 0) {
            return x;
          } else {
            return {};
          }
    on_value:
      then:
        - globals.set:
            id: currentpage_global
            value: !lambda return x;
        - lambda: |-
            id(page_timer)->execute(int(id(page_timeout).state));

  ##### touchevent sensor, Reset the page timeout #####
  - platform: nextion
    nextion_id: disp1
    #name: ${device_name} touchevent
    id: disp1_touchevent
    update_interval: 50ms
    component_name: touchevent
    internal: true
    filters:
      - lambda: |-
          static std::string touchevent_history = "";
          if (strcmp(x.c_str(), touchevent_history.c_str()) != 0) {
            touchevent_history = x;
            return x;
            // touchevent_history = "";
          } else {
            return {};
          }
    on_value:
      then:
        - lambda: |-
            id(page_timer)->execute(int(id(page_timeout).state));

##### START - SWITCH CONFIGURATION #####
switch:

  # ##### Restart switch ######
  # - platform: restart
  #   name: ${device_name} Restart

  # ##### Restart in safe-mode #####
  # - platform: safe_mode
  #   name: ${device_name} Restart (Safe Mode)

  ##### global variable to keep track on whether the Nextion display is ready or not. Delays initial info from HA to the display #####
  - platform: template
    name: ${device_name} Nextion inited
    id: nextion_init
    entity_category: config
    restore_state: false
    assumed_state: off
    optimistic: true

  ##### Notification unread #####
  - platform: template
    name: ${device_name} Notification unread
    id: notification_unread
    entity_category: config
    restore_state: true
    optimistic: true

  ##### Notification sound #####
  - platform: template
    name: ${device_name} Notification sound
    id: notification_sound
    entity_category: config
    restore_state: true
    optimistic: true

  ##### Confirmation Message #####
  - platform: template
    name: ${device_name} Confirmation Message
    id: confirmation_message
    entity_category: config
    restore_state: false
    optimistic: true

  ##### PHYSICAL SWITCH 1 #####
  - platform: gpio
    name: ${device_name} Relay 1
    id: relay_1
    pin:
      number: 22

  ##### PHYSICAL SWITCH 2 ######
  - platform: gpio
    name: ${device_name} Relay 2
    id: relay_2
    pin:
      number: 19

  ##### DISPLAY ALWAYS ON #####
  - platform: gpio
    name: ${device_name} Screen Power
    id: screen_power
    entity_category: config
    pin:
      number: 4
      inverted: true
    restore_mode: ALWAYS_ON
    internal: true

  ##### Switch Display Sleep Modus #####
  - platform: template
    device_class: switch
    name: ${device_name} Sleep Modus
    id: sleep_modus
    entity_category: config
    restore_state: true
    assumed_state: false
    optimistic: true
    on_turn_off:
      - lambda: id(disp1).send_command_printf("home.sleepmodus.val=0");
      - globals.set:
            id: sleep_modus_global
            value: '0'
      - lambda:  id(disp1).set_component_value("settings.a02",0);
    on_turn_on:
      - lambda: id(disp1).send_command_printf("home.sleepmodus.val=1");
      - globals.set:
            id: sleep_modus_global
            value: '1'
      - lambda:  id(disp1).set_component_value("settings.a02",1);

  ##### Relay Local control Fallback #####
  - platform: template
    name: ${device_name} Relay 1 Local Fallback
    id: relay1_fallback
    entity_category: config
    restore_state: true
    optimistic: true

  - platform: template
    name: ${device_name} Relay 2 Local Fallback
    id: relay2_fallback
    entity_category: config
    restore_state: true
    optimistic: true

##### START - NUMBER CONFIGURATION #####
number:

  ##### SCREEN BRIGHTNESS #####
  - platform: template
    name: ${device_name} Display Brightness
    id: display_brightness
    entity_category: config
    unit_of_measurement: '%'
    min_value: 1
    max_value: 100
    step: 1
    restore_value: true
    optimistic: true
    set_action:
      then:
        - lambda: 'id(disp1).set_backlight_brightness(x/100);'
        - lambda: 'id(disp1).send_command_printf("home.brightness.val=%i", int(x));'
        - globals.set:
            id: display_brightness_global
            value: !lambda 'return int(x);'

  ##### SCREEN BRIGHTNESS DIMMED DOWN #####
  - platform: template
    name: ${device_name} Display Brightness Dimdown
    id: display_dim_brightness
    entity_category: config
    unit_of_measurement: '%'
    min_value: 1
    max_value: 100
    step: 1
    restore_value: true
    optimistic: true
    set_action:
      then:
        - lambda: 'id(disp1).send_command_printf("home.brightdd.val=%i", int(x));'
        - globals.set:
            id: display_dim_brightness_global
            value: !lambda 'return int(x);'

  ##### Temperature Correction #####
  - platform: template
    name: ${device_name} Temperature Correction
    id: temperature_correction
    entity_category: config
    unit_of_measurement: '°C'
    min_value: -10
    max_value: 10
    step: 0.5
    restore_value: true
    optimistic: true
    set_action:
      then:
        - globals.set:
            id: temperature_correction_global
            value: !lambda 'return x;'

##### page-timeout #####
  - platform: template
    name: ${device_name} Page Timeout
    id: page_timeout
    entity_category: config
    min_value: 0
    max_value: 60
    initial_value: 10
    step: 1
    restore_value: true
    optimistic: true

##### START - DISPLAY START CONFIGURATION #####
display:
  - platform: nextion
    id: disp1
    uart_id: tf_uart
    tft_url: ${nextion_update_url}
    on_setup:
      then:
        - lambda: id(disp1).send_command_printf("page 8");
        - lambda: id(disp1).set_component_text_printf("boot.esph_version", "%s", "3.2.2"); ### esphome-version ###
        - wait_until:
            api.connected
        - lambda: id(disp1).set_component_text_printf("boot.ip_addr", "%s", id(ip_address).state.c_str());
        - delay: 1s
        - number.set:
            id: display_brightness
            value: !lambda 'return id(display_brightness_global);'
        - number.set:
            id: display_dim_brightness
            value: !lambda 'return id(display_dim_brightness_global);'
        - lambda: id(disp1).set_component_text_printf("settings.a03", "%i", id(display_brightness_global));
        - lambda: id(disp1).set_component_text_printf("settings.a04", "%i", id(display_dim_brightness_global));
        - lambda: id(disp1).send_command_printf("settings.brightslider.val=%i", id(display_brightness_global));
        - lambda: id(disp1).send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global));
        - lambda: id(disp1).send_command_printf("home.sleepmodus.val=%i", id(sleep_modus_global));
        - lambda: id(disp1).set_component_value("settings.a02", id(sleep_modus_global) == 1);
        - delay: 1s
        - switch.template.publish:
            id: nextion_init
            state: on

### Script for page_timer
script:
  - id: page_timer
    mode: restart
    parameters:
      delay: int
    then:
      - lambda: ESP_LOGD("nspanel", "start page-timer delay %i", int(id(page_timeout).state));
      - delay: !lambda return delay *1000;
      - lambda: |-
          if (id(disp1_currentpage).state == "home" or id(disp1_currentpage).state == "screensaver" or id(disp1_currentpage).state == "boot" or int(id(page_timeout).state) == 0) {
            ESP_LOGD("nspanel", "no page-jump");
          } else {
            ESP_LOGD("nspanel", "timer->home");
            id(disp1).send_command_printf("page 0");
          }
deejaybeam commented 1 year ago

and, of coarse - any change in this file requres to compile and install the new firmware on the esp-home-device (panel)

Timmwardion commented 1 year ago

this is, because you use the "simple" esp-config (from install-wiki) under packages you see from where to load the rest (or full-config) to "merge" those. In your case, you have changed to use a local file instead of using the git-version.

But this does not matters - easiest way, if you don´t have much esp-home experiance and you want "local-full-control" is to just insert the code from: https://github.com/Blackymas/NSPanel_HA_Blueprint/blob/main/nspanel_esphome.yaml "over" the "simple-config" in esphome-dashboard (edit-device). Of course - you need to set your substitution to your needs

You can check the resulting "full-config" if you click on the validate-button of the device-config.

With the full-config direct in your device-editor, you have full-controll to all aspects of the code

Yeah I get that. It's just an include file and I've played around with both scenarios (using include or doing it directly), changing the baud rates etc same result each time.

Interesting though I googled that string (DRAKJHSUYDGBNCJHGJKSHBDN) and found this https://unofficialnextion.com/t/nextion-upload-protocol-v1-2-the-fast-one/1044/6

Seems it is the escape sequence for protocol reparse mode. Makes me wonder if these issues are due to an incompatibility between the upload protocol being used and the one expected, or an issue with the implementation of that protocol in ESPHome.

Both of which are above my pay grade to solve.

edwardtfn commented 1 year ago

Please try this to upload the blank tft, and let me know your results:

substitutions:
  device_name: "hallwaycontrol" 
  wifi_ssid: !secret wifi_ssid
  wifi_password: !secret wifi_password

  nextion_update_url: "http://192.168.1.127:8123/local/nspanelblank.tft"
#  nextion_update_url: "http://192.168.1.127:8123/local/nspaneleu.tft" # URL to local tft File

###### USE THIS ONLY FOR YOUR FIRST TFT UPLOAD, ONCE IT WORKED, REMOVE THOSE LINES ######
external_components:
  - source: github://pr#2956
    components: [nextion]
    refresh: 1h
###############################################################################

packages:
  remote_package:
    url: https://github.com/Blackymas/NSPanel_HA_Blueprint
    ref: main
    files: [nspanel_esphome.yaml]
    refresh: 300s
deejaybeam commented 1 year ago

Again: as far as I understood - while display (nextion) runs the factory-firmware, it is also in reparse-mode. As long this is true, esphome can not communicate with the display - so then ther is no upload possible.

The boot-sequence command should send a special-command, to disable reparse-mode. After that, esphome can connect - than it is possible to do a tft-upload.

In our tft´s the reparse-mode is disabled and baud(s) is set to 115200 (nextion instruction inside program.s)

As long the initial tft-installation is not done, then esphome (could) have problems to communicate with nextion, and at this point nothing is possible

edwardtfn commented 1 year ago

Blank tft has the same result

Which means it didn't upload the file, right? You still have your panel displaying the original screen from Sonoff, right?

What if you paste this link in your browser (in your computer): http://192.168.1.127:8123/local/nspanelblank.tft Can you download the file for your computer?

Timmwardion commented 1 year ago

Sorry - give me 20. Just trying a couple more things.

deejaybeam commented 1 year ago

@Timmwardion please do me a favour: If you have now (hopefully) the full-esphome-config file, please change the following section(s) to match this:

##### Functionality for the Nextion display #####
external_components:
  - source: github://pr#2956
    components: [nextion]
    refresh: 1h

and:

##### ESPHOME CONFIGURATION #####
esphome:
  name: ${device_name}
  min_version: 2022.10.2
  on_boot:
    priority: 601
    then:
      - lambda: id(disp1).send_command_printf("DRAKJHSUYDGBNCJHGJKSHBDN");
Timmwardion commented 1 year ago

Oh boy. Worked.

Adjusting the thread above to hide the truth :-) (me reacting too quickly and not reading properly)

Code above from @edwardtfn got the job done!

Flashed with blank.tft then flashed with nspanel_eu.tft. Waiting for the process to finish and I'll delete that section.

Update: Next challenge is that the screen is stuck on "loading...". Watching the logs though it all seems pretty good.

edwardtfn commented 1 year ago

Update: Next challenge is that the screen is stuck on "loading...". Watching the logs though it all seems pretty good.

Have you tried a reboot?

gravy72 commented 1 year ago

I had the same issue with my screen stuck on 'Loading'. Try setting the Weather Integration on the blueprint to Default, then reboot.

Timmwardion commented 1 year ago

Filling in some of the blueprint and the rebooting worked well. All good now. Thanks for all your help!

edwardtfn commented 1 year ago

Yeah, a million things could cause this "Loading..." issue, so I just wrote some text about this: #671

maltetgh commented 1 year ago
##### Functionality for the Nextion display #####
external_components:
 - source: github://pr#2956
   components: [nextion]
   refresh: 1h
##### ESPHOME CONFIGURATION #####
esphome:
  name: ${device_name}
  min_version: 2022.10.2
  on_boot:
    priority: 601
    then:
      - lambda: id(disp1).send_command_printf("DRAKJHSUYDGBNCJHGJKSHBDN");

Hi, new user here... I also got stuck with a factory new nspanel and was unable to flash the tft. The exit reparse button did nothing.

I was able to flash first the blank and then the eu file after applying @deejaybeam code in the ESP config and installing it again.

Sooo... you still have an issue in the current release which presumably affects every new user who uses an NSPanel with stock firmware.