To send msg in a loop you can use node.send
, eg;
s = msg.payload
for(x=s;x<255;x++){
node.send({"brightness":x})
}
Then add a delay node, set it rate limit 1 per second, or a fraction; 0.2
Example flow
[{"id":"230ec9aa.d10f3e","type":"inject","z":"46161f77.3c21d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"payload":"200","payloadType":"num","x":250,"y":500,"wires":[["dd0be8e0.063e98"]]},{"id":"dd0be8e0.063e98","type":"function","z":"46161f77.3c21d","name":"","func":"s = msg.payload\n\nfor(x=s;x<255;x++){\n\n node.send({\"brightness\":x})\n\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":500,"wires":[["cec8de22.da0a4"]]},{"id":"e19bad9a.a09f98","type":"debug","z":"46161f77.3c21d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":500,"wires":[]},{"id":"cec8de22.da0a4","type":"delay","z":"46161f77.3c21d","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":550,"y":500,"wires":[["e19bad9a.a09f98"]]}]