Jump to content

Simple Programming Question


arf1410

Recommended Posts

Unfortunately, I need help with what should be a simple program.  Currently, I have one program that turns on my outside lights at sunset, and a separate program that turns them off at 11 pm.  I could not seem to easily find a way to accomplish those two actions in a single program.  Is that possible?

Link to comment
16 minutes ago, arf1410 said:

Unfortunately, I need help with what should be a simple program.  Currently, I have one program that turns on my outside lights at sunset, and a separate program that turns them off at 11 pm.  I could not seem to easily find a way to accomplish those two actions in a single program.  Is that possible?

Yes,

If

Time is between sunset and 11 pm same day

then

turn on light

Else

turn off light

 

Link to comment
1 hour ago, arf1410 said:

Is that possible?

 

1 hour ago, Techman said:

Yes,

Most people new to the ISY don't think of using the "Between" condition.  I think this is because they want something to happen at sunset and something else to happen at 11pm, but they don't want anything to happen in between those times.  The reason "Between" works in this case is because the ISY has two types of conditions.  The first are "trigger" conditions and the second are "evaluation" conditions.  "Between" is both of those kinds of conditions.

A program will only ever run if it is triggered to run.  In the case of "Between" there are two triggers: sunset and 11pm.  So at sunset the THEN will run (unless there are more conditions in the IF) and at 11pm the ELSE will run.  At any time between those two, the program will not be triggered - so in this case if the program turns the light on at sunset and you turn it off at 8pm, the program will NOT be triggered to run and turn the light on again.

Once a program is triggered by a trigger condition, evaluation conditions will impact whether the THEN or ELSE is executed.  Integer variables are evaluation conditions.  Their value can impact whether the THEN or ELSE is executed, but a change in their value will not trigger the program in the first place.  "Between" is also an evaluation condition.  If some other trigger causes a program to run, a "Between" will impact whether the THEN or ELSE is executed.

Link to comment
On 1/7/2020 at 11:16 PM, kclenden said:

 

At any time between those two, the program will not be triggered - so in this case if the program turns the light on at sunset and you turn it off at 8pm, the program will NOT be triggered to run and turn the light on again.

 

 

Are you sure about it NOT being triggered again? I've got a program that runs a fan and I can't get it to stay off if I manually turn it off. I'm on 4.7.3 so maybe this "between" is a 5.x wording/process.

---------
Bonus-Fan 
If
        From    Sunrise +  1 hour 
        To      Sunset  +  4 hours  (same day)
    And Module 'Climate' Temperature > 75 °F
Then
        Set 'Bonus Fan' On
Else
        Set 'Bonus Fan' Off
---------

I needed the fan off to move things around and it kept turning on. I had to disable the program for it to stay off.  Perhaps my line with the temp was causing it to trigger, but I only want the fan on when it's warm outside.

 

 

Link to comment
31 minutes ago, arf1410 said:

I thought I had this working ... but at the moment, I can't even find the "between" option

and also not clear how this is different from sunset to 11 pm turn light on, else turn off

It's not different.  "Between" is just another way to refer to the "From/To" programming construct which allows you to accomplish you're initial goal - turning two programs into one.

Link to comment

OK, I think my 2 programs are cancelling each other out.  In addition from the light being on from Sunset to 11 PM, I also want it to be on from say 5 am to 30 minutes after sunrise... so if I use the logic suggested by Techman, the night program would turn the morning one off...

Link to comment

It would not as those are 2 different time slots. I'm assuming 2 different programs were written.

The lights would be off at 11pm. They would turn back on at 5am and off again after sunrise. There's no way for them to interfere with each other.

What's actually happening? Post your programs for us to see what you did

Link to comment
12 hours ago, arf1410 said:

OK, I think my 2 programs are cancelling each other out.  In addition from the light being on from Sunset to 11 PM, I also want it to be on from say 5 am to 30 minutes after sunrise

In fact, you could do ALL this in a single program:

if

from time is sunset to 11PM (same day)

or from time is 5AM to sunrise + 30min

then

turn on lights

else

turn off lights

 

Syntax is from memory and approximate so don't get to concerned if actual program looks a little different,.

Link to comment

Archived

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


×
×
  • Create New...