# Keep value from another flow on update

**URL:** <https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951>\
**Category:** Dashboard\
**Created:** [7 September 2018 16:20 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951 "2018-09-07T16:20:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![arneym](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arneym/32/54_2.png) [@arneym](https://discourse.nodered.org/u/arneym)\
**Post date:** [7 September 2018 16:20 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951/1 "2018-09-07T16:20:52Z")

</div>

I am using a template node to create a machine status page. Here is a screenshot.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c51716ac54ca1f8473962de13ecf3b601d4ff32a.png)

My problem is when I get a status from a different machine, it clears the machine in red.  
The white machine should be green and the red machine should be red.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/723dbba03b4a503deedd01b8c2fbd35e8d9d0ad7.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/a9d56ac8dfd846bbf38fa79e9e19bc053570c1e1.png)

The LED needs to keep the last value, unless it changes.

I think that I am struggling with storing values. I have looked at the tutorials and the storing value page on the NR site, but I do not understand.

Here is my code:  
`[{"id":"5116599.e09b4a8","type":"ui_template","z":"ab8609d3.76eee8","group":"f6f1d68f.b33788","name":"InCycle LH35N-3000B","order":4,"width":"0","height":"0","format":"<style>\n.led {\n float: right;\n padding: 3px;\n width: 10px;\n height: 10px;\n margin: 2px 5px 5px 5px;\n border-radius: 0%;\n \n}\n</style>\n\n<div>LH35N-3000B {{msg.topic}}<span class=\"led\" style=\"background-color: {{msg.payload}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.payload}} 0 3px 15px;\"></span></div>\n","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":2600,"y":280,"wires":[["8ae78367.ad921"]]},{"id":"8ae78367.ad921","type":"change","z":"ab8609d3.76eee8","name":"","rules":[{"t":"set","p":"lh35n3000b","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2920,"y":200,"wires":[["9980e230.a9d4c"]]},{"id":"9980e230.a9d4c","type":"link out","z":"ab8609d3.76eee8","name":"LED LH35N-3000B Status out","links":["d57a88ba.5a8d08"],"x":3075,"y":200,"wires":[]},{"id":"d57a88ba.5a8d08","type":"link in","z":"ab8609d3.76eee8","name":"LED LH35N-3000B Status in","links":["9980e230.a9d4c","84c214e8.33f3c8","79f69d72.a0f734"],"x":2975,"y":280,"wires":[["a8da5e89.290ef","4a49bfa0.b56b9"]]},{"id":"a8da5e89.290ef","type":"ui_template","z":"ab8609d3.76eee8","group":"df7f71ac.38225","name":"","order":0,"width":"27","height":"10","format":"<!DOCTYPE html>\n<html lang=\"en\">\n <body>\n <style>\n.img {\n width: 100%;\n height: 100%;\n}\n.led35nb {\n position: absolute;\n padding: 3px;\n width: 10px;\n height: 10px;\n margin: 2px 5px 5px 5px;\n border-radius: 0%;\n top: 310px;\n right: 660px;\n}\n.led35n {\n position: absolute;\n padding: 3px;\n width: 10px;\n height: 10px;\n margin: 2px 5px 5px 5px;\n border-radius: 0%;\n top: 280px;\n right: 660px;\n}\n.ledht {\n position: absolute;\n padding: 3px;\n width: 10px;\n height: 10px;\n margin: 2px 5px 5px 5px;\n border-radius: 0%;\n top: 270px;\n right: 360px;\n}\n\n</style>\n <div class=\"container\">\n <a><span class=\"led35nb\" style=\"background-color: {{msg.lh35n3000b}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.lh35n3000b}} 0 3px 15px;\"></span></a>\n <a><span class=\"led35n\" style=\"background-color: {{msg.lh35n3000}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.lh35n3000}} 0 3px 15px;\"></span></a>\n <a><span class=\"ledht\" style=\"background-color: {{msg.ht}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.ht}} 0 3px 15px;\"></span></a>\n <img src=\"/turning.png\" alt=\"turning\" class=\"img\">\n </div>\n \n </body>\n\n</html>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":3100,"y":280,"wires":[[]]},{"id":"4a49bfa0.b56b9","type":"debug","z":"ab8609d3.76eee8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":3130,"y":380,"wires":[]},{"id":"f6f1d68f.b33788","type":"ui_group","z":"","name":"Shaft Turning Room","tab":"157f0329.92370d","order":1,"disp":true,"width":"6","collapse":false},{"id":"df7f71ac.38225","type":"ui_group","z":"","name":"Turning Room","tab":"3679129f.641f9e","disp":true,"width":"27","collapse":false},{"id":"157f0329.92370d","type":"ui_tab","z":"","name":"All - MC Status","icon":"dashboard","order":37},{"id":"3679129f.641f9e","type":"ui_tab","z":"","name":"Testing","icon":"dashboard"}]`

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [7 September 2018 16:58 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951/2 "2018-09-07T16:58:11Z")

</div>

It is not possible to import your flow. Please try using the 3 backticks before and after the code.

---

<div class="post-metadata">

**Author:** ![arneym](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arneym/32/54_2.png) [@arneym](https://discourse.nodered.org/u/arneym)\
**Post date:** [7 September 2018 17:45 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951/3 "2018-09-07T17:45:30Z")

</div>

Thank you! I added the backticks.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [7 September 2018 19:41 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951/4 "2018-09-07T19:41:14Z")

</div>

Apparently, you did not share the full code. Perhaps you have nodes spread over more than one tab ? I remind you that when you export a flow you are exporting only the nodes from a single tab.

From what is available I can see that you set the color of the led35nb using below node change but I can´t see where you set the value for the led35n, so it is not possible to understand the logic in your code.

 ![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2b9532b2f0b07e4438487cd2270060302a882432.png)

At the end what display the color of the leds in this chunk of code, so it is critical to understand where and how the properties msg.lh35n3000 and msg.lh35n3000b are configured.

```auto
 <a><span class="led35nb" style="background-color: {{msg.lh35n3000b}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.lh35n3000b}} 0 3px 15px;"></span></a>
 <a><span class="led35n" style="background-color: {{msg.lh35n3000}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.lh35n3000}} 0 3px 15px;"></span></a>

```

---

<div class="post-metadata">

**Author:** ![arneym](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arneym/32/54_2.png) [@arneym](https://discourse.nodered.org/u/arneym)\
**Post date:** [8 September 2018 10:47 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951/5 "2018-09-08T10:47:24Z")

</div>

I have a separate tab for each machine. The lh35n3000 machine has the same change node and links to the template node.

Thanks,

Mike

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [8 September 2018 14:46 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951/6 "2018-09-08T14:46:05Z")

</div>

> [@arneym](#):
>
> I have a separate tab for each machine. The lh35n3000 machine has the same change node and links to the template node.

I understand now. You have to make sure that the template node will always get the input msg with values assigned for each and every background-colors. Nowadays the template is getting msgs with undefined values. Probably the easiest way to handle this is using global variables, like shown in below flow.

Flow:

```auto
[{"id":"cbfe06cd.3ed808","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"e4516210.98ee4","type":"change","z":"cbfe06cd.3ed808","name":"","rules":[{"t":"set","p":"lh35n3000","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":140,"wires":[["ca8e80ee.bcd5"]]},{"id":"3e2c66a0.09c9ca","type":"ui_template","z":"cbfe06cd.3ed808","group":"5647c8f1.30bf68","name":"","order":0,"width":"27","height":"10","format":"<!DOCTYPE html>\n<html lang=\"en\">\n <body>\n <style>\n.img {\n width: 100%;\n height: 100%;\n}\n.led35nb {\n position: absolute;\n padding: 3px;\n width: 10px;\n height: 10px;\n margin: 2px 5px 5px 5px;\n border-radius: 0%;\n top: 310px;\n right: 660px;\n}\n.led35n {\n position: absolute;\n padding: 3px;\n width: 10px;\n height: 10px;\n margin: 2px 5px 5px 5px;\n border-radius: 0%;\n top: 280px;\n right: 660px;\n}\n.ledht {\n position: absolute;\n padding: 3px;\n width: 10px;\n height: 10px;\n margin: 2px 5px 5px 5px;\n border-radius: 0%;\n top: 270px;\n right: 360px;\n}\n\n</style>\n <div class=\"container\">\n <a><span class=\"led35nb\" style=\"background-color: {{msg.lh35n3000b}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.lh35n3000b}} 0 3px 15px;\"></span></a>\n <a><span class=\"led35n\" style=\"background-color: {{msg.lh35n3000}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.lh35n3000}} 0 3px 15px;\"></span></a>\n <a><span class=\"ledht\" style=\"background-color: {{msg.ht}}; box-shadow: black 0 -1px 1px 0px, inset black 0 -1px 4px, {{msg.ht}} 0 3px 15px;\"></span></a>\n <img src=\"/turning.png\" alt=\"turning\" class=\"img\">\n </div>\n \n </body>\n\n</html>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":940,"y":200,"wires":[[]]},{"id":"b1db552.49d27a8","type":"inject","z":"cbfe06cd.3ed808","name":"","topic":"BreakDown","payload":"#FF0000","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":180,"wires":[["e4516210.98ee4"]]},{"id":"63bd4513.c4898c","type":"inject","z":"cbfe06cd.3ed808","name":"","topic":"InCycle","payload":"#00FF00","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":140,"wires":[["e4516210.98ee4"]]},{"id":"6edf2b29.0535c4","type":"change","z":"cbfe06cd.3ed808","name":"","rules":[{"t":"set","p":"lh35n3000b","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":260,"wires":[["ca8e80ee.bcd5"]]},{"id":"41a483e5.b59cbc","type":"inject","z":"cbfe06cd.3ed808","name":"","topic":"BreakDown","payload":"#FF0000","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":300,"wires":[["6edf2b29.0535c4"]]},{"id":"9d290725.62c838","type":"inject","z":"cbfe06cd.3ed808","name":"","topic":"InCycle","payload":"#00FF00","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":260,"wires":[["6edf2b29.0535c4"]]},{"id":"ca8e80ee.bcd5","type":"function","z":"cbfe06cd.3ed808","name":"Read Global Status","func":"msg.lh35n3000b = global.get(\"lh35n3000b\");\nmsg.lh35n3000 = global.get(\"lh35n3000\");\nmsg.ht = global.get(\"ht\");\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":200,"wires":[["3e2c66a0.09c9ca"]]},{"id":"5647c8f1.30bf68","type":"ui_group","z":"","name":"Turning Room","tab":"18ccbd6a.e61163","disp":true,"width":"27","collapse":false},{"id":"18ccbd6a.e61163","type":"ui_tab","z":"","name":"Testing","icon":"dashboard"}]

```

---

<div class="post-metadata">

**Author:** ![arneym](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arneym/32/54_2.png) [@arneym](https://discourse.nodered.org/u/arneym)\
**Post date:** [13 September 2018 11:48 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951/7 "2018-09-13T11:48:50Z")

</div>

@Andrei,

I'm sorry that I'm just getting back with you. I had been out of town, and had not gotten a chance to read your message. This was just the answer that I needed. Everything works! I have added more machines to the code and everything is working as expected.

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![arneym](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/arneym/32/54_2.png) [@arneym](https://discourse.nodered.org/u/arneym)\
**Post date:** [13 September 2018 13:55 UTC](https://discourse.nodered.org/t/keep-value-from-another-flow-on-update/2951/8 "2018-09-13T13:55:30Z")

</div>

In case you all were interested, here is the result!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/de452cf7a18cd2e6bf9063b266b77466a689d2d5.png)
