Run a node-red flow only once per day

I have a flow that activates a “Good Morning” scene when it detects motion. How can I prevent this flow from running every time it sees motion? I just want it to run the first time it sees the motion and then do nothing for the rest of the day.

Use the “limit” in the “delay” node. limit to 1 message a day or other.

4 Likes

yes, either this or setting an input_boolean (which is reset in the night) and checking if it was already set when motion is detected.

2 Likes

Thanks! This looks like exactly what I need, I missed the “rate limit” setting in the drop down when I first looked at it.

Mark “solution” :slight_smile:

You can do that without additional sensor nor flow variable.
Just trigger event at midnight (or maybe at 4am or when you go sleep)) then use wait node configured to react on your sensor

I don’t see the “solution” box for some reason!

Don’t forget to enable the option that says “drop intermediate messages”.

1 Like

You should, you are the OP.

I applied this also (see picture) and in my case what it did is this.
If for example today I wake up at 09:00 and tomorrow at 10:00, then it would work. But if tomorrow I wake up at 08:00, it doesn’t work. I guess bcs 24 hours (1 day) has been completed since last trigger.
Now I am going to limit it into 12 hours per day and also put a restriction on the time before that.Capture

2 Likes

You can do like this:

[{"id":"25dd64e2.d6d4ac","type":"function","z":"7129ee98.085df","name":"Payload = reset","func":"msg.payload = \"reset\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":2120,"wires":[["98182de1.98ce8"]]},{"id":"4d5d0e17.8d759","type":"inject","z":"7129ee98.085df","name":"Manual reset trigger & block node","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":2120,"wires":[["25dd64e2.d6d4ac"]]},{"id":"98182de1.98ce8","type":"trigger","z":"7129ee98.085df","name":"","op1":"","op2":"0","op1type":"date","op2type":"str","duration":"0","extend":false,"units":"ms","reset":"reset","bytopic":"all","topic":"topic","outputs":1,"x":540,"y":2240,"wires":[["a5895ba1.b49158"]]},{"id":"1520ef5f.a40c71","type":"trigger-state","z":"7129ee98.085df","name":"","server":"4bbca37b.1700ec","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"motion_sensor","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":280,"y":2240,"wires":[["98182de1.98ce8"],[]]},{"id":"a5895ba1.b49158","type":"api-call-service","z":"7129ee98.085df","name":"Do TTS  and all other good morning routines","server":"4bbca37b.1700ec","version":1,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":850,"y":2240,"wires":[[]]},{"id":"4bbca37b.1700ec","type":"server","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

This will trigger each night at 00:00 and reset the trigger and block node.
And if there is a motion detected after 00:00 then the message will go past the trigger and block and do the TTS.

(you can customize the inject node time if you don’t want the message to speak in the middle of the night)

You can actually remove the function node and make the inject node inject string “reset” also.

3 Likes