Hello ..
- you can create a msg with the following fields
(possibly through a Dashboard form ... for the example we use an Inject node)
msg.lightMode
sets the color mode for the light
msg.rate
defines the rate limit between msgs, used by the Delay node (in milliseconds)
- the msg is passed to a Function node that creates x amount of off/on msgs
- delay node rate limits the msgs as defined in step 1
Test flow:
[{"id":"c8e60de07b087df2","type":"inject","z":"4895ea10b4ee9ead","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"lightMode","v":"5","vt":"num"},{"p":"rate","v":"2000","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"lightControl","payloadType":"date","x":200,"y":1340,"wires":[["813c73a9cfc5780e","e09d6f33c0aa0804"]]},{"id":"813c73a9cfc5780e","type":"function","z":"4895ea10b4ee9ead","name":"","func":"\nlet lightMode = msg.lightMode // how many times to switch on/off\nlet rate = msg.rate // rate between msgs .. needed property for Rate Limit Trigger node\n\nfor (let i = 0; i < lightMode; i++) {\n\n node.send({ payload: \"OFF\", rate })\n node.send({ payload: \"ON\", rate })\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":420,"y":1340,"wires":[["090f46dde86a5c60"]]},{"id":"c68a52fac94e3887","type":"debug","z":"4895ea10b4ee9ead","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":1340,"wires":[]},{"id":"090f46dde86a5c60","type":"delay","z":"4895ea10b4ee9ead","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":true,"x":590,"y":1340,"wires":[["c68a52fac94e3887"]]},{"id":"e09d6f33c0aa0804","type":"debug","z":"4895ea10b4ee9ead","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":400,"y":1240,"wires":[]}]
** take care of how low you set the rate because the relay may not be able to handle fast switching