Jump to content

I need some help writing a simple timer


satwar

Recommended Posts

This is the logic for the "then" part to cycle the outlet on and off.  Every 35 minutes, while the program is running, it will turn the outlet on for 30 minutes, and then off again. At the 35 minute mark, it starts over.

 

I'm not sure what condition you would want to initiate the program, so I added a variable that would need to be set to one so the program runs. 

 

If
        $CycleOutlet = 1

Then
        Repeat Every  35 minutes 
           Set 'Outlet' On
           Wait  30 minutes 
           Set 'Outlet' Off

Else
   - No Actions - (To add one, press 'Action')

Link to comment

Another option...

 

Create a State Variable e.g., s.DaylightHours

 

two programs..

TimerTest_A - [ID 00D3][Parent 00CC]

If
        From    Sunrise
        To      Sunset  (same day)
 
Then
        $s.DayLightHours  = 1
 
Else
        $s.DayLightHours  = 0

TimerTest_B - [ID 00DA][Parent 00CC]

If
        $s.DayLightHours is 1
 
Then
        Repeat While $s.DayLightHours is 1
           Set 'Outlet Family Room' On
           Wait  30 minutes 
           Set 'Outlet Family Room' Off
           Wait  5 minutes 
 
Else
           Set 'Outlet Family Room' Off

I did this in firmware version 5.0.2 and believe the same options are available under other versions.

Not tested though :)

 

 

Jon...

Link to comment

Based on how its written, it will take 10 minutes for it to come back with a 25 minute wait (as opposed to 30). Its not running again after 10 minutes, or 35 minutes after starting the program?

Control - [ID 005D][Parent 005B]

If
        $Allow_to_Run is 1
 
Then
        Repeat Every  35 minutes 
           Set 'Main Bedroom / Bedroom Humidifier' On
           Wait  25 minutes 
           Set 'Main Bedroom / Bedroom Humidifier' Off
 
Else
   - No Actions - (To add one, press 'Action')
Link to comment

Is your condition "$Allow_to_Run is 1" still true?  I know it needs to be a State variable to trigger the program but I don't think it needs to be a State variable to continue running once started (the wait causes reevaluation of the condition.)

 

 

Jon...

Link to comment

Watch the program icons to see if it stays solid green. If it does then the Then section is still running. You may have to enable this feature from a pulldown menu in the Admin Console.

 

There is also a problem with the timing as given. After the 25 minutes of On you will have to wait another 35 minutes for the repeat Wait.

The ISY Repeat construct has a syntax error built into it.

Repeat ever 35 minutes  really means the equivalent of "Repeat with a 35 minute Wait". With a 25 minute Wait inside the loop, the total time would be 60 minutes.

Link to comment

I'm sorry, but this is just too hard for me to understand.  I can get the repeat command to work by specifying the number of repeats to perform.  Thanks for the offers of help.

Back to basics.

 

Control - [iD 005D][Parent 005B]

If

        $Allow_to_Run is 1

 

Then

        Repeat Every  5 minutes                      <---- "Every" is a syntax error. It's just another 5 minutes wait

           Set 'Main Bedroom / Bedroom Humidifier' On

           Wait  30 minutes                                <--- total loop time is now 35 minutes

           Set 'Main Bedroom / Bedroom Humidifier' Off

 

Else

   - No Actions - (To add one, press 'Action')

 

 

Now right click on the program name and select 'run then'

 

 

 

Here is a version using the Repeat x times construct you mentioned. This will give a fresh start again each day just after midnight.

Again you can jump start the program by right clicking the program and selecting "run then" from the pulldown menu.

 

If

   Time is 12:01 AM         <---- any time of day will do

 

Then

      Repeat 41 times        <---- runs just short of 24 hours

           Set 'Outlet' On

           Wait 30 minutes

           Set 'Outlet' Off

           Wait 5 minutes

 

Else

       - No Actions - (To add one, press 'Action')

 

 

Any better for you?

Link to comment

Yes I think I got it, thank you.  I never thought the REPEAT EVERY x MINUTES process would be so hard.

 

The REPEAT FOR x TIMES process is very clear and I built it correctly at first try.

Great!

 

Both of them have syntax errors in the wording as doesn't it doesn't match the value implied.

If you would have waited the 35 minute for the cycle to repeat you would have seen it happen.

Link to comment

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...