Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Simple Programming Question

Featured Replies

Posted

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?

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

 

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.

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.

 

 

It's your temp causing it to turn back on. I'd have a secondary program that temporarily disabled your program if you manually turn it off

  • Author

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

Edited by arf1410

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.

  • Author

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...

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

Edited by lilyoyo1

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,.

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.