Jump to content

Quick programming question


ixlr8

Recommended Posts

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

Posted

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.

Posted

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')

Posted
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')

Posted

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!

Posted

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.

Posted

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

Posted

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

Posted

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.

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

    • There are no registered users currently online
  • Forum Statistics

    • Total Topics
      37.1k
    • Total Posts
      371.5k
×
×
  • Create New...