newpixelwheelhouse Posted January 14, 2020 Posted January 14, 2020 (edited) TLDR: My MotionTimer program isn't turning off my staircase lights scene after the motion sensors have sent off signals. Background: I have a virtual 3 way switch that controls my staircase lights via a scene: sStairsLights. The "Stairs_Lights_Load" dimmer switch carries the load physically to the light The "Stairs_Lights_Remote" is configured to remotely turn on/off the scene. sStairsLights I have two motion sensors (top of staircase landing & bottom of staircase) that are programmed to turn on/off the sStairsLights, UNLESS either dimmer switch is physically switched on. If either switch is switched on and not switched off, the motion programs are disabled so the lights stay on until either switch is switched off, at which point the motion programs are enabled again. This is done via a few motion timer enabler programs ("pStairs_MotionTimer_Enable" and "pStairs_MotionTimer_Enable/Disable"), which in turn enable/disable the folder "enabler" containing the "pStairs_MotionOn" and "pStairs_MotionTimer" programs: pStairs_MotionTimer_Enable pStairs_MotionTimer_Enable - [ID 001C][Parent 0006][Not Enabled][Run At Startup] If - No Conditions - (To add one, press 'Schedule' or 'Condition') Then Set Program 'pStairs_MotionTimer_Enable' To Run At Startup Else Set Program 'pStairs_MotionTimer_Enable' To Not Run At Startup pStairs_MotionTimer_Enable/Disable pStairs_MotionTimer_Enable/Disable - [ID 001A][Parent 0006] If ( 'Inside / Stairs / Stairs_Lights_Load' is switched On Or 'Inside / Stairs / Stairs_Lights_Remote' is switched On ) And ( 'Inside / Stairs / Stairs_Lights_Load' is not switched Off And 'Inside / Stairs / Stairs_Lights_Remote' is not switched Off ) Then Run Program 'pStairs_MotionTimer_Enable' (Else Path) Else Run Program 'pStairs_MotionTimer_Enable' (Then Path) FOLDER: enabler enabler - [ID 001D][Parent 0006] Folder Conditions for 'enabler' If Program 'pStairs_MotionTimer_Enable' is True Then Allow the programs in this folder to run. pStairs_MotionOn pStairs_MotionOn - [ID 0016][Parent 001D] If 'Inside / Stairs / _Sensor_Motion' is switched On Or 'Inside / Stairs / Staircase_Sensor_Motion' is switched On And 'Inside / Stairs / Stairs_Lights_Load' Status is Off Then Set 'Inside / Stairs / sStairsLights' On Else - No Actions - (To add one, press 'Action') pStairs_MotionTimer pStairs_MotionTimer - [ID 0019][Parent 001D] If 'Inside / Stairs / _Sensor_Motion' is switched Off Or 'Inside / Stairs / Staircase_Sensor_Motion' is switched Off And 'Inside / Stairs / Staircase_Sensor_Motion' Status is Off And 'Inside / Stairs / _Sensor_Motion' Status is Off Then Wait 5 seconds Set 'Inside / Stairs / sStairsLights' Off Else - No Actions - (To add one, press 'Action') Everything works up until this last "pStairs_MotionTimer" program that's supposed to turn off the scene. It's set so that once the motion sensors send the OFF signal after the 30 second timeout, the program waits 5 seconds before turning the scene off. I can't figure out what's incorrect in my syntax but I have the lights successfully turning on when motion is sensed, but I cannot get them to turn off. Under the program summary view, I can see the pStairs_MotionOn program runs when motion is sensed, and then 30 second later I can see the pStairs_MotionTimer has run but the lights don't turn off. Any idea what I've done wrong? Thank you! Edited January 14, 2020 by newpixelwheelhouse
oberkc Posted January 14, 2020 Posted January 14, 2020 58 minutes ago, newpixelwheelhouse said: It's set so that once the motion sensors send the OFF signal after the 30 second timeout, the program waits 5 seconds before turning the scene off. No, it isn't. It's set so that once one of the motion sensors OR the other sensor AND...AND... Are the two sensors close by? Are they typically triggered within seconds of each other? It seems to me that this set of conditions runs the risk that could run FALSE (else path) pretty regularly, including an interruption of the 5-second wait. My concern is that this is more complicated than it needs to be and introduces unexpected results. For your upstairs motion timer program, why not: if 'Inside / Stairs / _Sensor_Motion' status is Off and 'Inside / Stairs / Staircase_Sensor_Motion' status is Off then same else same 1
newpixelwheelhouse Posted January 15, 2020 Author Posted January 15, 2020 4 hours ago, oberkc said: No, it isn't. It's set so that once one of the motion sensors OR the other sensor AND...AND... Are the two sensors close by? Are they typically triggered within seconds of each other? It seems to me that this set of conditions runs the risk that could run FALSE (else path) pretty regularly, including an interruption of the 5-second wait. My concern is that this is more complicated than it needs to be and introduces unexpected results. For your upstairs motion timer program, why not: if 'Inside / Stairs / _Sensor_Motion' status is Off and 'Inside / Stairs / Staircase_Sensor_Motion' status is Off then same else same I was under the impression that a "control" trigger needs to be in the if statement in order to trigger the program to run. That's why I had the "if either switch is switched off" part in addition to both sensors' status is off, then timer > turn off. Thank you very much, this appears to solve my issue!
oberkc Posted January 15, 2020 Posted January 15, 2020 23 minutes ago, newpixelwheelhouse said: I was under the impression that a "control" trigger needs to be in the if statement in order to trigger the program to run. No. While "control" conditions will trigger a program, so will most other conditions, including "status" conditions. The real question is WHEN will a condition trigger a program. 1
oberkc Posted January 15, 2020 Posted January 15, 2020 (edited) 29 minutes ago, newpixelwheelhouse said: That's why I had the "if either switch is switched off" Make sure you understand the priorities of the logical conditions "and" and "or". Because of those priorities, the logic would evaluate as (parentheses added for explanation purposes): ('Inside / Stairs / _Sensor_Motion' is switched Off) Or ('Inside / Stairs / Staircase_Sensor_Motion' is switched Off And 'Inside / Stairs / Staircase_Sensor_Motion' Status is Off And 'Inside / Stairs / _Sensor_Motion' Status is Off) It is not unlike a math problem such as 3+2*4*4. Is the answer 96? Is the answer 35? Something else? In logic, like math, some operations occur before others. Edited January 15, 2020 by oberkc 1
newpixelwheelhouse Posted January 15, 2020 Author Posted January 15, 2020 19 minutes ago, oberkc said: Make sure you understand the priorities of the logical conditions "and" and "or". Because of those priorities, the logic would evaluate as (parentheses added for explanation purposes): ('Inside / Stairs / _Sensor_Motion' is switched Off) Or ('Inside / Stairs / Staircase_Sensor_Motion' is switched Off And 'Inside / Stairs / Staircase_Sensor_Motion' Status is Off And 'Inside / Stairs / _Sensor_Motion' Status is Off) It is not unlike a math problem such as 3+2*4*4. Is the answer 96? Is the answer 35? Something else? In logic, like math, some operations occur before others. I see, this will definitely help me figure out some other issues I'm running into on my own before coming back to the forums for help. Much appreciated!
Recommended Posts