Raspberry 4 relays block 4 controll

hello, i am a new user, i am doing a small project and need your help, i have rasberry node res running on it, i want to control 4 relays, 17:00 starts and stops at 22:00 to repeat every 40 seconds turns on the relay and turns off for 40 seconds and so on .

Hello,
You can achieve this using only core nodes. Here is a basic example flow you can import:

[{"id":"b0cd614b.37f948","type":"inject","z":"d6787e23.0eb1b","name":"Off at 22:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 22 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":160,"wires":[["c161c4f8.de7118"]]},{"id":"21b2d3c1.55f92c","type":"trigger","z":"d6787e23.0eb1b","name":"","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"40","extend":false,"overrideDelay":true,"units":"s","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":550,"y":160,"wires":[["47e97cdb.ad3ecc"]]},{"id":"a1a2ce83.6da05","type":"change","z":"d6787e23.0eb1b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":120,"wires":[["21b2d3c1.55f92c","1277bc3f.123dbc"]]},{"id":"e34606a7.78be8","type":"change","z":"d6787e23.0eb1b","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":200,"wires":[["21b2d3c1.55f92c","1277bc3f.123dbc"]]},{"id":"47e97cdb.ad3ecc","type":"switch","z":"d6787e23.0eb1b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"OFF","vt":"str"},{"t":"eq","v":"ON","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":710,"y":160,"wires":[["a1a2ce83.6da05"],["e34606a7.78be8"]]},{"id":"c6382f7b.8b68a","type":"inject","z":"d6787e23.0eb1b","name":"On at 17:00","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 17 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":690,"y":100,"wires":[["a1a2ce83.6da05"]]},{"id":"1277bc3f.123dbc","type":"debug","z":"d6787e23.0eb1b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1130,"y":160,"wires":[]},{"id":"c161c4f8.de7118","type":"trigger","z":"d6787e23.0eb1b","name":"","op1":"reset","op2":"reset","op1type":"str","op2type":"str","duration":"250","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":360,"y":160,"wires":[["21b2d3c1.55f92c"]]}]

It works by injecting the initial on at the start time using a inject node. This message gets looped back to a trigger node set to send the original message after 40 seconds. After the trigger node comes a switch which if the payload was on sends it to a change node to set it to off and give versa. After this the loop back starts again.
At the stop time another inject node resets the 40 second timer to stop the trigger. It uses a trigger node itself to send the reset message twice 250 ms apart just in case the first reset happens exactly when the loopback is in progress.

Johannes

Or maybe just a couple of trigger nodes....

[{"id":"3ea0be5e.263652","type":"inject","z":"2988ea8b.bedff6","name":"start","props":[{"p":"payload"}],"repeat":"","crontab":"00 17 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":120,"wires":[["9893c8a7.8d5998"]]},{"id":"9893c8a7.8d5998","type":"trigger","z":"2988ea8b.bedff6","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"-80","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":380,"y":120,"wires":[["8eee61d9.43a65"]]},{"id":"ef817093.75293","type":"inject","z":"2988ea8b.bedff6","name":"stop","props":[{"p":"reset","v":"true","vt":"bool"}],"repeat":"","crontab":"00 22 * * *","once":false,"onceDelay":0.1,"topic":"","x":150,"y":180,"wires":[["9893c8a7.8d5998"]]},{"id":"8eee61d9.43a65","type":"trigger","z":"2988ea8b.bedff6","name":"","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"40","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":590,"y":120,"wires":[["b6c2199a.3bec18"]]},{"id":"b6c2199a.3bec18","type":"debug","z":"2988ea8b.bedff6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":770,"y":120,"wires":[]}]
1 Like

Nice didn’t think of putting them in series like this before the first coffee this morning :+1:t2: The 40 / 80 combination was my first thought but than i did the switch change node combination instead.

1 Like

here everything works fine but how to make the relays turn off separately let's say 2 relays then the other two and so it repeats

I don't understand the exact sequence you want at at what times so hard to guess.
One way would be just to have 4 flows like above (1 per relay) and adjust the times.

say turn on 2 relays when you turn off the sit, then turn on the other two in a circle