*New to Webcore* Creating a Piston Timer and General Qs


#1

Hey All,

Thank you in advance for any help anyone can provide. I am new to Webcore and the ST community, and have been spending a lot of time researching on this forum, but haven’t yet been able to solve the issue I am having, nor find complete information on a few of my questions. My brain works a bit like a computer, and if I become hung up on something (even if its basic :relaxed: ) I can’t move on. ha.

Anyways, here are my questions/issue I am running into:

Questions:

  1. From my research it seems WebCore uses a number of programming languages. What I am hoping to find is more information on how the different functions work, their syntax, etc. Is there a comprehensive list anywhere? I know the Wiki has some information, but was hoping to dig more in depth. Are these functions from a library that is commonly used in a programming language, i.e. Java, Shell Script, Groovy, etc, where I can read more into the functions? I am an EE, but don’t have a lot of in depth programming knowledge with the above languages, but can spend the time to learn it if I have a general direction to go in.

  2. I am looking for more information on how to use the time() function, and the related datetime variables $now, $minute, $second, etc.

  3. Is there a good function to use for a timer (see below)? :slight_smile:

Issue:

I am trying to do something pretty simple, which is when the virtual status changes from Away to Home, to start a timer. If while this timer has not expired and I open my door, the contact sensor will trigger enabling some lights. The problem I am having here is implementing a timer, the rest I can do. Here is some test code I generated to try and debug the issue I am having.

When running this routine, I come across this issue (bolded below):

1/4/2018, 11:42:31 AM +507ms
+0ms ╔Received event [Home].routineExecuted = acf79887-7969-4a6f-b97b-82b8c92afdb7 with a delay of 38ms
+73ms ║RunTime Analysis CS > 10ms > PS > 42ms > PE > 22ms > CE
+75ms ║Runtime (38190 bytes) successfully initialized in 42ms (v0.2.100.20171211) (74ms)
+76ms ║╔Execution stage started
+83ms ║║Comparison (string) :79a59b304b237699dd658e01dfd4bee9: executes (string) :79a59b304b237699dd658e01dfd4bee9: = true (2ms)
+84ms ║║Cancelling condition #2’s schedules…
+85ms ║║Condition #2 evaluated true (4ms)
+85ms ║║Cancelling condition #1’s schedules…
+86ms ║║Condition group #1 evaluated true (state changed) (6ms)
+88ms ║║Cancelling statement #3’s schedules…
+93ms ║║Executed virtual command setVariable (1ms)
+100ms ║║Calculating (datetime) 1515094951597 + (integer) 1000 >> (datetime) 1515094952597
+103ms ║║Comparison (datetime) 1515094951603 is_between (datetime) 1515094951597 … (datetime) 1515094952597 = false (2ms)
+104ms ║║Condition #12 evaluated false (9ms)
+105ms ║║Condition group #6 evaluated false (state did not change) (10ms)
+107ms ║╚Execution stage complete. (31ms)
+108ms ╚Event processed successfully (108ms)

This is probably not the best way to generate a timer, or add time to an epoch time, but I honestly don’t know how else to do it. Any guidance here is appreciated. The real issue is the comparison false when …1603 is clearly between …1597 and …2597, so this method wont work. Any and all help is appreciated here!! Thanks!!!


#2

Probably doesn’t matter, but noticed that the const is not also set as time($now). The between evaluation being false is interesting — same behavior with an IF statement right?

Would a WAIT task suffice for the use case? I’m new here also and unable to answer any of the other questions.


#3

First off welcome!

The wiki is your friend here. The only more in depth place would be looking at the actual code, which you can do from the IDE. To try and give more info, the functions are a hodgepodge of several different languages configured to work with webcore/smartthings.

Is there something specific that you are trying to figure out about the functions that isn’t covered in the wiki?

Skipping this because I read ahead and this isn’t what you are looking for.

If mode changes to home
Followed by 
Contact sensor changes to open within xx time
Then 
Turn on some lights
End if

To create the above in webcore you need to add the two statements like above. Make sure they are in this order. When you add these they will default with and between them. Click on and and change it to followed by. After saving that you can now edit your second statement to make changes to the amount of time for it to happen.

Alternatively what @kevireilly suggested could also be made to work with some finesse but the followed by statement was made for this use case.