Good night if no motion


#1

1) Give a description of the problem
Hi, i know i’m over complicating this but i’ve hit the wall through lack of experience. I want my goodnight switch to operate if there has been no motion for the last 30 minutes @ 10:45PM, or later if we’re still awake. However if there has been motion in the last 30 mins, then i want the timeline to keep rolling after 22:45 until there is a point of no motion for 30 minutes. eg, no motion for 30 min @ 23:57.

I don’t want to use a repeat timer because the piston will keep operating after the condition is met.
i’ve tried repeat loops but i think i’ve set it up wrong. Any help would be great. if you can doctor my piston and supply a code, that would be fabulous thanks

2) What is the expected behaviour?
A repeat loop keeps running until the last inactive motion was 30 minutes ago. Any time after 10:45 PM and beyond

3) What is happening/not happening?
i cant get my repeat loop to keep running until the Condition is met. i think i’m quite a way off the mark. Please can you assist in adding to my piston and retuning a new import code. Many thanks :slight_smile:

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

I think you have to attack this from both angles…
(two triggers, one time based, and one motion based)

IF Sensor's motion stays inactive for 30 min  <-- Trigger
   and
   Time is not between 6AM and 10:44PM        <-- Condition
      Then run Good Night
END IF

Every day at 10:45PM                          <-- Trigger
do
   IF Sensor's motion is inactive             <-- Condition
      and
      Time is after last event +30min         <-- Condition
         Then run Good Night
   END IF
END EVERY

Note: The 1 min difference between blocks is intentional


#3

Thanks @wcmore. Yes, I did overcomplicate it! For some reason I thought that an inactive motion sensor after x time wouldn’t work as a trigger, silly me! :slightly_smiling_face: