Condition if motion office was not active in last 5 minutes

Hello

I'm having trouble having this is as a condition. Trigger says state is on or off. But you cannot do: was not on for X minutes

What's the easiest way to do this ?

Thanks so much

Use the Current state node and Test every minute if it is active - then go into a loop using Node-red contrib counter - feed that to a switch node - if the count gets to 5 - then branch out to what you want to do if no motion for 5 minutes - the other branch can do nothing

Craig

1 Like

This is basically similar to your other question. Just use a trigger node set to send nothing. Wait x mins , extend if retriggeref, then send “I’m off” or whatever

That explanation helps heaps. Thanks you. Apologies for similar questions.

What do you set the send 1 and then send 1 to? 0 and 1?

Ah that is true false got it

I am struggling with the flow. I get his the trigger works but not sure how to apply to this use case

If dog is detected (sensor) and no persons were detected (sensor) In past five minutes then call http

Any ideas how to do that ? Would putting them both into a switch make sense?

Thank you

Please provide details so that we dont have to guess your intention and then have to re-work the solution offered...

For example...

  • What quantifies 5 minutes. From when? From last time MAN was seen? From last time DOG was seen? From when neither MAN nor DOG were seen? From when neither MAN nor DOG were seen plus 5 minutes?
  • What happens if DOG is detected once at 00:00 and no MAN seen for 30 mins - is the HTTP request triggered IMMEDIATELY or after 5 minutes?
  • What happens if DOG is detected 3 times at 00:30, 00:31, 00:33 and no MAN seen for 30 mins - is the HTTP request triggered 3 times?
  • What happens if DOG is detected at 01:00 and MAN is detected 5 secs later?
  • What happens if MAN is detected at 02:00 and DOG is detected 4.5 mins later?

hi Steve, apologies. really appreciate your help.

  • What quantifies 5 minutes. From when?
    from when the person sensor last saw a person (on)

From last time MAN was seen? yes

From last time DOG was seen? no

From when neither MAN nor DOG were seen? no just MAN
From when neither MAN nor DOG were seen plus 5 minutes? No just man plus 5 mins.

  • What happens if DOG is detected once at 00:00 and no MAN seen for 30 mins - is the HTTP request triggered IMMEDIATELY or after 5 minutes? it's triggered immediately

  • What happens if DOG is detected 3 times at 00:30, 00:31, 00:33 and no MAN seen for 30 mins - is the HTTP request triggered 3 times? yes

  • What happens if DOG is detected at 01:00 and MAN is detected 5 secs later? http would be triggered as no person detected in last 5 mins

  • What happens if MAN is detected at 02:00 and DOG is detected 4.5 mins later? http would be triggered at 2:00 as no persons detected in last 5 mins

@djseek my apologies, been a busy day.

Here is a simple solution (note I used 5 sec for demonstration purposes - you should change this to 5 minutes)

chrome_N0fyOd7qwC

Demo flow (use CTRL+I to import)...

[{"id":"8ddf5d1b6315f4bf","type":"inject","z":"15d3c7388dee8074","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"man-in-garden","payload":"true","payloadType":"bool","x":1230,"y":120,"wires":[["1bf043722dd9e724"]]},{"id":"c451af881cf0887e","type":"inject","z":"15d3c7388dee8074","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"dog-in-garden","payload":"true","payloadType":"bool","x":1230,"y":180,"wires":[["c995e4029b2925be"]]},{"id":"1bf043722dd9e724","type":"trigger","z":"15d3c7388dee8074","name":"","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"5","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1420,"y":120,"wires":[["4f68eb19e1bff359"]]},{"id":"c117fa45ad816b84","type":"debug","z":"15d3c7388dee8074","name":"Dog seen without person - call HTTP Request -->","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1510,"y":240,"wires":[]},{"id":"4f68eb19e1bff359","type":"change","z":"15d3c7388dee8074","name":"","rules":[{"t":"set","p":"seenMan","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1610,"y":120,"wires":[[]]},{"id":"c995e4029b2925be","type":"switch","z":"15d3c7388dee8074","name":"was no one detected recently?","property":"seenMan","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":1570,"y":180,"wires":[["c117fa45ad816b84"]]}]
1 Like

thank you very much. this is working.

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