Algorithm timers

good afternoon
I apologize in advance if the topic was earlier
algorithm of operation after 60 seconds the display turns on 4 seconds are turned on, after disconnecting, 60 seconds are counted again, the cycle is repeated
how to implement this in node-red
thanks

Hi @HDM, I am sorry but this does not make any sense.

Could you try to explain further?

What is display?

4 seconds are turned on? It makes no sense I'm afraid.

Perhaps add some screenshots and list your logic out in a numbered list? Perhaps add your flow.

  1. 60 seconds countdown timer
  2. Turn on the display for 4 seconds by timer
  3. Disabling the display
  4. The cycle repeats to the point 1
    спасибо

Is this what you want...

  • 00:00:00 - begin timer
  • 00:01:00 - 60s later - send "ON" to display
  • 00:01:04 - 4s later - send "OFF" to display
  • 00:02:04 - 60s later - send "ON" to display
  • 00:02:08 - 4s later - send "OFF" to display
  • 00:03:08 - 60s later - send "ON" to display
  • 00:03:12 - 4s later - send "OFF" to display
    ... and so on ...

PS, I honestly have no idea what is "Turn on the display" - what kind of display - is this an MQTT signal? or a RELAY to turn TV on / off?

OK, here you go - best I can do with your description...
image

Import this flow...

[{"id":"6ce23b61.a6abe4","type":"trigger","z":"b1c27b9d.5a0ab8","op1":"","op2":"ON","op1type":"nul","op2type":"str","duration":"60","extend":false,"units":"s","reset":"","bytopic":"all","name":"Wait 60s","x":760,"y":660,"wires":[["dd3cf54c.611e18","b58e1059.a7678"]]},{"id":"dd3cf54c.611e18","type":"trigger","z":"b1c27b9d.5a0ab8","op1":"","op2":"OFF","op1type":"nul","op2type":"str","duration":"4","extend":false,"units":"s","reset":"","bytopic":"all","name":"Wait 4s","x":760,"y":700,"wires":[["5a87d7ed.d05a38","398ab895.734ae8"]]},{"id":"a5906ac4.de8f68","type":"inject","z":"b1c27b9d.5a0ab8","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":530,"y":660,"wires":[["6ce23b61.a6abe4"]]},{"id":"5a87d7ed.d05a38","type":"change","z":"b1c27b9d.5a0ab8","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":780,"wires":[["6ce23b61.a6abe4","dd3cf54c.611e18","1e654c0d.f5dac4"]]},{"id":"b58e1059.a7678","type":"debug","z":"b1c27b9d.5a0ab8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":950,"y":660,"wires":[]},{"id":"1e654c0d.f5dac4","type":"change","z":"b1c27b9d.5a0ab8","name":"","rules":[{"t":"delete","p":"reset","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":840,"wires":[["6ce23b61.a6abe4"]]},{"id":"398ab895.734ae8","type":"debug","z":"b1c27b9d.5a0ab8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":950,"y":700,"wires":[]}]

Steve - I think you can do a bit simpler like this :wink:

[{"id":"36bf2f7e.c210e","type":"inject","z":"173b76d0.b5b879","name":"","props":[{"p":"payload","v":"","vt":"str"},{"p":"topic","v":"","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":500,"wires":[["b00cc370.971e6"]]},{"id":"b00cc370.971e6","type":"trigger","z":"173b76d0.b5b879","name":"","op1":"OFF","op2":"","op1type":"str","op2type":"payl","duration":"-64","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":430,"y":500,"wires":[["cde0d496.d916f8","19b29a02.c5ee26"]]},{"id":"cde0d496.d916f8","type":"debug","z":"173b76d0.b5b879","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":690,"y":500,"wires":[]},{"id":"19b29a02.c5ee26","type":"trigger","z":"173b76d0.b5b879","name":"","op1":"","op2":"ON","op1type":"nul","op2type":"str","duration":"60","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":450,"y":560,"wires":[["cde0d496.d916f8"]]}]

3 Likes

thanks, thanks

Dave, I don't often use trigger node & that shows in my (albeit working) demo.

But one thing that always amazes me - the flexibility of node-red. :+1:

1 Like

Hi, all!
This shows us: Yes, the learning curve is flat at the beginning. Jeez, it looks so easy! So colourful. So nice! So intuitive.
But: It is extremely difficult to discover the real power and potential of the in-built nodes when facing a problem you want to solve using these nodes. The curve becomes so steep. An easy looking problem becomes virtually insurmountable.
Oh yes, once you are willing to "javascript" you can put it all in a function node. But this hides the inherent elegance of those nodes.
Or you quit.
What we need for beginners and not-so-beginner-anymore is more problem examples and their Node-RED solutions. Small problems. Some problems rather concrete, others of a more decoupled character wihout a problem "domain", propably popping up in different projects, contexts.
Yes, a trizillion of questions have been asked here before, answers given. No, they are not always easy to dig out.
The existing cook book is a start, needing further expansion.
Just my 2 cent.
Uwe

The existing cook book is a start, needing further expansion.

Did you ever look at this full playlist ? It covers many aspects of node-red and when to apply what.

Do you have a list of examples in mind ? Yes the cookbook is always looking to be extended... happy to take contributions and suggestions.

I completey overloked this little gem. There seems to be no linke on the website.
Yes, some answers are given, help to get the required insight.
Thanks for pointing this out.

It is in the documentation. (see: working with messages).

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