Two inputs in one function

You could always store the values in global variables, then use a get.global command within the function?

As I said 19 hours ago,
change the join option 'to create' to 'an Array'
and the resultant msg.payload will be an array with the first msg.payload to arrive will be the first entry in the array and the second msg.payload will be the second entry in the array.

Hi

your flow did the trick, but my problem now is that i cant find anyware to insert a topic to my Hue bulb,
Can you help

[{"id":"5b711416.372d9c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2d538999.8fb956","type":"debug","z":"5b711416.372d9c","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":750,"y":200,"wires":[]},{"id":"d42efb44.448ca8","type":"join","z":"5b711416.372d9c","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":550,"y":200,"wires":[["2d538999.8fb956"]]},{"id":"6308d1cc.33e48","type":"inject","z":"5b711416.372d9c","name":"Light Request (Buffer)","topic":"request","payload":"[28,2,0,97,0,0,255,130]","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":160,"wires":[["d42efb44.448ca8"]]},{"id":"130cb646.bfb3aa","type":"inject","z":"5b711416.372d9c","name":"Light Reply (JSON)","topic":"reply","payload":"{\"on\":true,\"brightness\":33,\"reachable\":true,\"rgb\":[255,178,76],\"hex\":\"ffb24c\",\"color\":\"orange\",\"colorTemp\":497,\"updated\":\"2020-08-22T20:56:26+02:00\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":340,"wires":[[]]},{"id":"3a875562.2802ba","type":"hue-light","z":"5b711416.372d9c","name":"Gulvlampe","bridge":"92011666.d44778","lightid":"2","colornamer":true,"skipevents":false,"x":190,"y":220,"wires":[["d42efb44.448ca8"]]},{"id":"92011666.d44778","type":"hue-bridge","z":"","name":"Philips hue","bridge":"192.168.0.11","key":"TEhdryuqFDW60NeiMR7kWSiXT-h0VwNrKAW4IeGc","interval":"3000","disableupdates":false}]

use a change node to change the topic

could you give me a hint, i dont know what to do with the change node

have you read the documentation about the change node? https://nodered.org/docs/user-guide/nodes#change

If you haven't, go read it.
If you have, what don't you understand about how to use it? What have you tried?

I did try to find something about setting a topic, but i cant find anything.

I did try this

[{"id":"5b711416.372d9c","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2d538999.8fb956","type":"debug","z":"5b711416.372d9c","name":"Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":930,"y":380,"wires":[]},{"id":"d42efb44.448ca8","type":"join","z":"5b711416.372d9c","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":710,"y":300,"wires":[["2d538999.8fb956"]]},{"id":"6308d1cc.33e48","type":"inject","z":"5b711416.372d9c","name":"Light Request (Buffer)","topic":"request","payload":"[28,2,0,97,0,0,255,130]","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":240,"wires":[["d42efb44.448ca8"]]},{"id":"130cb646.bfb3aa","type":"inject","z":"5b711416.372d9c","name":"Light Reply (JSON) TEST","topic":"","payload":"{\"on\":true,\"brightness\":33,\"reachable\":true,\"rgb\":[255,178,76],\"hex\":\"ffb24c\",\"color\":\"orange\",\"colorTemp\":497,\"updated\":\"2020-08-22T20:56:26+02:00\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":400,"wires":[["1efaab1f.548975"]]},{"id":"3a875562.2802ba","type":"hue-light","z":"5b711416.372d9c","name":"Gulvlampe","bridge":"92011666.d44778","lightid":"2","colornamer":true,"skipevents":false,"x":150,"y":320,"wires":[["1efaab1f.548975"]]},{"id":"1efaab1f.548975","type":"change","z":"5b711416.372d9c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.light","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":400,"wires":[["d42efb44.448ca8","2d538999.8fb956"]]},{"id":"92011666.d44778","type":"hue-bridge","z":"","name":"Philips hue","bridge":"192.168.0.11","key":"TEhdryuqFDW60NeiMR7kWSiXT-h0VwNrKAW4IeGc","interval":"3000","disableupdates":false}]

Move the change node to after the join node
Where it says msg.payload, you can change ‘payload’ to ‘topic’

the Join node wont run because the JSON/Hue Bulb dont have a topic

image

I got it

image

1 Like

I know .. that can work .. but with a disadvantage.
.. the disadvantage of merging to an array, is that, when two messages arrive in the join node from the same source .. lets say 'buffer' for this example .. you will get an array with two "buffers".

Screenshot_2020-08-24 Node-RED 192 168 1 160

Setting the Join to key/value object and 'number of message parts' : 2 and with 'every subsequent message' checked .. you get one msg, only the case of two subsequent messages from the two different sources.
but it depends on the use case .. i find it safer with a key/value object.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.