Turn light off after no motion, but not if it was manually turned on

This is a fairly common question, if you search the forum you will find a number of different approaches to it. Most recently, see the topic “baby sleeping” which addresses a similar issue but from the other side:

And for the exact same question as yours, here’s one approach:

1 Like