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 program problem

Featured Replies

Posted

If

$GarageDoorSensor is 1

And From Sunset + 15 minutes

To Sunrise (next day)

Then

Set 'Garage Exterior Light' On

Wait 1 minute

Set 'Garage Exterior Light' Off

Else

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

 

The 'Garage Exterior Light' turns on properly when $GarageDoorSensor variable is set to 1 but does not turn off after 1 minute.

 

Any idea why ?

The State variable is changing value before the Wait 1 minute completes. This causes the If to be reevaluated as False driving the Else clause so statements after the Wait are not executed.

  • Author

Yes - the state variable does change back to 0 before the 1 minute is up.

I would have thought that the Wait 1 Minute would prevent the program from reevaluating the IF.

 

How would I go about getting the desired behaviour ?

Any time a clause has a Wait or Repeat statement the If can be reevaluated. The UDI Wiki has an excellent explanation of how Repeat and Wait statements can affect execution of statements after the wait or Repeat.

 

One solution is to change the State variable in the Then clause

 

If

$GarageDoorSensor is 1

And From Sunset + 15 minutes

To Sunrise (next day)

Then

Set 'Garage Exterior Light' On

Wait 1 minute

Set 'Garage Exterior Light' Off

$GarageDoorSensor is 0

Else

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

 

Another solution is to move the Then logic to a second Program that has no If section. The current Program calls the second Program to perform the logic. The first Program cannot be reevaluated because there is no Wait. Even if it is reevaluated to False it does not affect the second Program.

  • Author

Thanks so much - I will give that 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.