Node red flow logic

hello all

I am trying to improve this flow.

In my mind I would like to turn the light off when no presence is detected by the occupancy node.

Therefore in the current configuration the light turns off as long as presence is on and detected and this is fine for the most part

If i link the presence detection from the bottom button the light stays on and the counter does not run.

However if i set the state of the presence detection to off the light still remains on

I would like to turn the light off if no presence is detected for time X and if presence is detected the light stays on until no presence is detected for X minutes

am i doing something wrong?

Thank you for your advice in advance

Can you clarify the relationship between the “Motion” and the “Occupancy” nodes?

Nodes normally work when the underlying device changes state. So does the Occupancy sensor turn “on” when it detects presence, and become “off” when that presence is not there? If that’s the case, then I would think you’d want the link to go from the bottom connector on the Occupancy node (ie, the “off” state has been sensed) to the timer, and there to be no link between the upper connector and the timer.

Alternatively, within the Occupancy (“Current State”) node, you should be able to set the value “for 1 minute” and thus eliminate the need for your timer node.

Here’s how I do it.

The State Node: Utility Room PIR is on when it detects motion and off when it doesn’t.
PIR On, turns on the light
PIR Off starts a ten minute timer. At the end of the ten minutes, the light is turned off

The Alexa Home node in the middle (gray) is simply the interface from my Alexa devices.

The bottom state node just detects if the light is manually turned on or off.

The timer only turns the light off if it detects presence and you walk away for ten minutes.

Thank you both for your input.

I will try the suggested configurations from @PecosKidd first

@stevemann i like your concept of using switches I can see this as an improvement to my office automation where i have alexa

Once again thank you

Hello all

As suggested by @PecosKidd I modified my flow as follows


It does almost work. As long as i stay in the room the light remains on. When i leave the room (after the delay) the light turns off.

However if i leave the room (the timer starts) and then go re-enter the room before the timer expires the timer continues to countdown and the light turns off.
How can i stop the timer when i re-enter the room and start again when i leave?

I could ste a delay in the node however this would add IMOHO an additional point to manage, to forget and to screw up

Thank you once again for your help

I am not sure which timer node you are using from the images but it looks same as Stoptimer Varidelay that I use. Sending a payload of “stop” or “STOP” will stop the countdown timer. Therefore, send that payload from your sensors to timer when they detect motion/occupancy.

The payload to stop the timer is probably in the node’s documentation if “stop” or “STOP” don’t work.

Thank you @Stephenn

I have been trying with the following nodes

I usually use stoptimer. When i insert a stop in msg payload as a trying in my occupancy node It stops the timer alright but the timer does start when i enter the room again.

I set the delay in stop timer to 30 seconds (i’m using a stopwatch to measure). The stoptimer node shows "stopped

Nothing i do will make it start. A a new motion it should cause the display to show running.

Thank you for taking the time to respond and help me

I also tried the stoptimer2

There’s something still confusing to me here: why are you using both the Motion and Occupancy sensors? Could you remove the Motion sensor from this process and just use the Occupancy sensor? Lights On when Occupancy becomes “on”, and start your timer when Occupancy turns “off”?

(The confusion could just be my understanding of Occupancy sensors, since I don’t have any of these…)

Why are you using stop timer instead of the standard delay node? You can stop a held message by sending msg.reset set it it to true. You can also change the delay time by sending msg.delay with the delay time in milliseconds.

Hello all thank you for taking the time from your weekend.

@PecosKidd

one of the videos from @mostlychirs who mentioned that PIR has a more rapid response. This is why i use the motion sensor.
I use a multisensor from evrythingsmart it has an entity called occupancy and one call mwave sensor I tried both in my occupancy sensor node.

@Mikefila I was using a time delay with my zwave multi-sensors.
I got the esp32 sensors from evrythingsmart because after watching many videos i focused on the one from mostlychris.

He depicted my scenario i am aiming for.
The issue is when I use the msg payload and add “stop” to stoptimer node shows its’s status as “stopped” and no subsequent motion make that stoptimer node change status to running…
I was not aware that i could send to the delay node a msg.reset to stop
I will need to try this.

My main objective is to learn how can i re-enter the room once the stoptimer is running and cause the stoptimer to start the count from the beginning.

Thank you all for your patience and help

Hello all

just as an update, i would like to share with you all my lates solution.

Thank all for your contributions the following solution is almost perfect.


It works very well in all areas that have regular motion, such as office kitchen hall and stair wells/

However in my living room and media room where motion is limited i see as a solution to use a smart watch to detect a presence in these rooms. When the watch leave the room and after a few minutes the off trigger is activated.

I personally do not like shart watches and i do not always have my phone with me.
I hope this is the correct mode of thinking and i hope this helps someone.

Again thank you all for time off your busy schedules to help me with this issue.

I consider this issue closed for me

1 Like

Glad it’s working for you!
Here’s one other thought of an approach to this type of situation.

Hi @PecosKidd

Nice very logical and simple

Thank you