Combined two data

hello, guys.
First of all, I'm sorry to use a translator.
I try to adjust the brightness using two data.

3 conditional statement

sensor <= 40 & light == 250 >>> bright dimming x<=250; x++
40 < sensor <= 80 & light == 50 >>> bright dimming x>=50; x--
80 < sensor <= 100 & light == 250 >>> bright dimming x<=250; x++

*This is my flow.
I don't understand, what did I write wrong?
Give me the head...

[{"id":"1f5cbe5.f3d8642","type":"function","z":"4bda1f34.e05f3","name":"bright","func":"global.set(\"bright\",msg.payload)\nreturn msg;","outputs":1,"noerr":0,"x":950,"y":520,"wires":[["844154b6.6bb068"]]},{"id":"527cebd8.65f094","type":"join","z":"4bda1f34.e05f3","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":510,"y":260,"wires":[["9378eab3.91ba58"]]},{"id":"9378eab3.91ba58","type":"function","z":"4bda1f34.e05f3","name":"Average","func":"x = msg.payload[0];\n//node.warn(x);\nx = x + msg.payload[1];\n//node.warn(x);\nx = x + msg.payload[2];\n//node.warn(x);\nx = x + msg.payload[3];\n//node.warn(x);\nx = x + msg.payload[4];\n//node.warn(x);\nx = x + msg.payload[5];\n//node.warn(x);\n\n\nx = x / 6;\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":260,"wires":[["72416a82.304674"]]},{"id":"e8625fc7.3038","type":"ui_text","z":"4bda1f34.e05f3","group":"bf3e38c0.e29328","order":2,"width":0,"height":0,"name":"","label":"bright","format":"{{msg.payload}}","layout":"row-spread","x":950,"y":560,"wires":[]},{"id":"c2c5a773.fb99b8","type":"ui_slider","z":"4bda1f34.e05f3","name":"","label":"bright","tooltip":"","group":"bf3e38c0.e29328","order":1,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"255","step":1,"x":710,"y":520,"wires":[["1f5cbe5.f3d8642","e8625fc7.3038"]]},{"id":"ac14e41.c285d18","type":"function","z":"4bda1f34.e05f3","name":"dimming ++","func":"s = msg.payload\nfor(var x=s;x<=250;x++)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":530,"y":360,"wires":[["f9d9c192.dd6a4"]]},{"id":"d689643d.4548a8","type":"function","z":"4bda1f34.e05f3","name":"dimming ++","func":"s = msg.payload\nfor(var x=s;x<=250;x++)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":530,"y":440,"wires":[["f9d9c192.dd6a4"]]},{"id":"6fb4f968.89c518","type":"function","z":"4bda1f34.e05f3","name":"dimming --","func":"s = msg.payload\nfor(var x=s;x>=50;x--)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":530,"y":400,"wires":[["f9d9c192.dd6a4"]]},{"id":"9332fd86.f4f0b","type":"change","z":"4bda1f34.e05f3","name":"","rules":[{"t":"move","p":"bright","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":460,"wires":[["c2c5a773.fb99b8","a7491eca.6da73"]]},{"id":"646d9191.d5a0f","type":"function","z":"4bda1f34.e05f3","name":"80 < sensor <= 100 & light == 250","func":"if (msg.payload.sensor > 80 && msg.payload.sensor <= 100 && msg.payload.light == 250)\n{\n    msg.payload = 50;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":280,"y":440,"wires":[["d689643d.4548a8"]]},{"id":"55efdb46.0ba9e4","type":"function","z":"4bda1f34.e05f3","name":"40 < sensor <= 80 & light == 50","func":"if (msg.payload.sensor > 40 && msg.payload.sensor <= 80 && msg.payload.light == 50)\n{\n    msg.payload = 250;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":400,"wires":[["6fb4f968.89c518"]]},{"id":"55b862c9.1ea92c","type":"function","z":"4bda1f34.e05f3","name":"sensor <= 40 & light == 250","func":"if(msg.payload.sensor <= 40 && msg.payload.light == 250)\n{\n    msg.payload = 50;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":360,"wires":[["ac14e41.c285d18"]]},{"id":"a7491eca.6da73","type":"debug","z":"4bda1f34.e05f3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":970,"y":460,"wires":[]},{"id":"f9d9c192.dd6a4","type":"delay","z":"4bda1f34.e05f3","name":"","pauseType":"rate","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":730,"y":400,"wires":[["9332fd86.f4f0b","9e679982.506bb8"]]},{"id":"9e679982.506bb8","type":"debug","z":"4bda1f34.e05f3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":400,"wires":[]},{"id":"acf7a996.e68d48","type":"inject","z":"4bda1f34.e05f3","name":"","topic":"test sensor","payload":"30","payloadType":"num","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":260,"wires":[["527cebd8.65f094"]]},{"id":"72416a82.304674","type":"change","z":"4bda1f34.e05f3","name":"","rules":[{"t":"set","p":"sensor","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":980,"y":260,"wires":[["d8583044.9e958","6839d384.24facc"]]},{"id":"844154b6.6bb068","type":"change","z":"4bda1f34.e05f3","name":"","rules":[{"t":"set","p":"light","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":520,"wires":[["989c9183.4ce5a","6839d384.24facc"]]},{"id":"6839d384.24facc","type":"link out","z":"4bda1f34.e05f3","name":"","links":["52f56b5b.01fd04","8ae48160.c5651","31f80fd4.a11b7"],"x":1415,"y":260,"wires":[]},{"id":"52f56b5b.01fd04","type":"link in","z":"4bda1f34.e05f3","name":"","links":["6839d384.24facc"],"x":95,"y":360,"wires":[["55b862c9.1ea92c"]]},{"id":"8ae48160.c5651","type":"link in","z":"4bda1f34.e05f3","name":"","links":["6839d384.24facc"],"x":95,"y":400,"wires":[["55efdb46.0ba9e4"]]},{"id":"31f80fd4.a11b7","type":"link in","z":"4bda1f34.e05f3","name":"","links":["6839d384.24facc"],"x":95,"y":440,"wires":[["646d9191.d5a0f"]]},{"id":"681673a6.ad2aac","type":"debug","z":"4bda1f34.e05f3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1310,"y":200,"wires":[]},{"id":"989c9183.4ce5a","type":"debug","z":"4bda1f34.e05f3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1310,"y":520,"wires":[]},{"id":"fef6f81c.f9cdb8","type":"inject","z":"4bda1f34.e05f3","name":"","topic":"test","payload":"250","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":540,"y":520,"wires":[["c2c5a773.fb99b8"]]},{"id":"d8583044.9e958","type":"debug","z":"4bda1f34.e05f3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":970,"y":200,"wires":[]},{"id":"28d6686f.97ea88","type":"mqtt in","z":"4bda1f34.e05f3","name":"","topic":"OUTTOPIC","qos":"0","datatype":"auto","broker":"84206044.372d9","x":960,"y":620,"wires":[["1660b314.e403ed"]]},{"id":"b74ba6cc.7ea168","type":"mqtt out","z":"4bda1f34.e05f3","name":"","topic":"OUTTOPIC","qos":"","retain":"","broker":"84206044.372d9","x":1170,"y":740,"wires":[]},{"id":"1660b314.e403ed","type":"debug","z":"4bda1f34.e05f3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1170,"y":620,"wires":[]},{"id":"a6fdc410.0604b8","type":"function","z":"4bda1f34.e05f3","name":"get bright","func":"var bright = global.get(\"bright\")||0;\nmsg.payload.bright = bright;\nreturn msg;","outputs":1,"noerr":0,"x":960,"y":740,"wires":[["b74ba6cc.7ea168","ab0ffa37.7a9a98"]]},{"id":"ab0ffa37.7a9a98","type":"debug","z":"4bda1f34.e05f3","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1170,"y":680,"wires":[]},{"id":"b7cea974.c15488","type":"inject","z":"4bda1f34.e05f3","name":"","topic":"","payload":"{\"r\":\"250\",\"g\":\"250\",\"b\":\"250\",\"a\":\"1\"}","payloadType":"json","repeat":"0.1","crontab":"","once":false,"onceDelay":0.1,"x":970,"y":680,"wires":[["a6fdc410.0604b8"]]},{"id":"bf3e38c0.e29328","type":"ui_group","z":"","name":"LED","tab":"7cc68490.34bccc","order":1,"disp":true,"width":"6","collapse":false},{"id":"84206044.372d9","type":"mqtt-broker","z":"","name":"Broker","broker":"http://www.mqtt-dashboard.com/","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"7cc68490.34bccc","type":"ui_tab","z":"","name":"Broker","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

You have a problem because you are trying to compare things from two different messages.

Alas this doesn't work.

You need to join them so they become one message.

I will have a look at what is going on and see if I can get things working quickly for you.

Oh and in the change node, it may have been better to move rather than set. But I'll work around that.

Right, (rolls up sleeves) this is going to be fun.

Things you really need to learn:
1 - when you put debug nodes everywhere Name them! It is pointless seeing data flying past you and not knowing from where it is coming.
2 - Learn how to use the debug node. Simply putting it everywhere is pointless if it isn't going to show you anything. It only increases your frustration because you aren't seeing anything when you are expecting to.
3 - how the msg is structured. msg.payload is but the start. Using the change node doesn't append the name to msg.payload You are typing the entire name after the msg. part.

Now, to the code/flow:
1 - you need to learn how to structure conditions.
if(msg.payload.sensor <= 40 && msg.payload.light == 250) is wrong.
2 - you seem to have three variables: (I'll call them a,b,c for clarity)
a - sensor
b - light
c - bright
looking at the code bright and light are the same.
3 - what is this supposed to do:

[{"id":"84cbf7ff.03aee8","type":"mqtt in","z":"b9924a74.4d98f8","name":"","topic":"OUTTOPIC","qos":"0","datatype":"auto","broker":"c556ac10.5b1a9","x":1070,"y":3150,"wires":[["b0dcb49d.143a3"]]},{"id":"3bc8f3f7.015194","type":"mqtt out","z":"b9924a74.4d98f8","name":"","topic":"OUTTOPIC","qos":"","retain":"","broker":"c556ac10.5b1a9","x":1280,"y":3260,"wires":[]},{"id":"b0dcb49d.143a3","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1280,"y":3150,"wires":[]},{"id":"cb40442.e5308b8","type":"function","z":"b9924a74.4d98f8","name":"get bright","func":"var bright = global.get(\"bright\")||0;\nmsg.payload.bright = bright;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":3260,"wires":[["3bc8f3f7.015194","8eadbaff.612e"]]},{"id":"8eadbaff.612e","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1280,"y":3200,"wires":[]},{"id":"a0689393.0da3b","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"{\"r\":\"250\",\"g\":\"250\",\"b\":\"250\",\"a\":\"1\"}","payloadType":"json","repeat":"0.1","crontab":"","once":false,"onceDelay":0.1,"x":1080,"y":3200,"wires":[["cb40442.e5308b8"]]},{"id":"c556ac10.5b1a9","type":"mqtt-broker","z":"","name":"Broker","broker":"http://www.mqtt-dashboard.com/","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Something which I can't answer:
The inject which injects 255 into the bright slider....
The message isn't/wasn't getting through so it didn't really do much.
I moved it to the other side and the flow started to work (go crazy actually).

You also aren't helping yourself with how you are dimming the value.
In one part of the code (where it goes in) it is called light then it becomes the standard payload and then it gets renamed to being bright and a couple of nodes later it is called light.

You are also setting a global context which I can't see used anywhere in the flow.
Granted it maybe for other things. But using global........ Unless it needs to be global keep it as flow.
(Remember, I have to go through later and clean up all this mess on my machine too.)

Here is my effort at tidying up what you wrote.

I had to change a lot of nodes and names.

study now names work and how the change node does things.
set is/can be dangerous because you keep the original value in the original part of the message. This can bite you and cause confusion.

study how to do conditions like the && when testing for multiple things matching.

So the code:

[{"id":"d96323ce.7d474","type":"function","z":"b9924a74.4d98f8","name":"bright","func":"global.set(\"bright\",msg.payload)\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":3310,"wires":[["7bcdc2cc.8361fc","551e020e.637c2c"]]},{"id":"a8f50e3.26444f","type":"join","z":"b9924a74.4d98f8","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":420,"y":2820,"wires":[["4a0ca290.64a7cc"]]},{"id":"4a0ca290.64a7cc","type":"function","z":"b9924a74.4d98f8","name":"Average","func":"x = msg.payload[0];\n//node.warn(x);\nx = x + msg.payload[1];\n//node.warn(x);\nx = x + msg.payload[2];\n//node.warn(x);\nx = x + msg.payload[3];\n//node.warn(x);\nx = x + msg.payload[4];\n//node.warn(x);\nx = x + msg.payload[5];\n//node.warn(x);\n\n\nx = x / 6;\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":2820,"wires":[["16fd49e3.931d96"]]},{"id":"ec0a453e.e29d78","type":"ui_text","z":"b9924a74.4d98f8","group":"5f171e98.6f1718","order":2,"width":0,"height":0,"name":"","label":"bright","format":"{{msg.payload}}","layout":"row-spread","x":500,"y":3350,"wires":[]},{"id":"e6ade3ec.3677f8","type":"ui_slider","z":"b9924a74.4d98f8","name":"","label":"bright","tooltip":"","group":"5f171e98.6f1718","order":1,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"255","step":1,"x":260,"y":3310,"wires":[["d96323ce.7d474","ec0a453e.e29d78","a687fd2b.52cdf"]]},{"id":"a041821b.4ff5d8","type":"function","z":"b9924a74.4d98f8","name":"dimming ++","func":"s = msg.payload\nfor(var x=s;x<=250;x++)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":558,"y":2986,"wires":[["5e562e2d.03bad"]]},{"id":"c249cd43.36d5d8","type":"function","z":"b9924a74.4d98f8","name":"dimming ++","func":"s = msg.payload\nfor(var x=s;x<=250;x++)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":558,"y":3126,"wires":[["5e562e2d.03bad"]]},{"id":"8e796149.bd8528","type":"function","z":"b9924a74.4d98f8","name":"dimming --","func":"s = msg.payload\nfor(var x=s;x>=50;x--)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":558,"y":3056,"wires":[["5e562e2d.03bad"]]},{"id":"2ccf3bf0.671154","type":"change","z":"b9924a74.4d98f8","name":"","rules":[{"t":"move","p":"bright","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":3200,"wires":[["e6ade3ec.3677f8","fce2b503.6c6b5"]]},{"id":"beef2d66.26236","type":"function","z":"b9924a74.4d98f8","name":"80 < sensor <= 100 & light == 250","func":"if ((msg.sensor > 80) && (msg.sensor <= 100) && (msg.payload.light == 250))\n{\n    msg.payload = 50;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":308,"y":3126,"wires":[["c249cd43.36d5d8","396471a3.5b90b6"]]},{"id":"9bf033ee.252b18","type":"function","z":"b9924a74.4d98f8","name":"40 < sensor <= 80 & light == 50","func":"if ((msg.sensor > 40) && (msg.sensor <= 80) && (msg.light == 50))\n{\n    msg.payload = 250;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":298,"y":3056,"wires":[["8e796149.bd8528","3ef0a7c1.4b7898"]]},{"id":"90b50622.49a88","type":"function","z":"b9924a74.4d98f8","name":"sensor <= 40 & light == 250","func":"if((msg.sensor <= 40) && (msg.light == 250))\n{\n    msg.payload = 50;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":288,"y":2986,"wires":[["a041821b.4ff5d8","1e55c7d0.020e8"]]},{"id":"fce2b503.6c6b5","type":"debug","z":"b9924a74.4d98f8","name":"WTF?","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":500,"y":3200,"wires":[]},{"id":"5e562e2d.03bad","type":"delay","z":"b9924a74.4d98f8","name":"","pauseType":"rate","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":798,"y":3056,"wires":[["2ccf3bf0.671154","e0967fb1.803c08"]]},{"id":"e0967fb1.803c08","type":"debug","z":"b9924a74.4d98f8","name":"Dimming?","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1020,"y":3057,"wires":[]},{"id":"b018e5d8.599de8","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"test sensor","payload":"30","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":2820,"wires":[["a8f50e3.26444f"]]},{"id":"16fd49e3.931d96","type":"change","z":"b9924a74.4d98f8","name":"SENSOR","rules":[{"t":"move","p":"payload","pt":"msg","to":"sensor","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":2870,"wires":[["f8e11f91.65866"]]},{"id":"7bcdc2cc.8361fc","type":"change","z":"b9924a74.4d98f8","name":"LIGHT","rules":[{"t":"move","p":"payload","pt":"msg","to":"light","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":3310,"wires":[["c02e5fd0.1bc08","81e7bb2b.cf3ca8"]]},{"id":"737d49df.edd43","type":"link out","z":"b9924a74.4d98f8","name":"","links":["dca5b725.d2b278","1580a1c8.79e12e","c96ad72f.ef4a4"],"x":725,"y":2870,"wires":[]},{"id":"dca5b725.d2b278","type":"link in","z":"b9924a74.4d98f8","name":"","links":["737d49df.edd43"],"x":123,"y":2986,"wires":[["90b50622.49a88"]]},{"id":"1580a1c8.79e12e","type":"link in","z":"b9924a74.4d98f8","name":"","links":["737d49df.edd43"],"x":123,"y":3056,"wires":[["9bf033ee.252b18"]]},{"id":"c96ad72f.ef4a4","type":"link in","z":"b9924a74.4d98f8","name":"","links":["737d49df.edd43"],"x":123,"y":3126,"wires":[["beef2d66.26236"]]},{"id":"c02e5fd0.1bc08","type":"debug","z":"b9924a74.4d98f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":840,"y":3310,"wires":[]},{"id":"765c9048.a6f998","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"test","payload":"250","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":490,"y":3260,"wires":[["d96323ce.7d474"]]},{"id":"84cbf7ff.03aee8","type":"mqtt in","z":"b9924a74.4d98f8","name":"","topic":"OUTTOPIC","qos":"0","datatype":"auto","broker":"c556ac10.5b1a9","x":1080,"y":3150,"wires":[["b0dcb49d.143a3"]]},{"id":"3bc8f3f7.015194","type":"mqtt out","z":"b9924a74.4d98f8","name":"","topic":"OUTTOPIC","qos":"","retain":"","broker":"c556ac10.5b1a9","x":1280,"y":3260,"wires":[]},{"id":"b0dcb49d.143a3","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1290,"y":3150,"wires":[]},{"id":"cb40442.e5308b8","type":"function","z":"b9924a74.4d98f8","name":"get bright","func":"var bright = global.get(\"bright\")||0;\nmsg.payload.bright = bright;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":3260,"wires":[["3bc8f3f7.015194","8eadbaff.612e"]]},{"id":"8eadbaff.612e","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1280,"y":3200,"wires":[]},{"id":"a0689393.0da3b","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"{\"r\":\"250\",\"g\":\"250\",\"b\":\"250\",\"a\":\"1\"}","payloadType":"json","repeat":"0.1","crontab":"","once":false,"onceDelay":0.1,"x":1080,"y":3200,"wires":[["cb40442.e5308b8"]]},{"id":"f8e11f91.65866","type":"function","z":"b9924a74.4d98f8","name":"","func":"if (msg.sensor > 0)\n{\n    context.set(\"SENSOR\",msg.sensor);\n}\nif (msg.light > 0)\n{\n    context.set(\"LIGHT\",msg.light);\n}\n\nlet sensor = context.get(\"SENSOR\");\nlet light = context.get(\"LIGHT\");\nif ((sensor > 0) && (light > 0))\n{\n    msg = {\"sensor\":sensor,\"light\":light}\n    return msg;\n}\n\nreturn;","outputs":1,"noerr":0,"x":590,"y":2870,"wires":[["737d49df.edd43","678e6219.eb4f14"]]},{"id":"678e6219.eb4f14","type":"debug","z":"b9924a74.4d98f8","name":"Average","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":770,"y":2820,"wires":[]},{"id":"551e020e.637c2c","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":640,"y":3350,"wires":[]},{"id":"a687fd2b.52cdf","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":340,"y":3390,"wires":[]},{"id":"81e7bb2b.cf3ca8","type":"link out","z":"b9924a74.4d98f8","name":"","links":["d28ac069.e590a"],"x":815,"y":3270,"wires":[]},{"id":"d28ac069.e590a","type":"link in","z":"b9924a74.4d98f8","name":"","links":["81e7bb2b.cf3ca8"],"x":485,"y":2900,"wires":[["f8e11f91.65866"]]},{"id":"1e55c7d0.020e8","type":"trigger","z":"b9924a74.4d98f8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":520,"y":2940,"wires":[[]]},{"id":"3ef0a7c1.4b7898","type":"trigger","z":"b9924a74.4d98f8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":520,"y":3020,"wires":[[]]},{"id":"396471a3.5b90b6","type":"trigger","z":"b9924a74.4d98f8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":520,"y":3090,"wires":[[]]},{"id":"5f171e98.6f1718","type":"ui_group","z":"","name":"LED","tab":"8a2ccb77.317da8","order":1,"disp":true,"width":"6","collapse":false},{"id":"c556ac10.5b1a9","type":"mqtt-broker","z":"","name":"Broker","broker":"http://www.mqtt-dashboard.com/","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"8a2ccb77.317da8","type":"ui_tab","z":"","name":"Broker","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Oh, and P.S. I have turned off the repeat in the first inject node.
I didn't need the complication it was causing.

1 Like

Thank you so much.
I also tried to join(join node) the two data, but It doesn't work, too.
I keep trying in another ways :disappointed_relieved:.

Thanks for your advice.
1,2 : I used the debug node just to check(immediate). I have nobody to advise me...Thanks for the tip.
3 : Actually I tried. I didn't know, so l kept changing. Now i know for sure. thank you.

MQTT : To send brightness to node MCU & neopixels light.

스크린샷 2020-06-24 오후 3.24.13
To match the test inputs as shown in this screen shot.
I didn't know, so I just put it in... Meaningless :sob:

The same thing is true.
Not yet good at use...sorry... I'll try to make a habit!!! Thanks.

I'll make sure to apply it next time.
Sorry for causing trouble.

The reason for applying 'repeat' is to average sensor data from six times.

--
Thank you so much for everything.
I'll cheer up and try again!@!!!
Thank you for letting me know what I'm lacking.
I will study hard to use it better.

The Join node is a good way to go, but it is necessary to configure it correctly. Have a look at this link to an example in the cookbook, and show us what the problem is if it doesn't work.
https://cookbook.nodered.org/basic/join-streams

2 Likes

I am trying to build a flow that can handle the output of two separate msg(msg.sensor, msg.bright)

The flow that I uploaded,


Each value is output but cannot be joined.

How do I combine them?

--
I fell asleep for a while...

Oh, for your information,


It was changed to turn the number over as a slider(dashboard).

Did you read and understand the cookbook example? Import the flow and experiment with it to see how it works.
If you still can't get yours working add a debug node showing what is going into the Join node so we can see what the data looks like, and show us how you have configured the Join node.

I checked, but I guess I didn't understand it well.
I'm sorry...

output msg.


It's not even classified as a topic, just it's two different objects(sensor, bright).
I don't know how to type value...I think I'll have to try another way.
I've been studying.

That is the way to do it. If you feed that intot he Join node as in the example and put a debug node on its output then what do you see?

automatic Mode
debug : Message missing msg.parts property - cannot join in 'auto' mode
manual Mode

-key/value - msg.topic


debug : Message missing key property 'msg.topic' - cannot add to object

-merged
debug : Cannot merge non-object types

I've tried other types, but... I couldn't.

well...I understood that you wanted to know this.
did you want this answer?
I simplified the flow for several attempts.

[{"id":"742ab856.d09e08","type":"join","z":"3d04da92.71e9e6","name":"6 data","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":210,"y":280,"wires":[["283f6a7d.0ba0c6"]]},{"id":"283f6a7d.0ba0c6","type":"function","z":"3d04da92.71e9e6","name":"Average","func":"x = msg.payload[0];\n//node.warn(x);\nx = x + msg.payload[1];\n//node.warn(x);\nx = x + msg.payload[2];\n//node.warn(x);\nx = x + msg.payload[3];\n//node.warn(x);\nx = x + msg.payload[4];\n//node.warn(x);\nx = x + msg.payload[5];\n//node.warn(x);\n\n\nx = x / 6;\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":280,"wires":[["9dc04b77.dfdfa8"]]},{"id":"81d28fbc.0d149","type":"inject","z":"3d04da92.71e9e6","name":"","topic":"test sensor value","payload":"30","payloadType":"num","repeat":"2","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":220,"wires":[["742ab856.d09e08"]]},{"id":"76c33b98.3a57c4","type":"debug","z":"3d04da92.71e9e6","name":"join","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1210,"y":280,"wires":[]},{"id":"50bdac36.1eed74","type":"debug","z":"3d04da92.71e9e6","name":"sensor","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":850,"y":220,"wires":[]},{"id":"9dc04b77.dfdfa8","type":"change","z":"3d04da92.71e9e6","name":"sensor","rules":[{"t":"move","p":"payload","pt":"msg","to":"sensor","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":280,"wires":[["50bdac36.1eed74","d4e8e433.55e2e8"]]},{"id":"d4e8e433.55e2e8","type":"join","z":"3d04da92.71e9e6","name":"","mode":"auto","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":1070,"y":280,"wires":[["76c33b98.3a57c4"]]},{"id":"84c3cdf4.b3128","type":"function","z":"3d04da92.71e9e6","name":"bright","func":"global.set(\"bright\",msg.payload)\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":360,"wires":[["543884a7.43dfec"]]},{"id":"2cfe120b.326abe","type":"ui_text","z":"3d04da92.71e9e6","group":"bf3e38c0.e29328","order":2,"width":0,"height":0,"name":"","label":"bright","format":"{{msg.payload}}","layout":"row-spread","x":650,"y":400,"wires":[]},{"id":"ac9e2c09.9ab19","type":"ui_slider","z":"3d04da92.71e9e6","name":"","label":"bright","tooltip":"","group":"bf3e38c0.e29328","order":1,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"255","step":1,"x":470,"y":360,"wires":[["84c3cdf4.b3128","2cfe120b.326abe"]]},{"id":"8a076e15.4418a","type":"inject","z":"3d04da92.71e9e6","name":"","topic":"test bright value","payload":"0","payloadType":"num","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":360,"wires":[["ac9e2c09.9ab19"]]},{"id":"fd0997b7.2483e8","type":"inject","z":"3d04da92.71e9e6","name":"","topic":"test bright value","payload":"250","payloadType":"num","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":400,"wires":[["ac9e2c09.9ab19"]]},{"id":"1b512bf5.df86d4","type":"debug","z":"3d04da92.71e9e6","name":"return bright","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":420,"wires":[]},{"id":"543884a7.43dfec","type":"change","z":"3d04da92.71e9e6","name":"return bright","rules":[{"t":"move","p":"payload","pt":"msg","to":"bright","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":360,"wires":[["1b512bf5.df86d4","d4e8e433.55e2e8"]]},{"id":"bf3e38c0.e29328","type":"ui_group","z":"","name":"LED","tab":"7cc68490.34bccc","order":1,"disp":true,"width":"6","collapse":false},{"id":"7cc68490.34bccc","type":"ui_tab","z":"","name":"Broker","icon":"dashboard","order":2,"disabled":false,"hidden":false}]
  • Placement only. Meaningless to numbers

Is that how it is configured in the example?

I just searched for the forum, I arranged the nodes one by one as I wanted...

If it didn’t work, I asked something questions...
I tried to find as much as I could...

I don't understand what you are saying. Have you got it working now?

Sorry for my poor English....

I'm trying to study the node that `Trying_to_learn’ answered me above.

but Well, it's too late night here, so I'm going to try again tomorrow

You really need to read how the join node works.

I've quickly looked at the flow you just posted.

You leaving it (the join node) to the default settings is not helping.

Oh, and making the inject nodes repeat their message (particularly the two at the bottom going into brightness) are not really helping the situation. It is supposed to be a fixed value.
Having it vary between 0 and 255 is really really making things confusing.

1 Like

I have to take a step back for a moment.

Here is the code to which I shall refer.
I know it is my code, but it is the best "bigger picture" code you have yet posted.

[{"id":"d96323ce.7d474","type":"function","z":"b9924a74.4d98f8","name":"bright","func":"global.set(\"bright\",msg.payload)\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":3310,"wires":[["7bcdc2cc.8361fc","551e020e.637c2c"]]},{"id":"a8f50e3.26444f","type":"join","z":"b9924a74.4d98f8","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"6","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":420,"y":2820,"wires":[["4a0ca290.64a7cc"]]},{"id":"4a0ca290.64a7cc","type":"function","z":"b9924a74.4d98f8","name":"Average","func":"x = msg.payload[0];\n//node.warn(x);\nx = x + msg.payload[1];\n//node.warn(x);\nx = x + msg.payload[2];\n//node.warn(x);\nx = x + msg.payload[3];\n//node.warn(x);\nx = x + msg.payload[4];\n//node.warn(x);\nx = x + msg.payload[5];\n//node.warn(x);\n\n\nx = x / 6;\nmsg.payload = x;\nreturn msg;","outputs":1,"noerr":0,"x":580,"y":2820,"wires":[["16fd49e3.931d96"]]},{"id":"ec0a453e.e29d78","type":"ui_text","z":"b9924a74.4d98f8","group":"5f171e98.6f1718","order":2,"width":0,"height":0,"name":"","label":"bright","format":"{{msg.payload}}","layout":"row-spread","x":500,"y":3350,"wires":[]},{"id":"e6ade3ec.3677f8","type":"ui_slider","z":"b9924a74.4d98f8","name":"","label":"bright","tooltip":"","group":"5f171e98.6f1718","order":1,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"255","step":1,"x":260,"y":3310,"wires":[["d96323ce.7d474","ec0a453e.e29d78","a687fd2b.52cdf"]]},{"id":"a041821b.4ff5d8","type":"function","z":"b9924a74.4d98f8","name":"dimming ++","func":"s = msg.payload\nfor(var x=s;x<=250;x++)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":558,"y":2986,"wires":[["5e562e2d.03bad"]]},{"id":"c249cd43.36d5d8","type":"function","z":"b9924a74.4d98f8","name":"dimming ++","func":"s = msg.payload\nfor(var x=s;x<=250;x++)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":558,"y":3126,"wires":[["5e562e2d.03bad"]]},{"id":"8e796149.bd8528","type":"function","z":"b9924a74.4d98f8","name":"dimming --","func":"s = msg.payload\nfor(var x=s;x>=50;x--)\n{\n    node.send({\"bright\":x})\n}\nreturn null;","outputs":1,"noerr":0,"x":558,"y":3056,"wires":[["5e562e2d.03bad"]]},{"id":"2ccf3bf0.671154","type":"change","z":"b9924a74.4d98f8","name":"","rules":[{"t":"move","p":"bright","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":3200,"wires":[["e6ade3ec.3677f8","fce2b503.6c6b5"]]},{"id":"beef2d66.26236","type":"function","z":"b9924a74.4d98f8","name":"80 < sensor <= 100 & light == 250","func":"if ((msg.sensor > 80) && (msg.sensor <= 100) && (msg.payload.light == 250))\n{\n    msg.payload = 50;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":308,"y":3126,"wires":[["c249cd43.36d5d8","396471a3.5b90b6"]]},{"id":"9bf033ee.252b18","type":"function","z":"b9924a74.4d98f8","name":"40 < sensor <= 80 & light == 50","func":"if ((msg.sensor > 40) && (msg.sensor <= 80) && (msg.light == 50))\n{\n    msg.payload = 250;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":298,"y":3056,"wires":[["8e796149.bd8528","3ef0a7c1.4b7898"]]},{"id":"90b50622.49a88","type":"function","z":"b9924a74.4d98f8","name":"sensor <= 40 & light == 250","func":"if((msg.sensor <= 40) && (msg.light == 250))\n{\n    msg.payload = 50;\n}\nelse\n{\n    return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":288,"y":2986,"wires":[["a041821b.4ff5d8","1e55c7d0.020e8"]]},{"id":"fce2b503.6c6b5","type":"debug","z":"b9924a74.4d98f8","name":"WTF?","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":500,"y":3200,"wires":[]},{"id":"5e562e2d.03bad","type":"delay","z":"b9924a74.4d98f8","name":"","pauseType":"rate","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":798,"y":3056,"wires":[["2ccf3bf0.671154","e0967fb1.803c08"]]},{"id":"e0967fb1.803c08","type":"debug","z":"b9924a74.4d98f8","name":"Dimming?","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1020,"y":3057,"wires":[]},{"id":"b018e5d8.599de8","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"test sensor","payload":"30","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":2820,"wires":[["a8f50e3.26444f"]]},{"id":"16fd49e3.931d96","type":"change","z":"b9924a74.4d98f8","name":"SENSOR","rules":[{"t":"move","p":"payload","pt":"msg","to":"sensor","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":2870,"wires":[["f8e11f91.65866"]]},{"id":"7bcdc2cc.8361fc","type":"change","z":"b9924a74.4d98f8","name":"LIGHT","rules":[{"t":"move","p":"payload","pt":"msg","to":"light","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":3310,"wires":[["c02e5fd0.1bc08","81e7bb2b.cf3ca8"]]},{"id":"737d49df.edd43","type":"link out","z":"b9924a74.4d98f8","name":"","links":["dca5b725.d2b278","1580a1c8.79e12e","c96ad72f.ef4a4"],"x":725,"y":2870,"wires":[]},{"id":"dca5b725.d2b278","type":"link in","z":"b9924a74.4d98f8","name":"","links":["737d49df.edd43"],"x":123,"y":2986,"wires":[["90b50622.49a88"]]},{"id":"1580a1c8.79e12e","type":"link in","z":"b9924a74.4d98f8","name":"","links":["737d49df.edd43"],"x":123,"y":3056,"wires":[["9bf033ee.252b18"]]},{"id":"c96ad72f.ef4a4","type":"link in","z":"b9924a74.4d98f8","name":"","links":["737d49df.edd43"],"x":123,"y":3126,"wires":[["beef2d66.26236"]]},{"id":"c02e5fd0.1bc08","type":"debug","z":"b9924a74.4d98f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":840,"y":3310,"wires":[]},{"id":"765c9048.a6f998","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"test","payload":"250","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":490,"y":3260,"wires":[["d96323ce.7d474"]]},{"id":"84cbf7ff.03aee8","type":"mqtt in","z":"b9924a74.4d98f8","name":"","topic":"OUTTOPIC","qos":"0","datatype":"auto","broker":"c556ac10.5b1a9","x":1080,"y":3150,"wires":[["b0dcb49d.143a3"]]},{"id":"3bc8f3f7.015194","type":"mqtt out","z":"b9924a74.4d98f8","name":"","topic":"OUTTOPIC","qos":"","retain":"","broker":"c556ac10.5b1a9","x":1280,"y":3260,"wires":[]},{"id":"b0dcb49d.143a3","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1290,"y":3150,"wires":[]},{"id":"cb40442.e5308b8","type":"function","z":"b9924a74.4d98f8","name":"get bright","func":"var bright = global.get(\"bright\")||0;\nmsg.payload.bright = bright;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":3260,"wires":[["3bc8f3f7.015194","8eadbaff.612e"]]},{"id":"8eadbaff.612e","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1280,"y":3200,"wires":[]},{"id":"a0689393.0da3b","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"{\"r\":\"250\",\"g\":\"250\",\"b\":\"250\",\"a\":\"1\"}","payloadType":"json","repeat":"0.1","crontab":"","once":false,"onceDelay":0.1,"x":1080,"y":3200,"wires":[["cb40442.e5308b8"]]},{"id":"f8e11f91.65866","type":"function","z":"b9924a74.4d98f8","name":"","func":"if (msg.sensor > 0)\n{\n    context.set(\"SENSOR\",msg.sensor);\n}\nif (msg.light > 0)\n{\n    context.set(\"LIGHT\",msg.light);\n}\n\nlet sensor = context.get(\"SENSOR\");\nlet light = context.get(\"LIGHT\");\nif ((sensor > 0) && (light > 0))\n{\n    msg = {\"sensor\":sensor,\"light\":light}\n    return msg;\n}\n\nreturn;","outputs":1,"noerr":0,"x":590,"y":2870,"wires":[["737d49df.edd43","678e6219.eb4f14"]]},{"id":"678e6219.eb4f14","type":"debug","z":"b9924a74.4d98f8","name":"Average","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":770,"y":2820,"wires":[]},{"id":"551e020e.637c2c","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":640,"y":3350,"wires":[]},{"id":"a687fd2b.52cdf","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":340,"y":3390,"wires":[]},{"id":"81e7bb2b.cf3ca8","type":"link out","z":"b9924a74.4d98f8","name":"","links":["d28ac069.e590a"],"x":815,"y":3270,"wires":[]},{"id":"d28ac069.e590a","type":"link in","z":"b9924a74.4d98f8","name":"","links":["81e7bb2b.cf3ca8"],"x":485,"y":2900,"wires":[["f8e11f91.65866"]]},{"id":"1e55c7d0.020e8","type":"trigger","z":"b9924a74.4d98f8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":520,"y":2940,"wires":[[]]},{"id":"3ef0a7c1.4b7898","type":"trigger","z":"b9924a74.4d98f8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":520,"y":3020,"wires":[[]]},{"id":"396471a3.5b90b6","type":"trigger","z":"b9924a74.4d98f8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":520,"y":3090,"wires":[[]]},{"id":"5f171e98.6f1718","type":"ui_group","z":"","name":"LED","tab":"8a2ccb77.317da8","order":1,"disp":true,"width":"6","collapse":false},{"id":"c556ac10.5b1a9","type":"mqtt-broker","z":"","name":"Broker","broker":"http://www.mqtt-dashboard.com/","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"8a2ccb77.317da8","type":"ui_tab","z":"","name":"Broker","icon":"dashboard","order":2,"disabled":false,"hidden":false}]

Something else I kind of missed:

You have the sensor input (at the top)

That is then sent through some nodes to average it, then combine it with another value you are feeding in which is the "set" brightness for the lamps.

I'm with you to there.

But where is the actual function you want to do?

It is pointless writing a program that does nothing.
Usually that (writing a program) is to do something.

All yours does is create a few hundred self inducing loops until two values match.
But then what?

You included an extra piece of code:

[{"id":"84cbf7ff.03aee8","type":"mqtt in","z":"b9924a74.4d98f8","name":"","topic":"OUTTOPIC","qos":"0","datatype":"auto","broker":"c556ac10.5b1a9","x":1070,"y":3150,"wires":[["b0dcb49d.143a3"]]},{"id":"3bc8f3f7.015194","type":"mqtt out","z":"b9924a74.4d98f8","name":"","topic":"OUTTOPIC","qos":"","retain":"","broker":"c556ac10.5b1a9","x":1280,"y":3260,"wires":[]},{"id":"b0dcb49d.143a3","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1280,"y":3150,"wires":[]},{"id":"cb40442.e5308b8","type":"function","z":"b9924a74.4d98f8","name":"get bright","func":"var bright = global.get(\"bright\")||0;\nmsg.payload.bright = bright;\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":3260,"wires":[["3bc8f3f7.015194","8eadbaff.612e"]]},{"id":"8eadbaff.612e","type":"debug","z":"b9924a74.4d98f8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1280,"y":3200,"wires":[]},{"id":"a0689393.0da3b","type":"inject","z":"b9924a74.4d98f8","name":"","topic":"","payload":"{\"r\":\"250\",\"g\":\"250\",\"b\":\"250\",\"a\":\"1\"}","payloadType":"json","repeat":"0.1","crontab":"","once":false,"onceDelay":0.1,"x":1080,"y":3200,"wires":[["cb40442.e5308b8"]]},{"id":"c556ac10.5b1a9","type":"mqtt-broker","z":"","name":"Broker","broker":"http://www.mqtt-dashboard.com/","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Which you say is:

And yet it isn't connected to the main part of the code. So exactly where/how it is supposed to work is vague - at best.

Taking a further step back:

You have two dashboard things:
1 - the slider
2 - a text node.

They show what? The brightness that you set of the brightness the program has set?
As they are, they are in a feedback loop which causes a lot of extra work for nothing.

New take:

You want to set the brightness of the LEDs.
A signal comes along from test sensor. What that is is unknown and why it is there is also unknown.

It sends a value into the program and the program then adjusts the brightness to...... Unclear.

That new value (from all three function nodes doing these weird compares) is then sent back to the start of the program and mated with a new test sensor value.

That is then - and I shall stress: again - sent back to the 3 comparison nodes I just mentioned.

Last thoughts:

You may need to really understand (define?) what it is you are wanting to do.
As I said earlier, there is no clearly defined function this is doing. Other than creating a few hundred loops which adjusting values to match. But in saying match that isn't really clearly defined either. Other than 3 nodes doing complicated comparisons.

You seem to be making a simple thing very complicated.

1 Like

Which is why I have been attempting to get the OP to import and play with the cookbook example, and understand it, before going any further.

1 Like

Yeah, I do agree. And though we seem to be at opposite ends on how we are doing it.....

I am doing it my way. Not that it is better than yours. Just different.

But there are a lot of problem he has yet to find.

Thank you so much for answering my questions.
The problem has been solved.
I know my code isn't perfect...

I also studied a lot about many things including the Join node.
I thought I should use something other than a join node, but Thank you for giving me the some time and chance of understanding the node.

and...

The reason why I didn't test it with real value...because one is real-time data measured using EMOTIV nodes (library) and the other is real-time lighting values connected through Arduino.
I thought it would be okay if the numbers were printed out.
I was not thinking straight....sorry
I still have a long way to go...I made a decision to study hard.

  • I write through translation because I can't speak English very well... It could have been difficult to understand what I said. you can not feel my sincerity in this article, but I really appreciate it. Thanks.