Jump to content

Using Repeat vs Tail Recursion for my Away program...


Recommended Posts

Posted

I have a program that controls the bathroom light to make the place look lived in. I want it to repeat every 1.5 hours give or take while the condition of the parent "Away" folder is true.

 

Is there any harm in using tail-recursion to achieve this? Will memory fill up or does the new call to the program kill the last running instance? Here is the pseudo-code:

Program Content for "Away - Master Bath"
If
     - no conditions
Then
     Wait 90 minutes (Random)
     turn light on
     Wait 10 minutes (Random)
     turn light off
     Run Program "Away - Master Bath" (Then Path)
Else
     - no actions

 

I'm assuming that using a repeat is better, as follows, but I just wanted to understand mor fully how recursion works here.

Program Content for "Away - Master Bath"
If
     - no conditions
Then
     Repeat Every 0 seconds
           Wait 90 minutes (Random)
           turn light on
           Wait 10 minutes (Random)
           turn light off
Else
     - no actions

 

Thanks in advance for any insight.

 

OH, last question... is there a good way copy/paste code from the Admin interface? I had to type these examples in by hand. Just wondering.

 

Cheers,

Jeff

Posted

Jeff-

 

I don't believe there are any stack issues with this. I have something similar on my ISY and haven't had any problems. As for copy paste, right click the program name in the tree on the left, select Copy to Clipboard.

 

HTH

 

-Xathros

Guest
This topic is now closed to further replies.

×
×
  • Create New...