# Value through switch permanently

**URL:** <https://discourse.nodered.org/t/value-through-switch-permanently/30102>\
**Category:** Dashboard\
**Created:** [15 July 2020 06:42 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102 "2020-07-15T06:42:51Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 08:48 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/21 "2020-07-15T08:48:50Z")

</div>

> [@Chorum](#):
>
> Because i Change the Topic in the Change node i cannot use this way for my values as payload….

Yeah, ok. But sorry I am still missing something.

The topic is set in the first `change` node. No need to delete the `msg.payload`.

 ![Screenshot from 2020-07-15 18-25-49](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/638a85927e48802ebf5039295376ebfaac72828d.png)

Is this how it will be in the (even) bigger picture?  
The node copied (though slightly modified to different names) as indicated.

But there is still a big problem I can see.

At the first `function` node..... What is going into there?

I am struggling to see how the input works.

You have 18 _readings_ coming in and need to display them on a `chart`.  
Each one with a different colour and name.

There seems to be something missing at the start which I think you are also missing which can make this a whole lot easier.

Can you show an example of what is sent into this part of the flow?

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [15 July 2020 08:54 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/22 "2020-07-15T08:54:26Z")

</div>

first : the payload deleting in the Change node is out 🙂

second: may be this can help to understand 🙂 🙂

 ![Dataflow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/5/35d0256ad19d3138bcb75e554ab6f9ba114af1d6.jpeg)

and in the Funktion node i send the value,labelname to the Chart if the switch is used. if not i send "0"  
i make some other Things there too, not related to the Chart but Need to be worked on that Position.

i want to Show the Chart labels dynamicly too, only for shown data, but that is for later.

a sample of the payload going into that is my first posted picture

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 09:07 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/23 "2020-07-15T09:07:22Z")

</div>

Ok.

But now I see a new _link_ from the `function` node to the second `switch`. Wasn't there before.

Ok, so if I now get what you are doing it is something like:

Start of flow... `input` (`function` node) Message is from any one of eighteen sources.

The incoming message is _split_ (as in is sent to two places) and goes **directly** to the `join` node where it is held waiting for a second message to arrive, and the other to a `switch` (indirectly) to be used to create a message part to indicate if you want this to be passed to the `chart` or not.

I am still stuck on why the other `switch` nodes don't have anything on their input/s.

So, the second part of the original message then arrives at the `join` node and a message is made - and then sent - to the `function` node.

That takes the message apart and looks if this data should be then on sent to the `chart`.  
If it is marked as _pass_ it is sent. If it marked as _block_ it is not.

Is that about what is happening?  
Still: why don't the other `switch` nodes have inputs to set their names?

I just saw you edited your post:  
[This one](https://discourse.nodered.org/t/value-through-switch-permanently/30102/19)  
Sorry. It is now out of context. I can't see what you edited.  
No problem, but I can't use it now with what I said.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 09:13 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/24 "2020-07-15T09:13:24Z")

</div>

Can you put a `debug` node at the start of the flow and show me what you are sending from a couple of the different _sources_?

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [15 July 2020 09:54 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/25 "2020-07-15T09:54:27Z")

</div>

1. the new Connection to the second switch was for testing Purpose 🙂

2. i have one source (here the empty function node left) with 18 values and valuenames like in the first Picture (i cut it to 4 sets for testing)

3. normally you dont Need Inputs for the switches. if a switch is used in the Dashboard the switch node send a string "true" -\> Change node for the join preparation -\> join node for Building the message -\>Funktion node where i check on that "true" to pass data to the Chart and textnodes.  
i would like to find a way to "block" a msg from Function node dynamicly, atm i send "0" as value.

4. the Change node before the first switch is for changing the switch label on the dashoard with a Name i get from the payload.

5. i have around 20 such payloads that i want to Display that way. i will try to use only one flow for all with switching between the inputsets later but thats not the case in this example..

i hope i covered all Questions … that editing isnt easy to follow

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 10:00 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/26 "2020-07-15T10:00:20Z")

</div>

Ok.

So could you please indulge me by posting a couple of messages that are for different chart colours?

Please paste them as I explained above.  
Over to the right of the output you move the mouse and there is a `copy value` pops up.  
Paste it here after clicking the `</>` button above.

Thanks.

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [15 July 2020 10:01 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/27 "2020-07-15T10:01:14Z")

</div>

```auto
{"topic":"ATESTEO/Wolfsburg/W16","payload":{"MQTTWert1":"25.1","MQTTWert1name":"T_BoxenLuft","MQTTWert2":"-101","MQTTWert2name":"N_EMA_VL","MQTTWert3":"932","MQTTWert3name":"n_Antrieb","MQTTWert4":"269","MQTTWert4name":"M_Antrieb","Status":"Läuft"},"qos":1,"retain":false,"_topic":"ATESTEO/Wolfsburg/W16","_msgid":"3f4512b0.dc5bee","kColor":"black","vColor":"black","template":"<html>\n<head>\n<style>\ntable.FixedTable\n{\n table-layout: fixed;\n border: 0;\n}\n</style> \n</head>\n<body>\n<table class=\"FixedTable\">\n <tbody>\n <tr ng-repeat=\"(k,v) in msg.payload\" ng-if=\"k != 'Item'\">\n <td style=\"width: 250; color:{{msg.kColor}}\">{{k}}</td>\n <td style=\"text-align:justify; color:{{msg.vColor}}\">{{v}}</td>\n </tr>\n </tbody>\n</table>\n</body>\n</html>","color":"lime"}

```

i hope thats Right ?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 10:03 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/28 "2020-07-15T10:03:58Z")

</div>

Yes, hang on while I decode it.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 10:18 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/29 "2020-07-15T10:18:32Z")

</div>

Ok, this isn't easy for me, but here goes:

This is the **payload** part of the message.

```auto
{"MQTTWert1":"25.1","MQTTWert1name":"T_BoxenLuft","MQTTWert2":"-101","MQTTWert2name":"N_EMA_VL","MQTTWert3":"932","MQTTWert3name":"n_Antrieb","MQTTWert4":"269","MQTTWert4name":"M_Antrieb","Status":"Läuft"},

```

This is what I can make of the `payload` part:

```auto
{"MQTTWert1":"25.1",
"MQTTWert1name":"T_BoxenLuft",
"MQTTWert2":"-101",
"MQTTWert2name":"N_EMA_VL",
"MQTTWert3":"932",
"MQTTWert3name":"n_Antrieb",
"MQTTWert4":"269",
"MQTTWert4name":"M_Antrieb",
"Status":"Läuft"},

```

Which parts of these change for the different _sources_?

I'm guessing one of the lines with the `name` part of the line.  
But only **one** of them should change to indicate the next _source_.

Or is it done in another part of the message?  
(Gotta ask)  
Or is it the `topic` that changes?

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [15 July 2020 10:32 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/30 "2020-07-15T10:32:31Z")

</div>

i dont understand the Question About different Sources.

this set of payload (originally 18 x value and 18 x Name) Comes from 1 source.

for later there will be around 20 Sources (divided by Topic) with the same set of 18+18 but not in this state.

i use the Name für changing the switch label and the value for the value.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 10:41 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/31 "2020-07-15T10:41:26Z")

</div>

Oh, ok. Got you now. So the message is _constructed_ before it gets here.

That is just 4 rather than 18 of them.

Ok.

I am sorry for not getting that sooner.

So, now I am with you on that.

With that, you seem to only ever use #1's message to set the name of the `switch`.  
Again: So the `change` node would be replicated all the way down to the other `switch` nodes but they extract different parts of the message.

Where the `change` node you have shown in the example sets the topic to:  
`payload.MQTTWert1name`  
The second version would set the topic to:  
`payload.MQTTWert2name`

and so on all the way to 18.

So let's build on that. Alas it is probably going to be modified once we establish it works.

I can post the flow as I think it will be to get the desired result if you want.  
But before that, I want to be sure I understand how it all works.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 July 2020 10:59 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/32 "2020-07-15T10:59:52Z")

</div>

I haven't been following the thread, but if all you need to do is to stop the message you send to the switch being sent on then clear the Pass Through Message checkbox in the switch config.  
If that is not the problem you are seeing then please ignore this post.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 11:05 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/33 "2020-07-15T11:05:19Z")

</div>

Thanks @Colin but I am trying to take baby steps (no offence @Chorum)  
I want to get one part working, then expand that to all.

Then, show a better way to do it - or another way.

It has taken me a long time to get my head around the message structure and it has only now fallen into place how it works.

Oops.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2020 11:11 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/34 "2020-07-15T11:11:17Z")

</div>

@Chorum:

This is a bit of a rebuild of what you posted.

I put the example message in the `function` node and use the `inject` node to inject the message.

It works and the `switches` get the right names.

```auto
[{"id":"8d08193c.f7a5d8","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"ec41bf90.caf2a","order":1,"width":"3","height":"1","passthru":true,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":1170,"y":4070,"wires":[["a5f9774b.5510d8"]]},{"id":"4c68517d.8f0068","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"ec41bf90.caf2a","order":2,"width":"3","height":"1","passthru":true,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":1170,"y":4100,"wires":[["7e837175.314d9"]]},{"id":"196b1998.e7208e","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"ec41bf90.caf2a","order":3,"width":"3","height":"1","passthru":true,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":1170,"y":4130,"wires":[["623733d1.dbcdec"]]},{"id":"8dd6be10.f35b08","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"ec41bf90.caf2a","order":4,"width":"3","height":"1","passthru":true,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":1170,"y":4160,"wires":[["2ae85942.130a56"]]},{"id":"6c00509e.93aca","type":"change","z":"b9924a74.4d98f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert1name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":4070,"wires":[["8d08193c.f7a5d8"]]},{"id":"c32ad7b3.fd898","type":"change","z":"b9924a74.4d98f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert2name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":4100,"wires":[["4c68517d.8f0068"]]},{"id":"a7c9c4f7.82dc38","type":"change","z":"b9924a74.4d98f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert3name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":4130,"wires":[["196b1998.e7208e"]]},{"id":"2a01eaa3.970afe","type":"change","z":"b9924a74.4d98f8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert4name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1020,"y":4160,"wires":[["8dd6be10.f35b08"]]},{"id":"f319b7aa.05703","type":"function","z":"b9924a74.4d98f8","name":"","func":"msg = {\"topic\":\"ATESTEO/Wolfsburg/W16\",\"payload\":{\"MQTTWert1\":\"25.1\",\"MQTTWert1name\":\"T_BoxenLuft\",\"MQTTWert2\":\"-101\",\"MQTTWert2name\":\"N_EMA_VL\",\"MQTTWert3\":\"932\",\"MQTTWert3name\":\"n_Antrieb\",\"MQTTWert4\":\"269\",\"MQTTWert4name\":\"M_Antrieb\",\"Status\":\"Läuft\"},\"qos\":1,\"retain\":false,\"_topic\":\"ATESTEO/Wolfsburg/W16\",\"_msgid\":\"3f4512b0.dc5bee\",\"kColor\":\"black\",\"vColor\":\"black\",\"template\":\"<html>\\n<head>\\n<style>\\ntable.FixedTable\\n{\\n table-layout: fixed;\\n border: 0;\\n}\\n</style> \\n</head>\\n<body>\\n<table class=\\\"FixedTable\\\">\\n <tbody>\\n <tr ng-repeat=\\\"(k,v) in msg.payload\\\" ng-if=\\\"k != 'Item'\\\">\\n <td style=\\\"width: 250; color:{{msg.kColor}}\\\">{{k}}</td>\\n <td style=\\\"text-align:justify; color:{{msg.vColor}}\\\">{{v}}</td>\\n </tr>\\n </tbody>\\n</table>\\n</body>\\n</html>\",\"color\":\"lime\"};\nreturn msg;","outputs":1,"noerr":0,"x":990,"y":4370,"wires":[["6c00509e.93aca","87b86163.c09e5","c32ad7b3.fd898","a7c9c4f7.82dc38","6525dbf6.870b14","2a01eaa3.970afe"]]},{"id":"f87fa938.93f1b","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":830,"y":4370,"wires":[["f319b7aa.05703"]]},{"id":"ec41bf90.caf2a","type":"ui_group","z":"","name":"Messwerte auswählen","tab":"260a696.4ccbf96","order":1,"disp":true,"width":"29","collapse":false},{"id":"260a696.4ccbf96","type":"ui_tab","z":"","name":"W16-Chart","icon":"dashboard","order":11,"disabled":false,"hidden":false}]

```

See how the `switch` nodes have slightly been changed.  
This isn't too important as you said the original way worked.

But I would like to stress it may be better if you do it the way I show in this code because we are going to build on that part later.

Can you confirm you are getting this part working?

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [16 July 2020 05:52 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/35 "2020-07-16T05:52:25Z")

</div>

Hey Colin,  
thats Right and i tried that.  
but didnt help ☹

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [16 July 2020 06:11 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/36 "2020-07-16T06:11:11Z")

</div>

Hello,

at first, thank you for your Patience Trying\_to\_learn !

i have got that flow working, and it works fine. As far i understand the payload isnt routed through the switch because the Topic changed ?

what i didnt find was the slightly change in the switches ?

And there is one Thing with that flow: if i inject a second time the switches are resetted to "off"  
I would like to have a stable switch Position only for Manual changes of the switchposition.

( later i want to put a timer behind that, so the switches go off after 30 minutes, thats necessary because i have to send a message to the Client at that time. but thats for later)

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [16 July 2020 07:27 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/37 "2020-07-16T07:27:23Z")

</div>

The Problem seems to be the Change node before the switch. if it is connected the switch sends true and cannot hold switch Position. without it it works normally.

atm i work on that

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [16 July 2020 09:53 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/38 "2020-07-16T09:53:12Z")

</div>

I have tried something different.  
The switch node only becomes 1 value in the payload: the name for the switch.  
after the switch i use a change node to get the switch value in a global variable.  
In the function node i ask on that variable and without the first change node for namegiving everything works again fine.

I dont understand that. i check on a global variable to pass values through the function node and the switch does not get any value, only the Name that i want him to have.  
From where Comes the value ?

```auto
[{"id":"fef7d669.96ce98","type":"change","z":"af61c022.bc96e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"Wertcheck1","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":3940,"y":2370,"wires":[[]]},{"id":"e9b9dd78.e10f1","type":"ui_switch","z":"af61c022.bc96e","name":"","label":"{{msg.topic}}","tooltip":"","group":"22029319.b38d4c","order":1,"width":"3","height":"1","passthru":true,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3650,"y":2370,"wires":[["fef7d669.96ce98"]]},{"id":"ff5e497e.748c38","type":"change","z":"af61c022.bc96e","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert1name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3500,"y":2370,"wires":[["e9b9dd78.e10f1"]]},{"id":"22029319.b38d4c","type":"ui_group","z":"","name":"Messwerte auswählen","tab":"ec7a53af.4ac29","order":1,"disp":true,"width":"29","collapse":false},{"id":"ec7a53af.4ac29","type":"ui_tab","z":"","name":"W16-Chart","icon":"dashboard","order":11,"disabled":false,"hidden":false}]

```

i really dont understand that….

---

<div class="post-metadata">

**Author:** ![Chorum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/chorum/32/47644_2.png) [@Chorum](https://discourse.nodered.org/u/Chorum)\
**Post date:** [16 July 2020 10:29 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/39 "2020-07-16T10:29:26Z")

</div>

New try:  
Injecting the switchname once, while switch is on off.  
Works fine again.  
If i put the switch on "on" the value flows. but if i put the switch on "off" again, the value flow continous.  
i cant figure out how...

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [16 July 2020 10:54 UTC](https://discourse.nodered.org/t/value-through-switch-permanently/30102/40 "2020-07-16T10:54:03Z")

</div>

It is good to see you are trying things.

Alas there is no _magic_ answer. Alas you have to put in the work.

Sorry, I haven't really checked your latest flow, but I would like to discuss what you are wanting to do and **how**.

We all see things differently, and that is a good thing, otherwise it would be a very boring world.

So, from what I have seen, and only recently realised is you are combining all the messages from the 18 inputs to one big message, as an object (I think is the term).

Your `function` node needs to see the messages come in, and parse them and check if the _allow_ part is set.  
If it is, it passes the message and its value.  
If it is not set (or blocked - if you will), it doesn't allow the message to get through, or replaces the value with a `0`.

But **how** you are doing it is ........ complicating things a bit.

So I want to present you an _alternative_ solution/method:

You get the message/s coming in.  
For now I will use the 4 you supplied.  
(From before)

```auto
{"MQTTWert1":"25.1",
"MQTTWert1name":"T_BoxenLuft",
"MQTTWert2":"-101",
"MQTTWert2name":"N_EMA_VL",
"MQTTWert3":"932",
"MQTTWert3name":"n_Antrieb",
"MQTTWert4":"269",
"MQTTWert4name":"M_Antrieb",
"Status":"Läuft"},

```

You are needing to _filter_ the messages on their `MQTTWert`_x_`name` part.

So, you have .... 4 inputs. (We can expand it to 18 once we get the mechanics working better.)

How are you making this message?

I think we may need to start there.

I am guessing you are using a `join` node?

[Previous page](https://discourse.nodered.org/t/value-through-switch-permanently/30102.md?page=1)

[Next page](https://discourse.nodered.org/t/value-through-switch-permanently/30102.md?page=3)
