Nextion Gauge Needle

Hi Everyone,

I started programming the nextion touch display with ESPHome. I have a little problem with the gauge component of nextion. I can write to the display gauge a value (e.g. position of the gauge needle) of a homeassisant sensor of my choice. But if that value changes, the new and (all) the old needle positions of the gauge stay on the screen.
Of course, I would like to have all old needle positions disappear and only show the newest.

Part of my ESPHome Code looks like this:

display:
  - platform: nextion
    id: nextiondisplay
    update_interval: 5s
    lambda: |-

            auto date = id(sntp_time).now().strftime("%b. %d");
            auto time = id(sntp_time).now();
            
            it.set_component_text("date", date.c_str());
            it.set_component_text_printf("time","%02d:%02d",time.hour,time.minute);
            it.set_component_value("gauge", id(power_total).state/1000*200);

and the according home assistant value is being added like that:

sensor:

  - platform: homeassistant  
    id: power_total
    entity_id: sensor.power_total_usage_house  
    accuracy_decimals: 1

Does anyone have found a solution for that or can hint me in the right direction?

Thanks

Does anyone have an idea how to solve my problem?

Thank you

Hi I am new with Nextion and has the same issue.
Please help me
Phil

I’m also using the gauge, and don’t have any problems with previous “needle positions”, however I cast the state value to a int, I’m not using floats within the Nextion Display. So, what’s happening if you try:

it.set_component_value("gauge", (int) id(power_total).state/1000*200);

Thank you very much but this does not work.
With the addition of this (int) the gauge does not move anymore .
I suspect that the issue is perhaps linked with the fact that I have put the gauge in a different page ( perhaps)
When I get several needle on the screen, the fact to come back to the first page and back, all the needle are blanked and gauge starts from new values to fill the screen with needles !
Any other idea ?
Phil