Missing something on this rule, it won't do what I need please help

Thanks in advance for any help.
I have a porch which I have a smart switch installed and I am now trying to automate it even further with two motion sensors. So if anyone steps into the motion sensors view the switch will turn on and turn off 45 seconds ( will be longer once I am done with the testing) later once sensors have been inactive.
It works OK if there is there is no movement after the sensors become inactive which takes about 30 for each and before the 45 seconds that the light switch is supposed to turn off, which it does.
The problem I have is that if any or both of the sensors continue to have motion beyond the 45 seconds the light switch is supposed to turn off the switch will never turn off, it continues on for hours even after there is no activity in any of the two sensors.
I have tried reading and made many changes but none have worked. Please any help would be greatly appreciated. Thanks
Hopefully the images below will display correctly.

@Luis_Gonzalez welcome to the community. It may be easer if you manage this automation with two rules so the logic can be simpler, and the “State Stays” condition should fit this situation well. See below:

Rule 1: Turn light on when motion is detected
Trigger: either motion is detected
Flow: if it’s before sunrise or after sunset, turn light on
(This rule is similar to your screenshot but no delay and no turning light off.)

Rule 2: Turn light off when both motion stayed inactive for 30 minutes.
Trigger: When either motion has stayed inactive for 30 minutes
Flow: If both(AND) motion sensors have stayed inactive for the past 30 minutes, turn the light off.


Thanks James,

Didn’t think of making two separate rules, now it makes more sense. I’ll try it tonight and see how it work and I will let you know.
thanks for you help.

1 Like

James just wanted to let you know that it worked great. I can use this same rule for the hallway.
Thank you so much for your help.