First piston attempt - Motion sensor, Time issue


#1

1) Give a description of the problem
Lights turning on at a time they shouldnt

2) What is the expected behavior?
Ive attempted to have set times for different actions to happen when motion is detected
1st instance should happen 30 mins before sunset with a set scene
2nd instance should change at 7pm to a random colour
3rd instance is for during the night with a set scene
4th should tell the piston to stop 30 mins after sunrise

3) What is happening/not happening?
Ive just finished setting it up and when i enter the room, its detecting motion and turning lights on. its currently 2:20pm so by how its set, there shouldnt be any action?

As the time hasnt been reached for the other actions to kick in im not able to say if theyre working as expected

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
24/03/2018, 14:23:06 +728ms
+1ms â•”Received event [Home].test = 1521901386728 with a delay of 0ms
+85ms â•‘RunTime Analysis CS > 17ms > PS > 30ms > PE > 38ms > CE
+89ms â•‘Runtime (41279 bytes) successfully initialized in 30ms (v0.2.102.20180116) (86ms)
+89ms â•‘â•”Execution stage started
+118ms â•‘â•‘Comparison (time) 51786822 is_before (datetime) 1521915840000 = true (3ms)
+119ms â•‘â•‘Time restriction check passed
+120ms â•‘â•‘Condition #10 evaluated true (27ms)
+121ms ║║Cancelling statement #10’s schedules…
+124ms â•‘â•‘Requesting time schedule wake up at Sat, Mar 24 2018 @ 5:54:00 PM GMT
+132ms â•‘â•‘Comparison (enum) inactive is (string) active = false (1ms)
+135ms â•‘â•‘Condition #8 evaluated false (9ms)
+136ms â•‘â•‘Condition group #2 evaluated false (state did not change) (42ms)
+138ms ║║Cancelling statement #3’s schedules…
+142ms â•‘â•‘Executed virtual command [Kitchen sink, Kitchen strip].wait (0ms)
+143ms â•‘â•‘Requesting a wake up for Sat, Mar 24 2018 @ 2:25:06 PM GMT (in 120.0s)
+148ms ║╚Execution stage complete. (59ms)
+150ms â•‘Setting up scheduled job for Sat, Mar 24 2018 @ 2:25:06 PM GMT (in 119.993s), with 4 more jobs pending
+160ms ╚Event processed successfully (160ms)

Thanks for any help and advice


#2

According to your piston, 2:20 pm is a time that the light should come on.

temp

(ie: if sunset is 7pm, then the lights would come on at motion anywhere from 12:01am to 6:30pm)

Perhaps you meant to write:
Time is AFTER 30 minutes to {$sunset}

This will turn on your lights with motion only during the evening time


#3

perfect! thanks alot for that

ive also noticed that the sensor seems less responsive than it was whilst using the hue app. i triggered it to turn on and stayed still in the room untill the 2 mins had passed then moved around and the sensor seemed to be unresponsive for a few minutes. is there any way to make it more responsive?

thanks again


#4

Using webcore you use cloudprocessing to manage your light. Using the hue hub/app the processing is local and you won’t be affected by slow internet.

Options are using the smart lighting app in smartthings and only use locally proccesed devices (see in IDE) or switch back to hue hub/app


#5

Back at work today so got to try the last part of the piston. Walked past the sensor around 5:20 and nothing happened :thinking:
Any ideas?


#6

I am by far not an expert at WebCoRe but I would think that you would need to have your conditions set up so that they read if “time is between” instead of “after”.


#7

I get what your saying but my thoughts behind it was that “if time is 30 minutes after sunrise” then that would mean the lights would still be active until sunrise + 30 mins and then stay off until the next scheduled time


#8

Not sure about your location, but here, the sun sets at about 7:10pm…
So if your code says:

Time is AFTER 30 minutes to {$sunset}
and
Motion Sensor 1’s motion is active
then
Turn on RGB Bulb

I would not expect the light to come on until AFTER about 6:40pm.
(30 minutes before sunset) Of course, depending on your location, the sun can set at different times, but it might be worth checking what time it sets in your area.


#9

Ok. I use “between sunset and sunrise” in a couple pistons as well as a couple morning pistons that specify a beginning and ending time and haven’t had any time issues. I have had other issues but never time related using “in between”


#10

I like Oldcomputerwiz’s approach. I would likely make a small tweak to the code something like this:

temp

If the sunrise is 7am, and the sunset is 7pm, this piston would turn on the lights anytime there is motion detected between 6:30pm and 7:30am

Notice the first line says “Time is not between”


#11

The sunset works as expected. This morning was the first time I’d been up before sunrise since making the piston so I had no idea if that part of it was working or not.
Sunrise here was at 6:51 this morning so the piston should have still been in an active state until 7:21
Does the code look wrong or am I just getting a random error?


#12

Can you post a new green camera snapsnot please?


#13

i like the idea of using the if between command. would tidy it up nicely


#14

would it be because the start time (at the top of the piston) is sunset and the last “active” time is 23:30 - meaning that on the next day, its waiting for -30 mins to sunset before starting the piston up again?


#15

I would try the sample I gave 5 posts back at the beginning of your code. That should cover both sunset-30 and sunrise+30.

temp

If you don’t try that, then change line 75 to say:
Time is BEFORE 30 minutes past {$sunrise}

But I agree. The between sample here is more streamlined.


#16

Lovely stuff. I’ll give that a try and report back tomorrow to let you know how I get on.

Thanks alot for your help


#17

I just noticed that line 33 (Wait 30 secs) should be dragged one line up to be before the Turn off command


#18

nice spot

thats the updated piston. hopefully it’ll work nicely now


#19

A precaution using the system variables, $sunrise and $sunset — $sunrise and $sunset are today’s sunrise and sunset, respectively. After $sunset, and before midnight, they both are in the past. Just past midnight, both are in the future. So using a condition such as “between $sunset and $sunrise” (which span midnight) will not give you the results you’re expecting. In such cases, use the pre-defined variables for sunset and sunrise since they do not exhibit this behavior; “between sunset and sunrise” will evaluate correctly.

See @WCmore’s tweak above …


#20

TY. I wasn’t aware of that and is good to know.