Sequence of output function

Hello
I have been looking for a mistake in my flow for quite some time. After a time of searching I have found a point which seems to be the error.
I trigger a switch from 2 different sources. One function works, the other not. If I set an inject and send payload "on" then it also works.
In debug you can see the only difference. It the sequence of the objects.
Can this be the reason?. I have long failed to notice this.

5.11.2020, 11:18:53node: test injectmsg : Object
object
_msgid: "73287724.150c58"
payload: "on"

5.11.2020, 11:18:55node: function switchmsg : Object
object
payload: "on"
_msgid: "9db07e28.d048d"

Can this be the reason? :thinking:
If YES, how does such a rotation happen and how can you turn something like this back

at the javascript level they are the same - as there is no defined ordering of an object. If you are manipulating it in a manner that does need a specific order (eg turning into a string and then splitting it (who knows why :slight_smile: - then yes order would matter. But no - javascript doesn't care.

Is that a ui_switch?
What else is in the failing message?
What is supposed to happen and what does happen?
Show us the config of the switch.
Are there any other wires going into the switch that might have messages in them?

Hello

Is that a ui_switch?
yes it is a ui_switch.

What else is in the failing message?
no error message only no action from switch

What is supposed to happen and what does happen?
the switch should accept the sent status on or off

Show us the config of the switch.
Picture of the switch configuration

Are there any other wires going into the switch that might have messages in them?
no there are only 2 functions into the switch. their output in debug fixed I have shown above.
One funktion works, over the daschboard I can togel the switch, only the one function, where the output looks "twisted" does not work.

switch

Sorry, I meant what else is in the message you are passing to the node from the function. Set the debug node to Show Full message and fully expand any contents.

Which versions of node-red (see the bottom of the hamburger menu dropdown) and node-red-dashboard (see Manage Palette) are you using? Upgrade to the latest of each unless you have a good reason not to. If it still doesn't work then construct a short flow consisting of your function node (or a simplified version of it) an Inject node to trigger the function (or two, one on, one off), and a ui_switch node so we can try to replicate the problem with your config. Then Export those nodes and paste them here (use the </> at the top of the forum entry window when pasting it in).

Starting wit the easy on
Node Red Version 1.2.2 and Dashboard 2.23.4
As shown in the picture i have already built a test inject. it only sends on or off and it works.
The debug is identical to the debug of the working function.

Set the debug node to Show Full message and fully expand any contents.
Here I don't know exactly what you mean. Unfortunately I use the German version and have set the check marks there like in the picture
switch3

Thats all what I get out of the debug
5.11.2020, 11:18:53node: test injectmsg : Object
object
_msgid: "73287724.150c58"
payload: "on"

5.11.2020, 11:18:55node: function switchmsg : Object
object
payload: "on"
_msgid: "9db07e28.d048d"

That isn't what I meant, what we need is to be able to replicate your problem, so we need a version of your function node feeding a switch, that we can import and see if we can replicate it. So you need your function node to be triggered by inject nodes in order to test it.

This is the funktion where the output looks "twisted" does not work.

[{"id":"db1c3b14.877d98","type":"function","z":"88aeead.6736f18","name":"","func":"var msg1 =[];\nvar msg2 =[];\n\nif (msg.payload[0].MO ==\"1\"){\n    MO=\"on\";\n    }\n    else{\n    MO=\"off\";\n    }\nif (msg.payload[0].DI ==\"1\"){\n    DI=\"on\";\n    }\n    else{\n    DI=\"off\";\n    }\nif (msg.payload[0].MI ===\"1\"){\n    MI=\"on\";\n    }\n    else{\n    MI=\"off\";\n    }    \nif (msg.payload[0].DO ===\"1\"){\n    DO=\"on\";\n    }\n    else{\n    DO=\"off\";\n    }    \nif (msg.payload[0].FR ===\"1\"){\n    FR=\"on\";\n    }\n    else{\n    FR=\"off\";\n    }    \nif (msg.payload[0].SO ===\"1\"){\n    SO=\"on\";\n    }\n    else{\n    SO=\"off\";\n    }   \n if (msg.payload[0].SA ===\"1\"){\n    SA=\"on\";\n    }\n    else{\n    SA=\"off\";\n    }   \n\nvar SRoff={\"SRoff\":msg.payload[0].SRoff};\nvar SRon={\"SRon\":msg.payload[0].SRon};\nvar SSoff={\"SSoff\":msg.payload[0].SSoff};\nvar SSon={\"SSon\":msg.payload[0].SSon};\nvar Toff={\"Toff\":msg.payload[0].Toff};\nvar Ton={\"Ton\":msg.payload[0].Ton};\nvar ZToff={\"ZToff\":msg.payload[0].ZToff};\nvar ZTon={\"ZTon\":msg.payload[0].ZTon};\nvar Z_Toff={\"Z_Toff\":msg.payload[0].Z_Toff};\nvar Z_Ton={\"Z_Ton\":msg.payload[0].Z_Ton};\nvar Ausgang={\"Ausgang\":msg.payload[0].Ausgang};\nvar Auto={\"Auto\":msg.payload[0].Auto};\nmsg2.push(MO,DI,MI,DO,FR,SA,SO,SRoff,SRon,SSoff,SSon,Toff,Ton,ZToff,ZTon,Z_Toff,Z_Ton,Ausgang,Auto);\nmsg.payload=msg2;\nfor(var a in msg.payload){\nmsg1.push([{\"payload\":msg.payload[a]}])  \nmsg1.topic=\"\";\n    \n}\n\n\nreturn msg1;\n\n","outputs":19,"noerr":0,"initialize":"","finalize":"","x":550,"y":1660,"wires":[["a0195dd6.060d4"],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]]}]

and I read and inkjeted from an existing Maria DB to function (no chance to do changes at DB, written by different program :frowning:)

topic: "SELECT * FROM Timer1 ORDER BY TIMESTAMP DESC LIMIT 1" 5.11.2020, 20:22:15node: bd410f46.2525dSELECT * FROM Timer1 ORDER BY TIMESTAMP DESC LIMIT 1 : msg : Object
object
_msgid: "54726b25.34f1b4"
payload: array[1]
0: object
TIMESTAMP: "2020-11-04T16:23:11.000Z"
MO: 1
DI: 1
MI: 0
DO: 1
FR: 0
SA: 1
SO: 0
SRoff: 0
SRon: 0
SSoff: 1
SSon: 1
Toff: 0
Ton: 0
Auto: 1
Ausgang: 0
ZToff: "1604271600000"
ZTon: "0"
Z_Toff: "18:00"
Z_Ton: "08:00"
topic: "SELECT * FROM Timer1 ORDER BY TIMESTAMP DESC LIMIT 1"

What we need is a flow we can import and test, so you can do something like stimulating your normal input to the function with an inject node.

Hello
I assembled and tested the required one in a separate flow. Everything worked. :open_mouth:
Then I copied the database query and it still worked.
When I copied everything over, the function was still ok. :face_vomiting:
In one flow it does not work in the other yes.
Thank you guys for your support.
I delete the "broken" flow and try to make up for the time lost due to the ghost error.