Date Countdown


#21

Sounds great sir! Greatly appreciated!

Sorry, i did forget i changed the previous past dates to 2018. I moved them back and go the same results, except christmas is listed. here is the update below from the way you had it exactly.

10/4/2017, 10:23:59 PM +139ms
+1ms ╔Received event [Home].time = 1507181040000 with a delay of -862ms
+207ms ║RunTime Analysis CS > 23ms > PS > 75ms > PE > 109ms > CE
+331ms ║Runtime (42208 bytes) successfully initialized in 75ms (v0.2.0ec.20170927) (329ms)
+333ms ║╔Execution stage started
+358ms ║║Cancelling statement #8’s schedules…
+368ms ║║Executed virtual command setVariable (5ms)
+407ms ║║Comparison (date) 1483171200000 is_greater_than (date) 1507100400000 = false (4ms)
+410ms ║║Condition #19 evaluated false (24ms)
+413ms ║║Condition group #11 evaluated false (state did not change) (26ms)
+444ms ║║Comparison (date) 1499151600000 is_greater_than (date) 1507100400000 = false (4ms)
+448ms ║║Condition #19 evaluated false (16ms)
+450ms ║║Condition group #11 evaluated false (state did not change) (19ms)
+481ms ║║Comparison (date) 1514102400000 is_greater_than (date) 1507100400000 = true (4ms)
+484ms ║║Cancelling condition #19’s schedules…
+486ms ║║Condition #19 evaluated true (18ms)
+488ms ║║Cancelling condition #11’s schedules…
+490ms ║║Condition group #11 evaluated true (state changed) (24ms)
+495ms ║║Cancelling statement #12’s schedules…
+517ms ║║Calculating (date) 1514102400000 - (date) 1507100400000 >> (date) 7002000000
+526ms ║║Calculating (integer) -1649134592 % (integer) 86400000 >> (integer) -7534592
+534ms ║║Executed virtual command setVariable (3ms)
+546ms ║║Comparison (integer) 9999 is_greater_than (integer) -7534592 = true (2ms)
+549ms ║║Cancelling condition #18’s schedules…
+551ms ║║Condition #18 evaluated true (11ms)
+553ms ║║Cancelling condition #14’s schedules…
+555ms ║║Condition group #14 evaluated true (state changed) (16ms)
+560ms ║║Cancelling statement #15’s schedules…
+569ms ║║Executed virtual command setVariable (3ms)
+578ms ║║Executed virtual command setVariable (4ms)
+591ms ║║Cancelling statement #4’s schedules…
+609ms ║║Calculating (string) Guess What!?! There are + (string) -7534592 >> (string) Guess What!?! There are -7534592
+615ms ║║Calculating (string) Guess What!?! There are -7534592 + (string) days until >> (string) Guess What!?! There are -7534592 days until
+621ms ║║Calculating (string) Guess What!?! There are -7534592 days until + (string) Christmas >> (string) Guess What!?! There are -7534592 days until Christmas
+626ms ║║Calculating (string) Guess What!?! There are -7534592 days until Christmas + (string) !!! >> (string) Guess What!?! There are -7534592 days until Christmas!!!
+633ms ║║Guess What!?! There are -7534592 days until Christmas!!!
+635ms ║║Executed virtual command log (2ms)
+642ms ║╚Execution stage complete. (308ms)
+645ms ║Setting up scheduled job for Thu, Oct 5 2017 @ 10:24:00 PM PDT (in 86400.217s)
+666ms ╚Event processed successfully (665ms)


#22

try this. remember to hit the test button before the timer kicks in. (you need to do this once when you change dates, dateNames or numberOfHolidays. if you change the first two, remember to set numberOfHolidays to the right count of holidays.)


#23

Try this.


#24

Thanks @bangali! That worked and lead me in the right direction. I think I got it and starting to understand it now! I have updated it slightly to add the SMS notification as well. The SMS notification also gives an update how long until Christmas (since thats always a big countdown :slight_smile: It will be a little wierd after thanksgiving but i can always update the SMS output then and put it back on afterwards. Greatly appreciate your help!

Below is an example piston in case anyone else would like to use it.


#25

you are welcome. the whole purpose of that example piston was to get you started. i expect you to modify it from here, use send notification, formatduration, combine it with my holiday lights example piston, etc etc till i no longer recognize it as the example posted here. :slight_smile:


#26

Yes! Exactly what I did. One additional question though, I was going to make it send random messages so it wasnt always the same each day but it doesnt seem to want to send it. Is there anything I’m missing from the below or do you see anything that would cause it to not to send?

random("Guess What!?! There are " daysTo " days until " dateNameStore[whichDate] " and " int(((dateStore[3] - datetime($now)) / 86400000)) " days until " dateNameStore[3] “!!!”, “Uh oh! There are only” int(((dateStore[4] - datetime($now)) / 86400000)) " days until " dateNameStore[4] “!!!”, “It’s going by too fast! You have only” int(((dateStore[5] - datetime($now)) / 86400000)) " days until " dateNameStore[5] “!!!”)


#27

are you looking to randomize the holiday date you send the message or the message text or both or other?


#28

To start, i was looking to randomize the SMS message sent, that was what the above was. Then I was going to try to randomize the message sent with the random holidays listed. Below is piston with the random messages & logs.

0/5/2017, 3:01:18 PM +336ms
+1ms ╔Received event [Home].test = 1507240878326 with a delay of 9ms
+194ms ║RunTime Analysis CS > 21ms > PS > 58ms > PE > 113ms > CE
+209ms ║Runtime (47008 bytes) successfully initialized in 58ms (v0.2.0ec.20170927) (207ms)
+211ms ║╔Execution stage started
+253ms ║║Comparison (string) test is (string) test = true (2ms)
+255ms ║║Cancelling condition #2’s schedules…
+256ms ║║Condition #2 evaluated true (9ms)
+258ms ║║Cancelling condition #1’s schedules…
+259ms ║║Condition group #1 evaluated true (state changed) (12ms)
+277ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+291ms ║║Cancelling statement #27’s schedules…
+317ms ║║Executed virtual command setVariable (6ms)
+327ms ║║Executed virtual command setVariable (3ms)
+339ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+348ms ║║Cancelling statement #27’s schedules…
+360ms ║║Executed virtual command setVariable (4ms)
+370ms ║║Executed virtual command setVariable (3ms)
+381ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+389ms ║║Cancelling statement #27’s schedules…
+401ms ║║Executed virtual command setVariable (3ms)
+411ms ║║Executed virtual command setVariable (4ms)
+425ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+433ms ║║Cancelling statement #27’s schedules…
+446ms ║║Executed virtual command setVariable (5ms)
+456ms ║║Executed virtual command setVariable (4ms)
+470ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+479ms ║║Cancelling statement #27’s schedules…
+492ms ║║Executed virtual command setVariable (4ms)
+504ms ║║Executed virtual command setVariable (5ms)
+519ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+527ms ║║Cancelling statement #27’s schedules…
+540ms ║║Executed virtual command setVariable (5ms)
+550ms ║║Executed virtual command setVariable (3ms)
+564ms ║╚Execution stage complete. (354ms)
+569ms ║Setting up scheduled job for Fri, Oct 6 2017 @ 12:00:00 PM PDT (in 75521.099s)
+591ms ╚Event processed successfully (591ms)

Here are the logs of the event running but no SMS is sent.

10/5/2017, 3:06:59 PM +182ms
+1ms ╔Received event [Home].time = 1507241220000 with a delay of -819ms
+186ms ║RunTime Analysis CS > 18ms > PS > 59ms > PE > 110ms > CE
+201ms ║Runtime (47009 bytes) successfully initialized in 59ms (v0.2.0ec.20170927) (199ms)
+202ms ║╔Execution stage started
+237ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+263ms ║║Comparison (datetime) 1514790000000 is_greater_than (datetime) 1507241219439 = true (2ms)
+265ms ║║Cancelling condition #19’s schedules…
+267ms ║║Condition #19 evaluated true (18ms)
+268ms ║║Cancelling condition #11’s schedules…
+269ms ║║Condition group #11 evaluated true (state changed) (22ms)
+273ms ║║Cancelling statement #12’s schedules…
+289ms ║║Calculating (datetime) 1514790000000 - (datetime) 1507241219465 >> (datetime) 7548780535
+297ms ║║Calculating (decimal) 7.548780535E9 / (decimal) 8.64E7 >> (decimal) 87.37014508101852
+304ms ║║Executed virtual command setVariable (4ms)
+318ms ║║Comparison (integer) 9999 is_greater_than (integer) 87 = true (2ms)
+321ms ║║Condition #30 evaluated true (11ms)
+322ms ║║Condition group #14 evaluated true (state did not change) (13ms)
+326ms ║║Cancelling statement #15’s schedules…
+333ms ║║Executed virtual command setVariable (3ms)
+339ms ║║Executed virtual command setVariable (2ms)
+358ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+383ms ║║Comparison (datetime) 1530687600000 is_greater_than (datetime) 1507241219559 = true (3ms)
+385ms ║║Condition #19 evaluated true (17ms)
+387ms ║║Condition group #11 evaluated true (state did not change) (19ms)
+391ms ║║Cancelling statement #12’s schedules…
+407ms ║║Calculating (datetime) 1530687600000 - (datetime) 1507241219582 >> (datetime) 23446380418
+414ms ║║Calculating (decimal) 2.3446380418E10 / (decimal) 8.64E7 >> (decimal) 271.37014372685184
+422ms ║║Executed virtual command setVariable (3ms)
+433ms ║║Comparison (integer) 87 is_greater_than (integer) 271 = false (2ms)
+435ms ║║Cancelling condition #30’s schedules…
+436ms ║║Condition #30 evaluated false (9ms)
+438ms ║║Cancelling condition #14’s schedules…
+439ms ║║Condition group #14 evaluated false (state changed) (13ms)
+457ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+482ms ║║Comparison (datetime) 1509433200000 is_greater_than (datetime) 1507241219658 = true (3ms)
+484ms ║║Condition #19 evaluated true (16ms)
+486ms ║║Condition group #11 evaluated true (state did not change) (18ms)
+490ms ║║Cancelling statement #12’s schedules…
+505ms ║║Calculating (datetime) 1509433200000 - (datetime) 1507241219681 >> (datetime) 2191980319
+513ms ║║Calculating (decimal) 2.191980319E9 / (decimal) 8.64E7 >> (decimal) 25.37014258101852
+520ms ║║Executed virtual command setVariable (3ms)
+531ms ║║Comparison (integer) 87 is_greater_than (integer) 25 = true (2ms)
+534ms ║║Cancelling condition #30’s schedules…
+535ms ║║Condition #30 evaluated true (10ms)
+537ms ║║Cancelling condition #14’s schedules…
+538ms ║║Condition group #14 evaluated true (state changed) (12ms)
+542ms ║║Cancelling statement #15’s schedules…
+549ms ║║Executed virtual command setVariable (3ms)
+555ms ║║Executed virtual command setVariable (1ms)
+573ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+599ms ║║Comparison (datetime) 1514185200000 is_greater_than (datetime) 1507241219775 = true (3ms)
+601ms ║║Condition #19 evaluated true (16ms)
+603ms ║║Condition group #11 evaluated true (state did not change) (18ms)
+607ms ║║Cancelling statement #12’s schedules…
+622ms ║║Calculating (datetime) 1514185200000 - (datetime) 1507241219798 >> (datetime) 6943980202
+630ms ║║Calculating (decimal) 6.943980202E9 / (decimal) 8.64E7 >> (decimal) 80.37014122685186
+637ms ║║Executed virtual command setVariable (2ms)
+648ms ║║Comparison (integer) 25 is_greater_than (integer) 80 = false (2ms)
+650ms ║║Cancelling condition #30’s schedules…
+652ms ║║Condition #30 evaluated false (9ms)
+653ms ║║Cancelling condition #14’s schedules…
+654ms ║║Condition group #14 evaluated false (state changed) (13ms)
+672ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+697ms ║║Comparison (datetime) 1518332400000 is_greater_than (datetime) 1507241219873 = true (2ms)
+699ms ║║Condition #19 evaluated true (17ms)
+701ms ║║Condition group #11 evaluated true (state did not change) (18ms)
+705ms ║║Cancelling statement #12’s schedules…
+720ms ║║Calculating (datetime) 1518332400000 - (datetime) 1507241219896 >> (datetime) 11091180104
+728ms ║║Calculating (decimal) 1.1091180104E10 / (decimal) 8.64E7 >> (decimal) 128.3701400925926
+735ms ║║Executed virtual command setVariable (3ms)
+746ms ║║Comparison (integer) 25 is_greater_than (integer) 128 = false (2ms)
+748ms ║║Condition #30 evaluated false (8ms)
+750ms ║║Condition group #14 evaluated false (state did not change) (10ms)
+768ms ║║Calculating (integer) 6 - (integer) 1 >> (integer) 5
+792ms ║║Comparison (datetime) 1524294000000 is_greater_than (datetime) 1507241219969 = true (3ms)
+795ms ║║Condition #19 evaluated true (16ms)
+796ms ║║Condition group #11 evaluated true (state did not change) (19ms)
+800ms ║║Cancelling statement #12’s schedules…
+816ms ║║Calculating (datetime) 1524294000000 - (datetime) 1507241219991 >> (datetime) 17052780009
+824ms ║║Calculating (decimal) 1.7052780009E10 / (decimal) 8.64E7 >> (decimal) 197.37013899305555
+831ms ║║Executed virtual command setVariable (4ms)
+842ms ║║Comparison (integer) 25 is_greater_than (integer) 197 = false (3ms)
+844ms ║║Condition #30 evaluated false (8ms)
+846ms ║║Condition group #14 evaluated false (state did not change) (10ms)
+855ms ║║Cancelling statement #4’s schedules…
+874ms ║║Calculating (string) Guess What!?! There are + (string) 25 >> (string) Guess What!?! There are 25
+880ms ║║Calculating (string) Guess What!?! There are 25 + (string) days until >> (string) Guess What!?! There are 25 days until
+885ms ║║Calculating (string) Guess What!?! There are 25 days until + (string) Halloween >> (string) Guess What!?! There are 25 days until Halloween
+890ms ║║Calculating (string) Guess What!?! There are 25 days until Halloween + (string) !!! >> (string) Guess What!?! There are 25 days until Halloween!!!
+897ms ║║Guess What!?! There are 25 days until Halloween!!!
+898ms ║║Executed virtual command log (2ms)
+934ms ║║Executed virtual command sendSMSNotification (25ms)
+940ms ║╚Execution stage complete. (738ms)
+942ms ║Setting up scheduled job for Fri, Oct 6 2017 @ 3:07:00 PM PDT (in 86399.877s)
+962ms ╚Event processed successfully (962ms)


#29

random messages:

the same expression i have in the log info, you can use for the sms.


How to send random text messages from a list
How to send random text messages from a list
Question about Speaking Random Text with Variables
#30

Amazing! I’ll play with it a little more tonight. Thank you!


#31

So basically in this one they are setting only one random string at a time and then calling those random strings right? In my piston, I am using one random string and putting all the messages in it. It doesn’t seem to want to accept a variable {whoCameHome} in the string.


#32

use the format statement to assemble the string with the variable.

post a green snapshot.


#33

This is what I am using right now…


#34

format("%s is in the house!", whoCameHome)


#35

Is that for the Push notification? That seems to be working as is. The problem is if I condense the GET request to just one random bunch of texts and try to insert the variable {whoCameHome} in it instead of a name, it doesn’t work.


#36

yes. ok.

do you have an example of what was the exact format?


#37

random(“http://192.168.1.100:5005/sayall/Well look who is home! Hello big fella!/50”,“http://192.168.1.100:5005/sayall/Long time no see {whoCameHome}! Nice to have you back/50”,“http://192.168.1.100:5005/sayall/Well what a nice surprise {whoCameHome}! Nice to have you home/50”,“http://192.168.1.100:5005/sayall/Hey if it isn’t {whoCameHome}! How’s it goin?/50”,“http://192.168.1.100:5005/sayall/The Big Guy has arrived! Let’s hear it for {whoCameHome}!/50”)


Pushing notifications to LANNouncer
#38

try this:

format(random(“http://192.168.1.100:5005/sayall/Well look who is home! Hello big fella!/50”, “http://192.168.1.100:5005/sayall/Long time no see %s! Nice to have you back/50”, “http://192.168.1.100:5005/sayall/Well what a nice surprise %s! Nice to have you home/50”, “http://192.168.1.100:5005/sayall/Hey if it isn’t %s! How’s it goin?/50”, “http://192.168.1.100:5005/sayall/The Big Guy has arrived! Let’s hear it for %s!/50”), whoCameHome)


#39

I will try this, thank you!


#40

Tried this but no go…

random(“http://192.168.1.100:5005/sayall/Well look who is home! Hello big fella!/50”,“http://192.168.1.100:5005/sayall/Long time no see %s Nice to have you back/50”,“http://192.168.1.100:5005/sayall/Well what a nice surprise %s! Nice to have you home/50”,“http://192.168.1.100:5005/sayall/Hey if it isn’t %s! How’s it goin?/50”,“http://192.168.1.100:5005/sayall/The Big Guy has arrived! Let’s hear it for %s!/50”,“http://192.168.1.100:5005:sayall/Hooray, %s is home! Let’s celebrate!/50”), whoCameHome