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.

If statement order

Featured Replies

Posted

Do we differentiate between when a KPL button was pressed, and just testing whether the button status is on/off by the order of the 'If' statements?

 

For example, I want to run an "all off" scene when my "Away" button is pressed on. Later, at sunset, I want to turn on another scene IF the away button is ON.

 

Program: Start Away Mode

If
       Control 'KPL@Office - Away' is On //same as below

Then
       Set  Scene 'All Off' Off

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

 

Program: Welcome Home

If
       Time is Sunset 
   And Control 'KPL@Office - Away' is On //same as above

Then
       Set  Scene 'Welcome Home Evening' On

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

 

 

Does the ORDER of the if statements determine what triggers the program to fire? So the first program will look for the Away button to be pressed. The second program will wait for Sunset ... at sunset, it will then move to the next condition and check the status of the Away button and continue (or not).

 

I understand that I can't control the status of a KPL button directly; the workaround is to place the button into a scene, and turn that scene on or off.

 

I guess I'm confused as to what exactly the KPL limitation is when making programs, and why we can't use both status and control events.

 

Thanks!

The order of the IF statements does not matter. In your second program, you should be testing the 'Status' of the button.

 

I think part of your confusion are the bugs in the current beta drop (not being able to test status of KPL, program true/false not set consistently). These have been fixed for the next drop.

 

In general though, I would use a folder condition instead.

 

Folder 'Away' - Allows programs in the folder to run if 'Keypad A' is pressed On, stops them from running when it is pressed 'Off'

Folder Conditions for 'Away'
Add conditions to limit when programs in this folder are allowed to run.

If
       Control 'Keypad A' is switched On
   And Control 'Keypad A' is not switched Off

Then
  Allow the programs in this folder to run.

 

Then just put your 'Welcome Home' program in your 'Away' folder

 

Program 'Welcome Home'

If 
       Time is Sunset 

Then 
       Set  Scene 'Welcome Home Evening' On 

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

  • Author
I think part of your confusion are the bugs in the current beta drop (not being able to test status of KPL, program true/false not set consistently). These have been fixed for the next drop.

 

You're right! Thanks for explanation! ... crystal clear!

 

~shawn

  • Author

except ...

 

Why are the two If statements necessary? If it is switched On, doesn't that inherently mean it is NOT switched Off?

Folder Conditions for 'Away'
Add conditions to limit when programs in this folder are allowed to run.

If
       Control 'Keypad A' is switched On
   And Control 'Keypad A' is not switched Off

Then
  Allow the programs in this folder to run.

Good Question!

 

The big change from 2.4.8 is that there are no longer inferred events. This is the primary reason for replacing 'Finally' with 'Else'.

 

The key here is that the true/false status, and whether a program runs (either the Then or the Else) is dependent on a recognized event.

 

For Controls and X10 messages, events must match exactly, meaning:

 

- For Controls, both the switch and value must match

- For X10 Messages, the house code/unit code and command must match.

 

The 'is not' allows you to test for the negative (i.e. false if the button is pressed)

 

Therefore the following program will only change state if 'Keypad A' is switched On, or switched Off. If you press 'Fast On' or 'Brighten' on 'Keypad A', the program will not change because these events are not relevant to the program.

 

If 
       Control 'Keypad A' is switched On  
   And Control 'Keypad A' is not switched Off 

 

FYI ... As discussed in another thread, if you explicitly run a program, its status becomes true. If you explicitly Run the else its status becomes false.

 

Not all of these changes are in the code drop you are using now; but they will be in the next code drop.

Create an account or sign in to comment

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.