Having trouble getting the "Time" Restrictions without a Date to be respected in Piston


#1

1) Give a description of the problem
I’m having a problem getting my motion sensor to trigger a light switch when I only specific the “Time” range Restriction. When I specify both a “Date and Time” range Restriction it works as expected for that time frame.

2) What is the expected behaviour?
The piston should make the motion sensor trigger the light switch to turn on the light between the time of “7:00:00 PM” and “8:00:00 PM”

3) What is happening/not happening?
The piston does not work in having motion sensor turn on the light switch. Instead the light switch does not turn on. However, the piston does run successfully in having the motion sensor detect motion and turn on the light switch if I modify the Restriction to be both Date and Time …Between: 3/7/2020 7:00PM and 3/7/2020 8:00PM. Also, I see weird behavior if I attempt to specify the action light turning on to occur on only one Day of Week (i.e. Saturday). I won’t confuse that scenario with what I mentioned above but fyi - such a change only functions if I specify a large time range such as 2PM to 7PM even when it’s after 7PM.

**4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full
3/7/2020, 7:24:33 PM +176ms
+0ms ╔Received event [My home].time = 1583627074623 with a delay of -1447ms
+63ms ║RunTime Analysis CS > 33ms > PS > 5ms > PE > 25ms > CE
+66ms ║Runtime (38150 bytes) successfully initialized in 5ms (v0.3.110.20191009) (64ms)
+67ms ║╔Execution stage started
+82ms ║║Skipped execution of physical command [SYLVANIA SMART+ Smart Plug].off([]) because it would make no change to the device. (1ms)
+83ms ║║Executed [SYLVANIA SMART+ Smart Plug].off (3ms)
+85ms ║╚Execution stage complete. (19ms)
+86ms ╚Event processed successfully (86ms)
3/7/2020, 7:24:04 PM +558ms
+1ms ╔Received event [Motion Sensor 1].motion = inactive with a delay of 2237ms
+41ms ║RunTime Analysis CS > 14ms > PS > 4ms > PE > 23ms > CE
+44ms ║Runtime (38147 bytes) successfully initialized in 4ms (v0.3.110.20191009) (42ms)
+45ms ║╔Execution stage started
+53ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+54ms ║║Cancelling condition #2’s schedules…
+55ms ║║Condition #2 evaluated false (6ms)
+56ms ║║Cancelling condition #1’s schedules…
+57ms ║║Condition group #1 evaluated false (state changed) (8ms)
+59ms ║║Cancelling statement #13’s schedules…
+63ms ║║Executed virtual command [SYLVANIA SMART+ Smart Plug].wait (1ms)
+64ms ║║Requesting a wake up for Sat, Mar 7 2020 @ 4:24:34 PM PST (in 30.0s)
+68ms ║╚Execution stage complete. (24ms)
+70ms ║Setting up scheduled job for Sat, Mar 7 2020 @ 4:24:34 PM PST (in 29.996s)
+78ms ╚Event processed successfully (78ms)
3/7/2020, 7:23:46 PM +402ms
+1ms ╔Received event [Motion Sensor 1].motion = active with a delay of 150ms
+60ms ║RunTime Analysis CS > 21ms > PS > 6ms > PE > 33ms > CE
+62ms ║Runtime (38151 bytes) successfully initialized in 6ms (v0.3.110.20191009) (60ms)
+63ms ║╔Execution stage started
+71ms ║║Comparison (enum) active is (string) active = true (1ms)
+73ms ║║Cancelling condition #2’s schedules…
+74ms ║║Condition #2 evaluated true (6ms)
+75ms ║║Cancelling condition #1’s schedules…
+76ms ║║Condition group #1 evaluated true (state changed) (8ms)
+88ms ║║Comparison (time) 59026480 is_between (time) 68400000 … (time) 72000000 = false (8ms)
+90ms ║║Condition #15 evaluated false (11ms)
+91ms ║║Condition group #7 evaluated false (state did not change) (13ms)
+93ms ║╚Execution stage complete. (30ms)
+94ms ╚Event processed successfully (94ms)
3/7/2020, 7:23:28 PM +636ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+97ms ║╔Subscribing to devices…
+109ms ║║Subscribing to Motion Sensor 1.motion…
+137ms ║║Subscribing to SYLVANIA SMART+ Smart Plug…
+139ms ║╚Finished subscribing (49ms)
+162ms ║Comparison (enum) inactive is (string) active = false (1ms)
+179ms ║Comparison (time) 59008802 is_between (time) 68400000 … (time) 72000000 = false (9ms)
+181ms ║Cancelling condition #15’s schedules…
+182ms ║Cancelling condition #7’s schedules…
+191ms ╚Piston successfully started (191ms)


#2

Here is how I would do this:

IF Sensor's motion changes to active          <-- Trigger
Then
    IF $hour24 equals 19                      <-- Condition
    Then
        Turn on Switch 1
        Send SMS
    END IF
END IF

IF Sensor's motion stays inactive for 30 sec  <-- Trigger
Then
    Turn off Switch 1
END IF

Notice I changed “ONLY WHEN” into an “IF”, and changed your condition into a trigger
(and I used $hour24, which is a system variable)

This method will only turn on the light between 7pm and 7:59pm…
(the turn off works 24/7 with the current wording)


#3

on your post in the ST forum, you inquired about enabling trace …

above or below the piston in the same place where the test button is located. when you enable Trace, you will notice a change on the piston…more details show


#4

To elaborate a bit to @jkp’s post…

Sometimes on a new piston, you will not see the Trace button:

pic


In those cases, press Test first, and then you will be able to turn on Trace.

pic


Once Trace is turned on, the extra numbers in your green snapshot will align with the Condition #'s in your log. (As seen in this sample piston)


#5

This conversation has inspired me to create a new page on the Wiki covering Logs & Trace

(it’s a bit more detailed than my last post)


#6

You were correct about Trace not appearing until I pressed ‘Test’ but it was grayed out and didn’t stand out initially but yes I see it. However, I was able to fix my issue with @jkp suggestion on the ST forum to check my location. I responded there as well with info that SmartThings Connect and Classic SmartThings each had different locations and WebCore when setup had it’s time set manually which explains why it was confused. I even modified the Restriction to include “Saturdays only” and it worked. Thanks for sharing the details on “Trace” this should help with troubleshooting more complex pistons.


#7

I add the time restriction as a Condition. It’s never failed this way.

Here’s an example: Night light in kitchen at night (oven light is the bulb above the stove)
image

The trace is RED right now, because it’s not within the time restriction.