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.

Program with flags for conditions

Featured Replies

Posted

I'm trying to write a program (or set of programs) that will accomplish the following:

 

At 30 minutes after sunset (except on Halloween), check to see if I've already armed my security system, and if so, turn on one scene (set of lights). But if the security system is not yet armed, then turn on two scenes.

 

I am using my HAI OmniPro II (which unfortunately only talks X10) to transmit an X10 ON signal when I arm my security system, and an X10 OFF command when it is disarmed. I have a properly working ISY program that sets or clears a flag (enables or disables a program called "Security Night Flag") accordingly. I do a similar thing for detecting Halloween (October 31).

 

I couldn't think of a way to do this in one program, so I wrote two:

If
        Time is Sunset  + 30 minutes
   And Program 'Security Night Flag' is True
   And Program 'Halloween Flag' is False

Then
         Set Scene 'Outdoor Lights' On

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

If
        Time is Sunset  + 30 minutes
   And Program 'Security Night Flag' is False
   And Program 'Halloween Flag' is False

Then
         Set Scene 'Outdoor Lights' On
         Set scene 'Security Lights' On

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

 

My problem is that, every night at exactly 30 minutes past sunset, BOTH scenes get turned on regardless of the enabled/disabled state of 'Security Night Flag'. It all seems pretty straightforward to me. What am I missing? Or is my ISY-99 somehow malfunctioning?

I have a properly working ISY program that sets or clears a flag (enables or disables a program called "Security Night Flag") accordingly. I do a similar thing for detecting Halloween (October 31).

 

You should not be disabling the programs. Running Then turns the program True and running Else will set the program False. You don't need any actions in the program.

 

Rand

  • Author

I never actually run the programs called "Security Night Flag" or "Halloween Flag"- I only check to see if they are enabled (flag set) or disabled (flag not set).

 

The two programs/code samples in my post above are called, respectively, "30 Minutes After Sunset 1" and "30 Minutes After Sunset 2". They are NOT enabling and disabling themselves, if that's what you thought I was doing.

 

For example, here are the programs, called "Security Night On" and "Security Night Off", respectively, that I am using to set and clear the "Security Night Flag'

If 
         X10 'A13/On (3)' is Received

Then 
         Enable Program 'Security Night Flag'

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

If 
         X10 'A13/Off (11)' is Received

Then 
         Disable Program 'Security Night Flag'

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

 

Are you saying that I should not be using Enable and Disable, but rather, run them as Then or Else, as appropriate? Would this explain the malfunction that I am experiencing?

Hello dkaleita, I'm sorry if I was confusing.

 

When you check for True or False is does not matter if the programs are enabled or not. When your program sees the X10 command for the security system armed you should Run (Then) "Security Night Flag". When unarmed Run (Else) "Security Night Flag".

 

This will set the program True:

If        
           X10 'A1/On (3)' is Received

Then
       Run Program 'Security Night Flag' (Then Path)

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

 

This will set the program False:

If        
           X10 'A1/Off (11)' is Received

Then
       Run Program 'Security Night Flag' (Else Path)

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

 

You can check the status of the programs on the Program Summary page.

 

 

I never actually run the programs called "Security Night Flag" or "Halloween Flag"- I only check to see if they are enabled (flag set) or disabled (flag not set).

 

The two programs/code samples in my post above are called, respectively, "30 Minutes After Sunset 1" and "30 Minutes After Sunset 2". They are NOT enabling and disabling themselves, if that's what you thought I was doing.

 

Am I missing you point, or are you missing mine?

 

Some of each I think ;)

Rand

  • Author

Ah, I see! I guess I had a basic misunderstanding of how to implement a flag. I'll give it a try.

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.