Trouble with presence piston between times


#1

1) Give a description of the problem

Trying to get piston to fire based on a presence sensor arriving at certain time
2) What is the expected behavior?
I’d like a the foyer light to come on for a short time on the nights I work (my nights vary so it can’t be a specific set of nights)

3) What is happening/not happening?
Tested with virtual presence sensor and light does not come on.

**4) Post a Green Snapshot of the

5) Attach any logs (From ST IDE and by turning logging level to Full)

Toggle navigation

Back

Work

Script

///* Work *////* Author : Ryan // Created : 1/31/2019, 9:20:02 PM // Modified : 1/31/2019, 11:00:29 PM // Build : 4 // UI version : v0.3.109.20181207 *//**************************************************************/ execute

if

Test Presence’s presencechanges to present

and

(

{$time} is ‘After 22:00:00 PM’

and

{$time} is’Before 11:59:00 PM’

)

then

withFoyer Lightdo

Turn on;

Set level to 1%;

end with;

withFoyer Lightdo

Wait 1 hours;

Turn off;

end with;

end if;

end execute;

Logs

1/31/2019, 11:11:30 PM +476ms
+2ms ╔Received event [Test Presence].presence = present with a delay of 130ms
+90ms ║RunTime Analysis CS > 22ms > PS > 55ms > PE > 13ms > CE
+93ms ║Runtime (37949 bytes) successfully initialized in 55ms (v0.3.109.20181207) (90ms)
+94ms ║╔Execution stage started
+105ms ║║Comparison (enum) present changes_to (string) present = true (1ms)
+107ms ║║Cancelling condition #2’s schedules…
+109ms ║║Condition #2 evaluated true (7ms)
+116ms ║║Comparison (string) 11:11 P.M. is (string) After 22:00:00 PM = false (2ms)
+119ms ║║Condition #4 evaluated false (7ms)
+120ms ║║Condition group #3 evaluated false (state did not change) (10ms)
+121ms ║║Condition group #1 evaluated false (state did not change) (21ms)
+124ms ║╚Execution stage complete. (30ms)
+126ms ╚Event processed successfully (125ms)
1/31/2019, 11:11:26 PM +923ms
+2ms ╔Received event [Test Presence].presence = not present with a delay of 55ms
+77ms ║RunTime Analysis CS > 18ms > PS > 46ms > PE > 13ms > CE
+80ms ║Runtime (37947 bytes) successfully initialized in 46ms (v0.3.109.20181207) (77ms)
+81ms ║╔Execution stage started
+92ms ║║Comparison (enum) not present changes_to (string) present = false (1ms)
+94ms ║║Cancelling condition #2’s schedules…
+95ms ║║Condition #2 evaluated false (7ms)
+96ms ║║Condition group #1 evaluated false (state did not change) (9ms)
+99ms ║╚Execution stage complete. (18ms)
+101ms ╚Event processed successfully (100ms)

Clear

Full Nothing selected None Minimal Medium Full

Logging level

Variables

Local variables

(no variables defined)

Global variables

(no variables defined)

System variables

dynamic$argsnull

integer$day31

integer$dayOfWeek4

string$dayOfWeekNameThursday

device$deviceLocation

device$devicesLocation

integer$hour11

integer$hour2423

string$httpContentType

integer$httpStatusCode

boolean$httpStatusOk

integer$iftttStatusCode

boolean$iftttStatusOk

dynamic$incidentsnull

decimal$index

dynamic$jsonnull

datetime$localNow1548976349632

device$locationLocation

string$locationModeDisarm

integer$mediaSize0

string$meridianPM

string$meridianWithDotsP.M.

datetime$midnight1/31/2019, 12:00:00 AM

integer$minute12

integer$month1

string$monthNameJanuary

string$nameWork

datetime$nextMidnight2/1/2019, 12:00:00 AM

datetime$nextNoon2/1/2019, 12:00:00 PM

datetime$nextScheduledTimeInvalid Date

datetime$nextSunrise2/1/2019, 7:48:00 AM

datetime$nextSunset2/1/2019, 5:49:00 PM

dynamic$nflnull

datetime$noon1/31/2019, 12:00:00 PM

datetime$now1/31/2019, 11:12:29 PM

dynamic$placesnull

decimal$random0.9675935696335316

string$randomColor#DC143C

string$randomColorNameSandy Brown

integer$randomHue51

integer$randomLevel11

integer$randomSaturation93

dynamic$responsenull

integer$second29

boolean$shmTrippedfalse

string$state(not set)

datetime$sunrise1/31/2019, 7:48:00 AM

datetime$sunset1/31/2019, 5:49:00 PM

string$time11:12 P.M.

string$time2423:12

datetime$utc1548994349684

string$versionv0.3.109.20181207

dynamic$weathernull

integer$year2019

Evaluation Console

ValueExpression*REMOVE BELOW AFTER READING**
If a solution is found for your question then please mark the post as the solution.


#2

I am not sure if it matters, but it is a bit strange to see line 21 in military time (22:00PM) and yet line 23 is in standard time (11:59PM)

An alternative is to combine both of those lines into this instead:
IF $time24 is greater than 21

This will be true for the same time frame as you have in your code, yet it only uses one line.


#3

… also, anything after the Wait command will never fire because the trigger will no longer be true at that time.

This can be bypassed with “Task Cancellation Policy” set to never on the block with the Wait.


#4

Set level to 1%

I have never tried that but can you even see if the light is ON with 1%???


#5

Yeah I have it at 1 all the time when I get home, but have to manually trigger it. It lights the area fine too get around.


#6

I tried changing the time to $time24 and removing the end command completely and had no luck. I also tried a simple if presence sensor changes to present turn on foyer light and that worked. So I’m guessing the time thing is throwing it off for some reason


#7

@Osufnl49

I believe it’s not working because your TIME is two IFs and with AND
on the paper it looks like it should work but my guess is that’s the cause…(I am not great with webcore’s behind the scenes part:))))

I just wrote this and it works… Download it with the code if you like…


#8

And for the “wait” part you need to use NEVER CANCEL TASK as @WCmore mentioned.


#9

“NEVER CANCEL TASK” How would I go about doing this?