Piston not functioning in specified time frame


#1

1) Give a description of the problem
The piston I have created to used a motion sensor to turn a light either on or off only during a specified time window at night is not working, but will work if I adjust the window to do testing.

2) What is the expected behaviour?
When a certain motion sensor detects activity and the time is between 12:01am (1 minute after midnight) and 6:00am a light will be turned on or off.

3) What is happening/not happening?
The routine does nothing even though the motion sensor is detecting activity.

To do testing, if I change the time frame to something like 10:00am to 1:00pm the piston works fine.

4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
No logs at this time

REMOVE BELOW AFTER READING


#2

Hi,

I think having two triggers on the same device within one piston will cause unpredictable results.

Try just having the if on one trigger, then within the if have two ifs checking your other conditions.

i.e add a new if at line 17 on motion sensor 4 changes to active, and include the existing ifs in there, removing the part that checks the motion sensor from the current if statements.


#3

I will try your recommendation, but my question would be “Why does the original piston work if I change the times to daylight hours, but not in the middle of the night?”


#4

The piston runs when the motion sensor changes state. If it has changed to active when the dimmer is off during certain hours, it will turn it on at a low dim setting. Then it will immediately turn it off again?


#5

Your summarization is close except for the last line. That might be what is happening at night (shrugs), but when testing during the day when the motion sensor changes to active it looks at the switch state, make the appropriate adjustment and then exits. If the switch is off, turn on, then exit. If the switch is on, turn off, then exit.


#6

It actually runs top to bottom at each change in the motion sensor.
(IE: It does not process half of the code and exit)


#7

The motion trigger conditions are both ‘changes to active’ so they will both be true if motion goes active. If the switch is off the first if-then turns it on at a low level. Whether it gets immediately turned off again by the next if-then depends on whether the switch attributes have been updated when the piston checks them. That seems to have the potential for a bit of a race condition. Maybe time of day could affect it as things might be busier during the day and slow things down. Logs would be diagnostic.

I assume there aren’t any other factors at play?Like the dimmer already being on at 12% or greater at midnight so the cycle never starts.


#8

I would probably reduce it to a single trigger… Maybe something like this:

IF Sensor's motion changes to active
   and 
   Time is between X & Y
   Then
      IF Dimmer 4 is off
      Then
         Turn on
      ELSE
         IF Level is less than 12%
         Then
            Turn off
         END IF
      END IF
END IF

Note there are three nested IFs here… with only the second one using ELSE.


#9

This is the piston I created based off of the recommendations I received. It was in place last night and appeared to have worked. Thanks everyone for their help.