esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

Nextion/NSPanel update_all_components() doesn't seem to work #5212

Open DorjeDorf opened 7 months ago

DorjeDorf commented 7 months ago

The problem

I have been trying to get the sleep mode on NSPanels for quite a while and could never get it to work, because data sent to the NSPanel, while the screen is sleeping is not updating when the screen wakes. You have to wait until a new entry is sent from HA to get the value to appear.

I tried multiple ways to get it work, but nothing seems to help. Things tried:

  1. Add an entry to call update_all_components() on_wake in the screen definition
  2. Add a custom call for update_all_components() on button press
  3. Added delays of 1 through 10 seconds to on wake and button press before update_all_components() gets called
  4. created a button configured to trigger update_all_commands() at any point.

Number 4 is especially interesting. I had the NSPanel go to sleep and woke it up after 5 minutes - I show a clock on the screen and saw in the ESPHome log, updates were sent properly and were received by ESPHome. I hit the button to manually update all components before a new time came in from HA, but nothing changed. The log showed propery, that the button was pressed, but nothing changed on the screen until a new update came from HA.

Either I am not understanding how this works, or it doesn't work. I tried looking at the code, and I am not in sleep, I don't ignore the command in setup and the screen is woken up (I even added sleep(0) in option 4 - and I know it works, because pressing the button with the screen sleeping- it would wake up).

How should one get the Nextion screen to update data on waking up from sleep?

Which version of ESPHome has the issue?

2023..

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

Every one this year. I had this for a long time.

What platform are you using?

ESP32

Board

NSPanel (multiple hardware revisions)

Component causing the issue

Nextion

Example YAML snippet

# Configure the screen itself
display:
  - platform: nextion
    id: disp1
    uart_id: tf_uart
    tft_url: http://<address>/local/nspanel/file.tft
    on_wake: 
      then: 
        - lambda: 'id(disp1).send_command_printf("sleep_timer.en=1");'
        - lambda: 'id(disp1).update_all_components();'
    on_setup:
      then:
        - number.set:
            id: brightness
            value: 30
        - lambda: |-
            id(disp1).set_component_text(
              "room_name", "${room_name}"
            );
        - lambda: 'id(disp1).send_command_printf("sleep_timer.en=1");'

--

  - platform: template
    name: $device_name Update all data
    on_press:
      - lambda: 'id(disp1).sleep(0);'
      - delay: 5s      
      - lambda: 'id(disp1).update_all_components();'

Anything in the logs that might be useful for us?

After pressing the button:
'nspanel-04 Update all data' Pressed.

After waking up without manual trigger of data update:
13:08:05    [D] [nextion:468]   
Got touch at x=255 y=206 type=PRESS
13:08:06    [D] [nextion:468]   
Got touch at x=255 y=206 type=RELEASE
13:08:06    [D] [nextion:822]   
all_components_send_state_

Additional information

No response

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.