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.

Quick programming question

Featured Replies

Posted

I am running 2.8.16 on an XP machine. I want to turn off a light in the house when the garage door sensor goes to OPEN. I can't figure out how to do this. It would be simple if I could put a CONDITION in the THEN statement, but it looks like I can't do that. Am I missing something obvious? Any suggestions would be appreciated.

 

TIA- Jim

I would do this via program:

 

if
control "garage door sensor" is set on

then
turn "light in the house" off

else

 

Actual code wording may vary, but I trust the logic is clear.

  • Author

A little more detail on what I am trying to do. Here is my present code, on select days of the week turn a light on at 5:40am. Instead of turning the light off after 30 minutes, I want to turn it off when the garage door sensor indicates the door has been opened. What you see is about the limit of my very basic code writing ability.

 

If
       On Mon, Wed, Thu
       Time is  5:40:00AM

Then
       Set 'LR Table Lamp' On
       Wait  30 minutes 
       Set 'LR Table Lamp' Off

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

A little more detail on what I am trying to do.

 

Is the "little more detail" the same as "all the rest of the detail"?

 

Perhaps it best to describe, in english (as opposed to a program example) what you want to accomplish. For example:

 

a. table lamp to come on at 0540 on mondays, wednesdays, and fridays.

b. table lamp to remain on until garage door is open, or 2 hours after sunset, whichever comes first.

 

Is this it? Assuming so, change your first program to:

 

If
       On Mon, Wed, Thu
       Time is  5:40:00AM

Then
       Set 'LR Table Lamp' On

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

 

Create a second program...as I suggested earlier, modified:

 

If
       control garage door sensor is set on
or
       time is sunrise + 2 hours
Then
              Set 'LR Table Lamp' Off

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

Here is anoter take on it.

 

You need a global state variable "WakeupState" with an initial value of 0. Modify your first program as below:

 

If
       On Mon, Wed, Thu
       Time is  5:40:00AM

Then
       $WakeupState = 1
       Set 'LR Table Lamp' On
       Wait  30 minutes 
       Set 'LR Table Lamp' Off
       $WakeupState = 0

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

Now, add a second program:

 

If
       Control 'Garage Door Sensor' is switched on
And     $WakeupState is not 0

Then
       Set 'LR Table Lamp' Off
       $WakeupState = 0

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

 

Good luck!

  • Author

Thank you for the ideas, I appreciate it. I was hoping to be able to do it in one program, I am going to experiment with all suggestions.

Thanks again.

You'll need to upgrade to v3 of the firmware to experiment with variables. Alternatively in v2 you can use programs as (binary) variables (true or false)

 

 

Sent from my iPod touch using Tapatalk

Oops, sorry. Didn't see the 2.8.16 in the first post. Just change every "$WakeupState = 1" to "Run Program 'WakeupState' (Then Path)," "$WakeupState = 0" to "Program Program 'WakeupState' (Else Path)," and "$WakeupState is not 0" to "Program 'WakeupState' is not False."

  • Author

Well, I tried to do the programming the way that oberkc suggested, it worked but it was cumbersome keeping everything straight and not conflicting other programs controlling that light. So... I downloaded beta version 3.1.10 and set up a variable. Much simpler and no issues with conflicting with other programs on that light.

Thank you all for your help.

and not conflicting other programs controlling that light.

 

Ah. Those 'little more details" left unspoken get you every time.

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.