Value through switch permanently

these values are part of a bigger payload that is beeing send from a computer to the mqtt broker.
The payload is a JSON Object wich is changed to a JavaScript object .
until the payload reaches the entry of the chartflow it has been filtered to the values i Need at that point.

I am not an native english speaker, i hope i make myself clear :slight_smile:

That is ok. I failed English anyway.

Oh, so the values are already in this package. No problems.

Hang on while I mess around with things.

Oh, ok, something for you to try:

Here is a bit of the code we are using:

[{"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":"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":"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}]

The change node sets the topic to ...... payload.MQTTWert1name then in the switch node the label is set to {{msg.topic}}

For the sake of seeing how you can cheat, put: {{msg.payload.MQTTWert1name}} in the switch node's label where we now have {{msg.topic}} and delete the change node before the switch.

See if that works.
Do you understand what is happening?

I can post the code but I think you need to do it yourself to get an understanding of what is happening and why.

In the mean time I will work on what needs to happen for the next part to work.

I understand and tried something similar.
Problem stays.

But i have a new thing :
if i switch the switch on and wait a second, the switch goes off by himself and the value stays.
BUT!!!! if i am fast enough to switch it manually off the value is gone and the behavior is perfekt.
I need to get that automaticly going "off" gone…..

Yeah, the switch node can be tricky sometimes.

Did you try what I suggested with the change node and the switch node with the label?

The output is not important. Only if the switch has the right name at this stage.

Yes i did it. Works like mentioned.

Good. So you can see how you can reduce the code by not needing/using the change node to set the msg.topic to msg.payload........ (sorry, but I hope you understand that part)

But while I was away, there is a problem with having the message like it is.

If the switch is OFF do you want to send 0 or nothing?

Either way, the problem comes into play because the entire message - with all the other 3 parts - is passed through. 3 in out example. Really it is 18, so that is a lot more message deconstruction that needs to be done.

Looking at your function node, you seem somewhat skilled at javascript and the structure.
Do you know what context is? For nodes and for the flow? (there is also global but I don't want to complicate (pollute?) the global when flow should suffice).

(Sorry)

What is this template that is in the message? Is it important?

When everything works i will try to cut it down :slight_smile: for development i try to use more single steps so i can intervene at every point.

the template isnt negotiable :slight_smile:

atm i use the value of the switch as global in the function node. so no Need to join with the original payload.

at the switch there is only one value and this is MQTTWert1name.

so no data is flowing from the switch anywhere , only to the global to check "on" and "off".

I would like to top sending something on "off" but atm i send 0 or 1 for testing. null doesnt work.
i wish i could send nothing, so i could vanish the label of the value in the Chart node while switch is on "off".

i write in any programming language, not perfect but i get it to work everytime :slight_smile:

Ok, you are using context (why global?)....

So the template part must be kept. :frowning: That makes things complicated in some ways.

The problem as I see it is that all the individual messages are grouped when they get to this part of the program.

Yes, and the other/s are 2, 3, 4, 5 and so on to 18 - if I get what is happening.

But back to what I am saying.

Ok, for what ever reason all the 18 messages are delivered in one bigger message.

You will be better at this than me.

You need to break them back down to their individual 18 (or for now 4) messages.

I'm guessing the split node will do this, but I am not smart enough to know how to do that, as it is not a simple msg.payload.

How you are doing it now will cause problems because you are (say) stopping message1 getting through in that part of the code.

HOWEVER!

There are another 17 (3) copies of that message passing through the other parts and it will not be blocked. So you have a problem there.

Until you separate the messages back to their 18 individual messages, you are going to have a lot of headaches you (probably) don't need.

Splitting them - though more labourius at one level - will greatly simplify filtering them.

How often (fast) are these messages arriving?

Why is the template not negotiable?

It isn't used in the chart node.

All the chart needs is a msg.topic and msg.payload.
The topic to name the line and the payload to be the value of the line on the chart.

I see you are replying, but.....

Here is a flow that maybe does what you want.

[{"id":"49798152.e859d8","type":"change","z":"b9924a74.4d98f8","name":"Part 2","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert2","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert2name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4350,"wires":[["18fade6d.1843ca","53a404d1.59f7ac"]]},{"id":"fb40c7a6.d7dad8","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":3060,"y":4390,"wires":[["66a86c89.e1e4ec","7bd08973.eb2448","49798152.e859d8","8031996.9decb68","f57f3a97.88af4"]]},{"id":"18fade6d.1843ca","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":2,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4310,"wires":[["53a404d1.59f7ac"]]},{"id":"53a404d1.59f7ac","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\");\nif (pass == \"0\")\n{\n    msg.payload = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4350,"wires":[["a09a4ef7.31482"]]},{"id":"b48a1d99.b29fd","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":2900,"y":4390,"wires":[["fb40c7a6.d7dad8"]]},{"id":"66a86c89.e1e4ec","type":"debug","z":"b9924a74.4d98f8","name":"A","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3040,"y":4450,"wires":[]},{"id":"7bd08973.eb2448","type":"change","z":"b9924a74.4d98f8","name":"Part 1","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert1","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert1name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4270,"wires":[["ab5f6391.6954e","62d220a6.a4221"]]},{"id":"8031996.9decb68","type":"change","z":"b9924a74.4d98f8","name":"Part 3","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert3","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert3name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4440,"wires":[["1ea9bfea.581898","e00dd3af.7301b8"]]},{"id":"f57f3a97.88af4","type":"change","z":"b9924a74.4d98f8","name":"Part 4","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert4","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert4name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4510,"wires":[["4c693616.cd16e8","e9ca2eef.807678"]]},{"id":"a09a4ef7.31482","type":"debug","z":"b9924a74.4d98f8","name":"2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4350,"wires":[]},{"id":"ab5f6391.6954e","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\");\nif (pass == \"0\")\n{\n    msg.payload = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4270,"wires":[["8bd9edd3.295188"]]},{"id":"62d220a6.a4221","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":1,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4220,"wires":[["ab5f6391.6954e","befe2625.a9c3"]]},{"id":"1ea9bfea.581898","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":3,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4400,"wires":[["e00dd3af.7301b8"]]},{"id":"e00dd3af.7301b8","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\");\nif (pass == \"0\")\n{\n    msg.payload = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4440,"wires":[["e9ba57cb.35bdc"]]},{"id":"4c693616.cd16e8","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":4,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4480,"wires":[["e9ca2eef.807678"]]},{"id":"e9ca2eef.807678","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\");\nif (pass == \"0\")\n{\n    msg.payload = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4510,"wires":[["cd17cd34.a3fe7"]]},{"id":"8bd9edd3.295188","type":"debug","z":"b9924a74.4d98f8","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4270,"wires":[]},{"id":"befe2625.a9c3","type":"debug","z":"b9924a74.4d98f8","name":"From switch","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3580,"y":4220,"wires":[]},{"id":"e9ba57cb.35bdc","type":"debug","z":"b9924a74.4d98f8","name":"3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4440,"wires":[]},{"id":"cd17cd34.a3fe7","type":"debug","z":"b9924a74.4d98f8","name":"4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4510,"wires":[]},{"id":"db4d9de.f7f246","type":"ui_group","name":"Group 3","tab":"260a696.4ccbf96","order":3,"disp":true,"width":6},{"id":"260a696.4ccbf96","type":"ui_tab","z":"","name":"W16-Chart","icon":"dashboard","order":11,"disabled":false,"hidden":false}]

It is a bit of a hack, but with the switches set to ON of OFF the allow or block the message going through.

If it is OFF, the value sent is 0. You can easily make it not send anything by changing the line that sets the msg.payload = "0"; to simply return;

EDITED GET NEW FLOW!

If we can get rid of the template at this point and brake the message to parts, i will take it a shot.

i used global because i am lazy. i can reach globals from anywhere, so i used it.

the Messages arriving every 1.2 seconds. i plan to Change that dynamicly for the Chart to 0.5s but thats for later :slight_smile:

i will try the flow tomorrow, for today my work is done :slight_smile:

thank you for your help!
i try to learn from that :slight_smile:

You are really REALLY going to need a fast machine.

That is a lot of number crunching!

And display work!

I goofed with the first post of the code. I edited it and added the alert.

I hope that does what you want.

I am at my knowledge's limits with what you are wanting to do.

This is (yet) another flow.

Slight modification to the other one.

This one has two different ways of showing the output.
The 1, 2, 3 and 4 outputs are the bigger message. Not really useful/needed on the chart node.
The a, b, c and d outputs are just the payload. The topic is shown too.

Any blocked parts get a 0 and so you can use a join node and tell it to wait for 4 messages then send the message to the chart. That is in keeping with what you did before.

You may not need to do that. I don't know.

But here is the slightly better flow:

[{"id":"fb40c7a6.d7dad8","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":3060,"y":4390,"wires":[["66a86c89.e1e4ec","7bd08973.eb2448","49798152.e859d8","8031996.9decb68","f57f3a97.88af4"]]},{"id":"b48a1d99.b29fd","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":2900,"y":4390,"wires":[["fb40c7a6.d7dad8"]]},{"id":"66a86c89.e1e4ec","type":"debug","z":"b9924a74.4d98f8","name":"A","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3040,"y":4450,"wires":[]},{"id":"7bd08973.eb2448","type":"change","z":"b9924a74.4d98f8","name":"Part 1","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert1","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert1name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4270,"wires":[["ab5f6391.6954e","62d220a6.a4221"]]},{"id":"49798152.e859d8","type":"change","z":"b9924a74.4d98f8","name":"Part 2","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert2","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert2name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4350,"wires":[["18fade6d.1843ca","53a404d1.59f7ac"]]},{"id":"8031996.9decb68","type":"change","z":"b9924a74.4d98f8","name":"Part 3","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert3","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert3name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4440,"wires":[["1ea9bfea.581898","e00dd3af.7301b8"]]},{"id":"f57f3a97.88af4","type":"change","z":"b9924a74.4d98f8","name":"Part 4","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert4","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert4name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4510,"wires":[["4c693616.cd16e8","e9ca2eef.807678"]]},{"id":"ab5f6391.6954e","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\");\nif (pass == \"0\")\n{\n    msg.payload = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4270,"wires":[["8bd9edd3.295188","d02fe110.72f05"]]},{"id":"62d220a6.a4221","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":1,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4220,"wires":[["ab5f6391.6954e","befe2625.a9c3"]]},{"id":"18fade6d.1843ca","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":2,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4310,"wires":[["53a404d1.59f7ac"]]},{"id":"53a404d1.59f7ac","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\");\nif (pass == \"0\")\n{\n    msg.payload = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4350,"wires":[["a09a4ef7.31482","c4c729e8.12af9"]]},{"id":"1ea9bfea.581898","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":3,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4400,"wires":[["e00dd3af.7301b8"]]},{"id":"e00dd3af.7301b8","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\");\nif (pass == \"0\")\n{\n    msg.payload = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4440,"wires":[["e9ba57cb.35bdc","d3502d2e.8ed888"]]},{"id":"4c693616.cd16e8","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":4,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4480,"wires":[["e9ca2eef.807678"]]},{"id":"e9ca2eef.807678","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\");\nif (pass == \"0\")\n{\n    msg.payload = 0;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4510,"wires":[["cd17cd34.a3fe7","f313a56e.f0b4d8"]]},{"id":"8bd9edd3.295188","type":"debug","z":"b9924a74.4d98f8","name":"1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4270,"wires":[]},{"id":"d02fe110.72f05","type":"debug","z":"b9924a74.4d98f8","name":"a","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":3690,"y":4300,"wires":[]},{"id":"befe2625.a9c3","type":"debug","z":"b9924a74.4d98f8","name":"From switch","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3580,"y":4220,"wires":[]},{"id":"a09a4ef7.31482","type":"debug","z":"b9924a74.4d98f8","name":"2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4350,"wires":[]},{"id":"c4c729e8.12af9","type":"debug","z":"b9924a74.4d98f8","name":"b","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":3690,"y":4380,"wires":[]},{"id":"e9ba57cb.35bdc","type":"debug","z":"b9924a74.4d98f8","name":"3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4440,"wires":[]},{"id":"d3502d2e.8ed888","type":"debug","z":"b9924a74.4d98f8","name":"c","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":3690,"y":4470,"wires":[]},{"id":"cd17cd34.a3fe7","type":"debug","z":"b9924a74.4d98f8","name":"4","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4510,"wires":[]},{"id":"f313a56e.f0b4d8","type":"debug","z":"b9924a74.4d98f8","name":"d","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":3690,"y":4540,"wires":[]},{"id":"db4d9de.f7f246","type":"ui_group","name":"Group 3","tab":"260a696.4ccbf96","order":3,"disp":true,"width":6},{"id":"260a696.4ccbf96","type":"ui_tab","z":"","name":"W16-Chart","icon":"dashboard","order":11,"disabled":false,"hidden":false}]

Screenshot from 2020-07-16 22-51-07

Again, I am only dipping into the thread and so may not be saying relevant things, but do you mean that you want to send the switch a message but do not want it to pass the message on? If so then clear the Pass Through checkbox, then it will never pass anything on and will only send a message when you click it.

Ah.

Ok.

In that flow I posted. In each function node change the code from:

//  Look for message from `switch`
//  and set context.

if (msg.payload == "true")
{
    context.set("ONOFF","1");
    node.status({fill:"green",shape:"dot",text:"PASS"});
    return;
} else
if (msg.payload == "false")
{
    context.set("ONOFF","0");
    node.status({fill:"red",shape:"dot",text:"BLOCK"});
    return;
}
var pass = context.get("ONOFF");
if (pass == "0")
{
    msg.payload = 0;
}

return msg;

Where it says: msg.payload = 0;

Replace it with:

return;

That should get the desired result I hope.

I tweaked the flow a bit more.

NOTE

You MUST turn the switches to the on position, or the messages will be blocked by default.

The names will only appear after a message is received - of course.

[{"id":"fb40c7a6.d7dad8","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":3060,"y":4390,"wires":[["66a86c89.e1e4ec","7bd08973.eb2448","49798152.e859d8","8031996.9decb68","f57f3a97.88af4"]]},{"id":"b48a1d99.b29fd","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":2900,"y":4390,"wires":[["fb40c7a6.d7dad8"]]},{"id":"66a86c89.e1e4ec","type":"debug","z":"b9924a74.4d98f8","name":"A","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3040,"y":4450,"wires":[]},{"id":"7bd08973.eb2448","type":"change","z":"b9924a74.4d98f8","name":"Part 1","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert1","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert1name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4270,"wires":[["ab5f6391.6954e","62d220a6.a4221"]]},{"id":"49798152.e859d8","type":"change","z":"b9924a74.4d98f8","name":"Part 2","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert2","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert2name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4350,"wires":[["18fade6d.1843ca","53a404d1.59f7ac"]]},{"id":"8031996.9decb68","type":"change","z":"b9924a74.4d98f8","name":"Part 3","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert3","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert3name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4440,"wires":[["1ea9bfea.581898","e00dd3af.7301b8"]]},{"id":"f57f3a97.88af4","type":"change","z":"b9924a74.4d98f8","name":"Part 4","rules":[{"t":"set","p":"value","pt":"msg","to":"payload.MQTTWert4","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"payload.MQTTWert4name","tot":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"move","p":"value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3230,"y":4510,"wires":[["4c693616.cd16e8","e9ca2eef.807678"]]},{"id":"ab5f6391.6954e","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\") || 0;\nif (pass == \"0\")\n{\n    //msg.payload = 0;\n    return;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4270,"wires":[["8bd9edd3.295188","d02fe110.72f05"]]},{"id":"62d220a6.a4221","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":1,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4220,"wires":[["ab5f6391.6954e","befe2625.a9c3"]]},{"id":"18fade6d.1843ca","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":2,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4310,"wires":[["53a404d1.59f7ac"]]},{"id":"53a404d1.59f7ac","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\") || 0;\nif (pass == \"0\")\n{\n    //msg.payload = 0;\n    return;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4350,"wires":[["a09a4ef7.31482","c4c729e8.12af9"]]},{"id":"1ea9bfea.581898","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":3,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4400,"wires":[["e00dd3af.7301b8"]]},{"id":"e00dd3af.7301b8","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\") || 0;\nif (pass == \"0\")\n{\n    //msg.payload = 0;\n    return;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4440,"wires":[["e9ba57cb.35bdc","d3502d2e.8ed888"]]},{"id":"4c693616.cd16e8","type":"ui_switch","z":"b9924a74.4d98f8","name":"","label":"{{msg.topic}}","tooltip":"","group":"db4d9de.f7f246","order":4,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3360,"y":4480,"wires":[["e9ca2eef.807678"]]},{"id":"e9ca2eef.807678","type":"function","z":"b9924a74.4d98f8","name":"","func":"//  Look for message from `switch`\n//  and set context.\n\nif (msg.payload == \"true\")\n{\n    context.set(\"ONOFF\",\"1\");\n    node.status({fill:\"green\",shape:\"dot\",text:\"PASS\"});\n    return;\n} else\nif (msg.payload == \"false\")\n{\n    context.set(\"ONOFF\",\"0\");\n    node.status({fill:\"red\",shape:\"dot\",text:\"BLOCK\"});\n    return;\n}\nvar pass = context.get(\"ONOFF\") || 0;\nif (pass == \"0\")\n{\n    //msg.payload = 0;\n    return;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":3560,"y":4510,"wires":[["cd17cd34.a3fe7","f313a56e.f0b4d8"]]},{"id":"8bd9edd3.295188","type":"debug","z":"b9924a74.4d98f8","name":"1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4270,"wires":[]},{"id":"d02fe110.72f05","type":"debug","z":"b9924a74.4d98f8","name":"a","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":3690,"y":4300,"wires":[]},{"id":"befe2625.a9c3","type":"debug","z":"b9924a74.4d98f8","name":"From switch","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3580,"y":4220,"wires":[]},{"id":"a09a4ef7.31482","type":"debug","z":"b9924a74.4d98f8","name":"2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4350,"wires":[]},{"id":"c4c729e8.12af9","type":"debug","z":"b9924a74.4d98f8","name":"b","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":3690,"y":4380,"wires":[]},{"id":"e9ba57cb.35bdc","type":"debug","z":"b9924a74.4d98f8","name":"3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4440,"wires":[]},{"id":"d3502d2e.8ed888","type":"debug","z":"b9924a74.4d98f8","name":"c","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":3690,"y":4470,"wires":[]},{"id":"cd17cd34.a3fe7","type":"debug","z":"b9924a74.4d98f8","name":"4","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":3690,"y":4510,"wires":[]},{"id":"f313a56e.f0b4d8","type":"debug","z":"b9924a74.4d98f8","name":"d","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":3690,"y":4540,"wires":[]},{"id":"db4d9de.f7f246","type":"ui_group","name":"Group 3","tab":"260a696.4ccbf96","order":3,"disp":true,"width":6},{"id":"260a696.4ccbf96","type":"ui_tab","z":"","name":"W16-Chart","icon":"dashboard","order":11,"disabled":false,"hidden":false}]

Good Morning!

Thank you for your time and help!

I will start working down your posts now.

Colin: even if i didnt have any line after the switch the problem stays. That checkbox didnt help(development state yesterday).

So, i tested the latest flow.
it worked fine but the one thing i experience in my flows.
after one payload the switch is set to off...
and after that, the value keeps coming, while switch is off.

Sooo,

i found something in an other thread.
i changed my build to this and it seems to work:

[{"id":"e9b9dd78.e10f1","type":"ui_switch","z":"af61c022.bc96e","name":"","label":"{{msg.payload.MQTTWert1name}}","tooltip":"","group":"22029319.b38d4c","order":1,"width":"3","height":"1","passthru":false,"decouple":"false","topic":"ATESTEO/Wolfsburg/W16","style":"","onvalue":"true","onvalueType":"str","onicon":"","oncolor":"","offvalue":"false","offvalueType":"str","officon":"","offcolor":"","x":3800,"y":2310,"wires":[["fef7d669.96ce98","2c2043b2.4cb60c"]]},{"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":4000,"y":2310,"wires":[[]]},{"id":"80fe1189.5a0ff","type":"change","z":"af61c022.bc96e","name":"","rules":[{"t":"delete","p":"payload.MQTTWert1","pt":"msg"},{"t":"delete","p":"payload.MQTTWert2","pt":"msg"},{"t":"delete","p":"payload.MQTTWert3","pt":"msg"},{"t":"delete","p":"payload.MQTTWert4","pt":"msg"},{"t":"delete","p":"payload.Status","pt":"msg"},{"t":"delete","p":"payload.MQTTWert2name","pt":"msg"},{"t":"delete","p":"payload.MQTTWert3name","pt":"msg"},{"t":"delete","p":"payload.MQTTWert4name","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":3560,"y":2310,"wires":[["e9b9dd78.e10f1"]]},{"id":"2c2043b2.4cb60c","type":"trigger","z":"af61c022.bc96e","op1":"true","op2":"off","op1type":"str","op2type":"str","duration":"0","extend":true,"units":"s","reset":"false","bytopic":"all","name":"","x":3810,"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}]

For the rate of the MQTT Messages - wich machine has to be strong, the one that sends or the one that Displays or the Broker ? Perhaps i want to much...

Strange. It works here.

As I showed in the screen shot.

Subsequent injections get the same messages blocked and the same passed.

Show me a screen shot of the flow where it is still lets the value passed when the switch is off.
Please.

I will now look at your latest flow/code.