# Variable payload keeps still displayed on the UI even when no there's no payload

**URL:** <https://discourse.nodered.org/t/variable-payload-keeps-still-displayed-on-the-ui-even-when-no-theres-no-payload/64610>\
**Category:** General\
**Created:** [2 July 2022 11:27 UTC](https://discourse.nodered.org/t/variable-payload-keeps-still-displayed-on-the-ui-even-when-no-theres-no-payload/64610 "2022-07-02T11:27:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![omardmf](https://avatars.discourse-cdn.com/v4/letter/o/bbe5ce/32.png) [@omardmf](https://discourse.nodered.org/u/omardmf)\
**Post date:** [2 July 2022 11:27 UTC](https://discourse.nodered.org/t/variable-payload-keeps-still-displayed-on-the-ui-even-when-no-theres-no-payload/64610/1 "2022-07-02T11:27:05Z")

</div>

I'm using python to detect two colors "red" and "green", and display them on the node red UI in the form of a text and a led, if i detect green a text green will be written and the led is lit green, but when i terminate the color detection code, the text and led are still green.  
i have a function before the text and led to discriminate between red and green:

var Color = msg.payload  
if (Color === "Red") {  
return msg;  
}  
else if (Color === "Green") {  
return msg;  
}

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [2 July 2022 11:51 UTC](https://discourse.nodered.org/t/variable-payload-keeps-still-displayed-on-the-ui-even-when-no-theres-no-payload/64610/2 "2022-07-02T11:51:01Z")

</div>

As far as I can see, you are not actually changing the message payload - just returning the original message from each part of the 'if' 'else' construct.

It would help if you posted/shared your Node-RED flow and explained what your main objective is.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 August 2022 11:51 UTC](https://discourse.nodered.org/t/variable-payload-keeps-still-displayed-on-the-ui-even-when-no-theres-no-payload/64610/3 "2022-08-31T11:51:04Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
