Bedroom door switch plus motion


#1

1) Give a description of the problem
The timer keeps re running and im unsure how to code it as the contact sensor stays closed.

2) What is the expected behaviour?
I would like to use variables in a piston to show “unknown, occupied and empty”

The reason for this is once the door closes (contact sensor) i would like the motion sensor to check for movement, to determine the status. Then it can make a decision about whether to turn the light off or leave it on.

3) What is happening/not happening?
(PUT YOUR INFO HERE)

4) Post a Green Snapshot of the pistonimage


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 do not understand your use for Status of “unknown”.
I would try the following…

IF Multipurpose Sensor closes    (the door closes)
  Then
  IF Bedroom Motion Sensor stays inactive for 2 minutes
    Then
      With Lights
        Turn Off
  END IF
END IF

#3

Some observations:

The restrictions (‘only when’) do not make the piston execute. They are tests applied when the piston has been fired. It is like surrounding the block they control with ‘if restrictions then … endif’, except the restrictions never cause the piston to subscribe to events as the triggers and conditions may do.

The timer (‘every’) operates outside the normal flow of the piston and that block will run every 30 seconds. The ‘only when’ in that position gets tested when the timer is started. So the timer fires every 30 seconds and either does nothing or sets the variable. It doesn’t check the restriction every time. Or something like that - I’ve not looked closely at the start up mechanism as you rarely see a restriction applied to a timer in that way (I’ve seen two on this forum this week but can’t recall ever seeing it before).

Your piston fires, meaning it runs top to bottom once, whenever the motion sensor changes state. Apart from the timer doing its thing every thirty seconds, that is it all it does automatically by itself.

To be honest, I’m not sure what you expect the flow of the piston to be. To me your piston reads more like it is trying to say ‘if and when X happens do Y’, when it needs to be saying ‘something has just happened, if it was X do Y’.