Looking for help with a variable blink type flow

I am having trouble trying to figure out how to even get started with this.

What I am trying to do is have a light turn on at an intensity set by a slider. It will stay on for a variable time set by another slider, and then turn off (intensity 0) for a variable time set by a third slider, This will continue blinking with the set variables, but also be adjustable while running.

What I have so far is a switch to turn it on and off, basically it allows or blocks the payload from going to the output.
I can adjust the initial intensity and set how long it would be on.
But then I have no idea how to change the intensity back to 0 for a length of time and then begin the loop again.

This is the flow I have so far.

[{"id":"6062053d.2086dc","type":"inject","z":"b0931cb110c11b45","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.5","topic":"","payload":"60","payloadType":"num","x":130,"y":240,"wires":[["cc8a5dae.05a4"]]},{"id":"b76703eb.5ec03","type":"inject","z":"b0931cb110c11b45","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.7","topic":"","payload":"5","payloadType":"num","x":130,"y":300,"wires":[["9a916755.f1d9d8"]]},{"id":"bc35b4d6.a57d98","type":"inject","z":"b0931cb110c11b45","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.4","topic":"","payload":"10","payloadType":"num","x":130,"y":380,"wires":[["32632475.72d99c"]]},{"id":"cc8a5dae.05a4","type":"ui_slider","z":"b0931cb110c11b45","name":"","label":"Power","tooltip":"","group":"c54e984f8898c3b8","order":3,"width":0,"height":0,"passthru":true,"outs":"end","topic":"pow","topicType":"str","min":"1","max":"100","step":1,"className":"","x":290,"y":240,"wires":[["96aa29b9.5b8638"]]},{"id":"9a916755.f1d9d8","type":"ui_slider","z":"b0931cb110c11b45","name":"","label":"Time on","tooltip":"","group":"c54e984f8898c3b8","order":4,"width":0,"height":0,"passthru":true,"outs":"end","topic":"on","topicType":"str","min":"1","max":"60","step":1,"className":"","x":300,"y":300,"wires":[["96aa29b9.5b8638"]]},{"id":"32632475.72d99c","type":"ui_slider","z":"b0931cb110c11b45","name":"","label":"time off","tooltip":"","group":"c54e984f8898c3b8","order":6,"width":0,"height":0,"passthru":true,"outs":"end","topic":"off","topicType":"str","min":"1","max":"60","step":1,"className":"","x":300,"y":380,"wires":[[]]},{"id":"96aa29b9.5b8638","type":"join","z":"b0931cb110c11b45","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":530,"y":240,"wires":[["91a55690.12e718"]]},{"id":"91a55690.12e718","type":"change","z":"b0931cb110c11b45","name":"","rules":[{"t":"set","p":"delay","pt":"msg","to":"($$.payload.on) * 1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":720,"y":360,"wires":[["b241ad6a.eb624"]]},{"id":"b241ad6a.eb624","type":"trigger","z":"b0931cb110c11b45","name":"","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"10","extend":false,"overrideDelay":true,"units":"s","reset":"false","bytopic":"all","topic":"topic","outputs":2,"x":730,"y":240,"wires":[["1a697bb4.3ef984"],["91a55690.12e718"]]},{"id":"718406a5.505528","type":"inject","z":"b0931cb110c11b45","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":".02","topic":"","payload":"false","payloadType":"bool","x":510,"y":180,"wires":[["b241ad6a.eb624"]]},{"id":"1a697bb4.3ef984","type":"change","z":"b0931cb110c11b45","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"($$.payload.pow)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":240,"wires":[["a22dc4c4.058de8"]]},{"id":"d9970365.1b","type":"debug","z":"b0931cb110c11b45","name":"debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1250,"y":240,"wires":[]},{"id":"a22dc4c4.058de8","type":"traffic","z":"b0931cb110c11b45","name":"","property_allow":"payload","filter_allow":"true","ignore_case_allow":true,"negate_allow":false,"send_allow":false,"property_stop":"payload","filter_stop":"false","ignore_case_stop":true,"negate_stop":false,"send_stop":false,"default_start":false,"differ":false,"x":1110,"y":300,"wires":[["d9970365.1b"]]},{"id":"6564003e.5890d","type":"ui_switch","z":"b0931cb110c11b45","name":"","label":"On/Off","tooltip":"","group":"c54e984f8898c3b8","order":2,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":1070,"y":140,"wires":[["a22dc4c4.058de8"]]},{"id":"96901392.0175e","type":"inject","z":"b0931cb110c11b45","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.1","topic":"","payload":"false","payloadType":"bool","x":909,"y":139,"wires":[["6564003e.5890d"]]},{"id":"c54e984f8898c3b8","type":"ui_group","name":"Default","tab":"35306e68b5db6e65","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"35306e68b5db6e65","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

If anyone can fix or write a flow for me it would be appreciated.

Assuming that your payload looks like this

{
"brightness":50,
"timeon":2,   
"timeoff":5
}

You need two trigger nodes. One sends On and Off, the other waits a bit then restarts the loop. Each one needs a change node to set msg.delay :

[{"id":"14f3d2554301f138","type":"trigger","z":"67305623ffab64cc","name":"On then Off","op1":"","op2":"","op1type":"pay","op2type":"payl","duration":"5","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":430,"y":420,"wires":[["5eaaca5dd826b897"],["e243105d36f631a0","b712647f70ccc5ae"]]},{"id":"840edfe8a4fd1f6d","type":"debug","z":"67305623ffab64cc","name":"debug 421","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":520,"wires":[]},{"id":"eead5dcd6205f543","type":"trigger","z":"67305623ffab64cc","name":"Wait, repeat","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"5","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":2,"x":430,"y":500,"wires":[[],["cfc323c7cfdd39b4"]]},{"id":"1b197aade5a6e1e5","type":"inject","z":"67305623ffab64cc","name":"Start","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"brightness\": 50, \"timeon\": 2, \"timeoff\": 5}","payloadType":"json","x":90,"y":360,"wires":[["cfc323c7cfdd39b4"]]},{"id":"5eaaca5dd826b897","type":"change","z":"67305623ffab64cc","name":"payload = brightness","rules":[{"t":"move","p":"payload.brightness","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":400,"wires":[["840edfe8a4fd1f6d"]]},{"id":"cfc323c7cfdd39b4","type":"change","z":"67305623ffab64cc","name":"Set msg.delay","rules":[{"t":"set","p":"delay","pt":"msg","to":"payload.timeon * 1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":420,"wires":[["14f3d2554301f138"]]},{"id":"b712647f70ccc5ae","type":"change","z":"67305623ffab64cc","name":"Set msg.delay","rules":[{"t":"set","p":"delay","pt":"msg","to":"payload.timeoff * 1000","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":500,"wires":[["eead5dcd6205f543"]]},{"id":"eb900d81334064c4","type":"inject","z":"67305623ffab64cc","name":"reset","props":[{"p":"reset","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":250,"y":360,"wires":[["eead5dcd6205f543","14f3d2554301f138"]]},{"id":"e243105d36f631a0","type":"change","z":"67305623ffab64cc","name":"payload = 0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":440,"wires":[["840edfe8a4fd1f6d"]]}]

If your sliders and join node construct a single message in the format shown above they can replace the "Start" inject node, probably via another trigger node to send msg.reset then the new payload. Something like this:

I was able to use this to get the result I was going for. Thank you.

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