sairon / esphome-nspanel-lovelace-ui

ESPHome component for NSPanel Lovelace UI
Other
126 stars 32 forks source link

feat: add ESP-IDF support #33

Closed sairon closed 4 months ago

sairon commented 1 year ago

Add support for esp-idf framework, partially based on ESPHome PR esphome/esphome#5667 by @edwardtfn (thank you, Edward!). The upstream code has been refactored to share more when Arduino or ESP-IDF is used and to use baud rate switching used in this "fork".

This is currently still WIP, I will do a bit more refactoring and testing, but initial tests are looking good and there are indeed some resource savings when compared to Arduino, as seen with my testing config:

Arduino:

RAM:   [=         ]  14.6% (used 47928 bytes from 327680 bytes)
Flash: [=======   ]  71.1% (used 1304205 bytes from 1835008 bytes)

ESP-IDF:

RAM:   [=         ]  10.7% (used 35048 bytes from 327680 bytes)
Flash: [======    ]  61.2% (used 1123305 bytes from 1835008 bytes)

Fixes #23.

For those who are eager to try (more testers are always welcome!), simply update ref in your config to add-esp-idf-support, and ideally also the refresh time:

external_components:
  - source:
      type: git
      url: https://github.com/sairon/esphome-nspanel-lovelace-ui
      ref: add-esp-idf-support
    refresh: 0s
    components: [ nspanel_lovelace ]

It is recommended to use serial for transition from Arduino to IDF, because IIRC the partition layout is a bit different, but I have tested the OTA works both ways without problems too.

rschueler commented 1 year ago

Thanks! Compiled it together with bluetooth proxy and worked. Flash 91% ... Upload of new TFT file also worked fine!

edwardtfn commented 1 year ago

I'm curious here... Why don't you guys use the Nextion component from ESPHome? I see your library is way simpler and probably easier to maintain, but other than that, is there a reason to be by the side? It would be nice if we can collaborate more with each other... 😉 And please let me know if you have issues with the idf code for uploading TFT. I will be happy to help.

sairon commented 1 year ago

@edwardtfn The reason for a separate component is that it implements the custom protocol used by the NSPanel Lovelace UI Nextion firmware. See the repo's readme for details - the goal is to have an easy to use component, similarly to what Jesse did (but never merged) for the stock NSPanel FW. I imagine the same might be possible to achieve with the Nextion component and bunch of lambda scripts, but it will be hard to use and maintain. And using a custom component for comms and upstream Nextion for upload is not possible either, because they will have to share the same UART.

randybb commented 1 year ago

I have switched all my 6 panels from arduino to idf - no issues so far. Thanks a loot

rschueler commented 1 year ago

From time to time I have follwing warnings in the logs: [17:17:52][W][component:214]: Component mqtt took a long time for an operation (0.12 s). [17:17:52][W][component:215]: Components should block for at most 20-30ms. [17:18:00][W][component:214]: Component mqtt took a long time for an operation (0.08 s). [17:18:00][W][component:215]: Components should block for at most 20-30ms.

edwardtfn commented 1 year ago

https://esphome.io/changelog/2023.7.0.html#a-new-warning-in-the-logs

edwardtfn commented 10 months ago

Hey, you may wanna know that the original version where I've added support to ESP-IDF wasn't supporting HTTPS. I've added that support to the ESPHome component (esphome/esphome#6051) and it works pretty solid. You can use that to download the files directly from GitHub, removing the need of copying the files to a local http server.

Bascht74 commented 9 months ago

Now it works with https: https://github.com/esphome/esphome/pull/6051

@sairon Could you merge then? It works stable in my condiguration for some time and now https is possible

Bascht74 commented 9 months ago

Hi @sairon I still hope you can merge this pull request so that this PR comes into focus: https://github.com/sairon/esphome-nspanel-lovelace-ui/pull/34