Jump to content

Program Runs "Then" and then runs "Else"


Recommended Posts

Posted

Hi - 

 

I think I know what is happening, but not sure how to fix it.

 

Program 'Event/South Door (Door)' has a condition that checks if 'South Gate Sensor-Opened' is switched on. If triggered it runs program 'Action/South Door (Door)' which checks to see if a if a light is on (and checks time of day, but I don't think that matters). If light is off, it runs 'then' portion of the program. If light is on it runs 'else'. Problem is, once it runs the 'then' portion, the light being checked comes on which I believe causes it to run 'else' right after running 'then'.

 

Desired behavior is that when 'Action/South Door (Door)' is triggered, to have it run 'then' if light is initially off, and 'else' if the light is initially on. I assume I have to split the actions into two separate programs and call them from the '/event/South Door (Door)', but not sure where to check for light status and time of day that are now checked in 'Action/South Door (Door)'.

 

Hope this is clear, and hope there is a solution. Thank you anyone who takes interest.

 

:Mike

 

 

South_Door_programs.txt

Posted

Well, it appears that the "Action/South Door (Door)" program is disabled, so turning the "Outside / South Lights" on shouldn't run the program again and make it fall into the Else branch. What version of the firmware are you running? If 5.0.X, could this be a bug?

 

The only other thing I can think of is that the "Event/South Door (Door)" program is getting triggered twice? Maybe a notification text should be added there to debug.

Posted

Well, it appears that the "Action/South Door (Door)" program is disabled, so turning the "Outside / South Lights" on shouldn't run the program again and make it fall into the Else branch. What version of the firmware are you running? If 5.0.X, could this be a bug?

 

The only other thing I can think of is that the "Event/South Door (Door)" program is getting triggered twice? Maybe a notification text should be added there to debug.

 

 

 

Thank you for taking a look.

 

I am running 4.6.2

 

I have a notification for 'then' and another one for 'else'. When the problem happens, I get a notification that South Door 'then' runs, and 8 seconds later get a notification that South Door 'else' runs. 

 

EDIT: Should also note that when the light is on, 'else" runs as expected. Only when light is off do I get the then/else problem.

 

Edit2: Sorry - I see you are saying to add a notification to "Event/South Door (Door)". I've done that now and will report back (not at home now)

Posted

You need to put the trigger conditions into one "if" and all other conditions (the condition you just want to check) in the second program's if.

 

If

trigger condition (the thing that makes it happen NOW, could be more than one thing)

and

program two is true

Then

do whatever

Else

do something else.

 

Keep in mind, a trigger condition can not be something that changes as a result of the trigger.  That is when you get into a loop back.  Like if the status of a light changing is the trigger, then you can not have the toucome of the program also change the status of the light.

 

So, in your case, "south lights" status is an if condition and your then changes the status in your then (but not else).

Posted

You need to put the trigger conditions into one "if" and all other conditions (the condition you just want to check) in the second program's if.

 

If

trigger condition (the thing that makes it happen NOW, could be more than one thing)

and

program two is true

Then

do whatever

Else

do something else.

 

Keep in mind, a trigger condition can not be something that changes as a result of the trigger.  That is when you get into a loop back.  Like if the status of a light changing is the trigger, then you can not have the toucome of the program also change the status of the light.

The initial trigger 'Event/South Door (Door)' just checks to see if door was opened, but the program it calls 'Action/South Door (Door)' has another trigger to decide if we run 'then' or 'else'. That trigger contains the status of the light (which I think it what you're saying is wrong). Not clear how to achieve the results without this? Would I move the light on/off logic to the original trigger and create two programs e.g. 'Event/South Door (Door-LIGHT ON)' and 'Event/South Door (Door-LIGHT OFF)' and have each one call a different action program? That would seem to create loopback also since status of light changes in 'Event/South Door (Door-LIGHT OFF)'.

 

Sorry - I think I see the problem but I'm confused about how to achieve the goal.

Posted

The initial trigger 'Event/South Door (Door)' just checks to see if door was opened, but the program it calls 'Action/South Door (Door)' has another trigger to decide if we run 'then' or 'else'. That trigger contains the status of the light (which I think it what you're saying is wrong). Not clear how to achieve the results without this? Would I move the light on/off logic to the original trigger and create two programs e.g. 'Event/South Door (Door-LIGHT ON)' and 'Event/South Door (Door-LIGHT OFF)' and have each one call a different action program? That would seem to create loopback also since status of light changes in 'Event/South Door (Door-LIGHT OFF)'.

 

Sorry - I think I see the problem but I'm confused about how to achieve the goal.

The South lights is both a trigger condition and output of your program.  It will loop back.  You can't  do that.

 

And now that I look at your program, you are changing the south lights multiple times and from one state to the other and back.

 

You need two programs.  And you will also have to disable some of these programs while the others are running because your south lights keeps changing state and you have south lights as a condition.

Posted

Please note, the one program is enabled and the other is not.

South Door (Door) - [ID 0033][Parent 0035][Not Enabled]

If
        Status  'Outside / South Lights' is Off
        And
             From Sunset - 30 minutes
             To Sunrise + 30 minutes (next day)
    
 
Then
        Send Notification to 'Text' content '!South Door - Door (then)'
        Set 'Outside / South Lights' Fast On
        Set 'Outside / North Lights' Fast On
        Set 'Outside / West Lights' Fast On
        Set 'Outside / Front Porch Shed' Fast On
        Set 'Outside / Back Porch Shed' Fast On
        Set 'Main House / Keypads / Front Door' Fast On
        Set 'Main House / Keypads / Back Door' Fast On
        Repeat 15 times
           Set 'Main House / Kitchen Accents' 250 (Beep Duration)
           Set 'Main House / Kitchen Island Cans' 250 (Beep Duration)
           Set 'Main House / Keypads / Bedroom' 250 (Beep Duration)
        Repeat 1 times
           Wait  30 seconds
           Set 'Outside / South Lights' 25%
           Set 'Outside / North Lights' 25%
           Set 'Outside / West Lights' 25%
           Set 'Outside / Front Porch Shed' 25%
           Set 'Outside / Back Porch Shed' 25%
           Set 'Main House / Keypads / Front Door' 25%
           Set 'Main House / Keypads / Back Door' 25%
           Wait  60 seconds
           Set 'Outside / South Lights' Off
           Set 'Outside / North Lights' Off
           Set 'Outside / West Lights' Off
           Set 'Outside / Front Porch Shed' Off
           Set 'Outside / Back Porch Shed' Off
           Set 'Main House / Keypads / Front Door' Off
           Set 'Main House / Keypads / Back Door' Off
           
 
Else
        Send Notification to 'Text' content '!South Door - Door (else)'
        Set 'Main House / Keypads / Front Door' Fast On
        Set 'Main House / Keypads / Back Door' Fast On
        Repeat 15 times
           Set 'Main House / Kitchen Accents' 250 (Beep Duration)
           Set 'Main House / Kitchen Island Cans' 250 (Beep Duration)
           Set 'Main House / Keypads / Bedroom' 250 (Beep Duration)
        Repeat 1 times
           Wait  30 seconds
           Set 'Main House / Keypads / Front Door' 25%
           Set 'Main House / Keypads / Back Door' 25%
           Wait  60 seconds
           Set 'Main House / Keypads / Front Door' Off
           Set 'Main House / Keypads / Back Door' Off
 
Program Trigger it   Enabled

If
      From Sunset - 30 minutes
     To Sunrise + 30 minutes (next day)

Then
     Run if of South door program
Else
     Run if of South Door program



Posted

I've spent about an hour trying to figure out what you're saying but I'm not getting it. Can you explain like I was 5 years old? Alternatively, if I there is a better way to accomplish goal can you point me to a function or feature I should use?

 

Your help is appreciated.

Posted

I've spent about an hour trying to figure out what you're saying but I'm not getting it. Can you explain like I was 5 years old? Alternatively, if I there is a better way to accomplish goal can you point me to a function or feature I should use?

 

Your help is appreciated.

Well, not really.  Look, your program is triggered by a change in the light.  And the program itself is changing the light.  You must see how that is a problem.

Posted

Simplified... here is what your If and Then section cause.

 

If the light is Off? Yes

Then turn the light on.

 

ooops... things just changed.

If the light is Off? No

Else turn the light Off and forget running the Then

Posted

I understand the problem at this point, looking for some creative solutions if anyone has any.

 

Maybe I turn outside light on to 98% when it is triggered with the switch or other program that turns on outside light but then turn it on to 100% with the door trigger? Then I could check status of light and say if light < 100 then run 'else', other wise run 'then'? 

 

Or can I set a variable when the outside lights are turned on via switch or other program and check that variable to see if outdoor lights should be turned on?

 

Really just spitballing here, I am not sure what capabilities are available to accomplish goal. Again, the goal is: if the outside lights are already on, don't turn them on when the door is triggered and if they are not on, turn them on and dim them after 30 seconds, then turn off. 

 

Thanks all for continued interest.

 

:Mike

 

 

 

Posted

Simplified... here is what your If and Then section cause.

 

If the light is Off? Yes

Then turn the light on.

 

ooops... things just changed.

If the light is Off? No

Else turn the light Off and forget running the Then

 

Except the second program is disabled, so changing the status of the light should not cause it to execute. The way he has it is the proper way to setup separate trigger events and if conditions for a program. I’m still betting that we are going to find out the first program (Event/South Door) is triggering twice.

 

 

Sent from my iPhone using Tapatalk

Posted

If the first program triggering twice turns out to the the problem, could I have the first line in the '/action/South Door (Door)' disable the triggering program ('/event/South Door (door)') and the last line re-enable it?

 

I will be able to tell if first program fires twice shortly, just cant be turning on/off the lights during dinner :-)

 

Thanks all.

Posted

Except the second program is disabled, so changing the status of the light should not cause it to execute. The way he has it is the proper way to setup separate trigger events and if conditions for a program. I’m still betting that we are going to find out the first program (Event/South Door) is triggering twice.

 

 

Sent from my iPhone using Tapatalk

It would appear that he only wrote one program.  I created the two program scenario.  I can only assume his one program was disabled because it wasn't working properly.

Posted

Except the second program is disabled, so changing the status of the light should not cause it to execute. The way he has it is the proper way to setup separate trigger events and if conditions for a program. I’m still betting that we are going to find out the first program (Event/South Door) is triggering twice.

 

 

Sent from my iPhone using Tapatalk

See apostolakisl response above. I was clarifying the current question in the thread.

Posted

Try modifying the first program:

 

South Door (Door) - [ID 001C][Parent 0031]
If
        Control 'Main House / Motion-Door Sensors / South Gate Sensor-Opened' is switched On
And        Control ‘Main House / Motion-Door Sensors / South Gate Sensor-Opened’ is not switched Off

Then        
        Run Program 'South Door (Door)' (If) 
Else   - No Actions - (To add one, press 'Action')
The other thing, both your programs have the same name. May want to rename one to ensure you have selected the second program in the first programs then clause.
Posted

The door trigger program now looks like this:

 

South Door (Door) - [iD 001C][Parent 0031]

 
If
        Control 'Main House / Motion-Door Sensors / South Gate Sensor-Opened' is switched On
    And Control 'Main House / Motion-Door Sensors / South Gate Sensor-Opened' is not switched Off
 
Then
        Run Program 'South Door (Door)' (If)
        Send Notification to 'Text' content '!South Door - Door (if)'
 
Else
   - No Actions - (To add one, press 'Action')
 
I will try and report back. Thank you
Posted

You may also want to rename one of the two programs as well, to ensure you have the right one selected in the ‘Then’ clause... having both with the same name is sure to cause confusion.

Posted

Also, I would put the notification before the call to the second program so that the timing will line up better.

 

What is the “switched on and not switched off” supposed to accomplish?

 

 

Sent from my iPhone using Tapatalk

Posted

Well, it looks like sometimes the trigger program runs more than once and when it does the problem occurs. The first time the trigger program runs it calls the action program's 'then'. The second time the trigger program runs it sees the outside light as on and runs the action program's 'else'.

 

For starters, I will rename the action programs (added leading underscore) and move the notification to the top as suggested above.

 

The current versions of the programs are posted below, but problem still occurs that the trigger sometimes runs twice. Not sure if I should try to solve that, or try different logic entirely.

 

NOTE: I removed the 'And Control 'Main House / Motion-Door Sensors / South Gate Sensor-Opened' is not switched Off' line because I couldn't tell what it was doing and it didn't change behavior. 

 

South Door (Door) - [iD 001C][Parent 0031]
 
If
        Control 'Main House / Motion-Door Sensors / South Gate Sensor-Opened' is switched On
 
Then
        Send Notification to 'Text' content '!South Door - Door (if)'
        Run Program '_South Door (Door)' (If)
 
Else
   - No Actions - (To add one, press 'Action')
 
__________________________________________________
 
_South Door (Door) - [iD 0033][Parent 0035][Not Enabled]
 
If
        Status  'Outside / South Lights' is Off
    And From    Sunset  - 30 minutes
        To      Sunrise + 30 minutes (next day)
 
Then
        Send Notification to 'Text' content '!South Door - Door (then)'
        Set 'Outside / South Lights' Fast On
        Set 'Outside / North Lights' Fast On
        Set 'Outside / West Lights' Fast On
        Set 'Outside / Front Porch Shed' Fast On
        Set 'Outside / Back Porch Shed' Fast On
        Set 'Main House / Keypads / Front Door' Fast On
        Set 'Main House / Keypads / Back Door' Fast On
        Repeat 15 times
           Set 'Main House / Kitchen Accents' 250 (Beep Duration)
           Set 'Main House / Kitchen Island Cans' 250 (Beep Duration)
           Set 'Main House / Keypads / Bedroom' 250 (Beep Duration)
        Repeat 1 times
           Wait  30 seconds
           Set 'Outside / South Lights' 25%
           Set 'Outside / North Lights' 25%
           Set 'Outside / West Lights' 25%
           Set 'Outside / Front Porch Shed' 25%
           Set 'Outside / Back Porch Shed' 25%
           Set 'Main House / Keypads / Front Door' 25%
           Set 'Main House / Keypads / Back Door' 25%
           Wait  60 seconds
           Set 'Outside / South Lights' Off
           Set 'Outside / North Lights' Off
           Set 'Outside / West Lights' Off
           Set 'Outside / Front Porch Shed' Off
           Set 'Outside / Back Porch Shed' Off
           Set 'Main House / Keypads / Front Door' Off
           Set 'Main House / Keypads / Back Door' Off
 
Else
        Send Notification to 'Text' content '!South Door - Door (else)'
        Set 'Main House / Keypads / Front Door' Fast On
        Set 'Main House / Keypads / Back Door' Fast On
        Repeat 15 times
           Set 'Main House / Kitchen Accents' 250 (Beep Duration)
           Set 'Main House / Kitchen Island Cans' 250 (Beep Duration)
           Set 'Main House / Keypads / Bedroom' 250 (Beep Duration)
        Repeat 1 times
           Wait  30 seconds
           Set 'Main House / Keypads / Front Door' 25%
           Set 'Main House / Keypads / Back Door' 25%
           Wait  60 seconds
           Set 'Main House / Keypads / Front Door' Off
           Set 'Main House / Keypads / Back Door' Off
 
 
Posted

Also, I would put the notification before the call to the second program so that the timing will line up better.

 

What is the “switched on and not switched off” supposed to accomplish?

 

 

Sent from my iPhone using Tapatalk

"switched On" triggers from the On signal created by the upper paddle contact

"switched Off" triggers from the Off signal created by the lower paddle contact.

 

"Is NOT switched Off" triggers from the Off signal but runs the Else section as it is false when the Off signal triggers it.

 

How's that for a  boolean twist? :)

 

With "status" there is only one device...the dimmer electronics, not the two paddle switches.

Posted

"switched On" triggers from the On signal created by the upper paddle contact

"switched Off" triggers from the Off signal created by the lower paddle contact.

 

"Is NOT switched Off" triggers from the Off signal but runs the Else section as it is false when the Off signal triggers it.

 

How's that for a boolean twist? :)

 

With "status" there is only one device...the dimmer electronics, not the two paddle switches.

But there is no else in the first program - so what’s the point is all I’m saying.

 

 

Sent from my iPhone using Tapatalk

Posted

Well, it looks like sometimes the trigger program runs more than once and when it does the problem occurs. The first time the trigger program runs it calls the action program's 'then'. The second time the trigger program runs it sees the outside light as on and runs the action program's 'else'.

 

For starters, I will rename the action programs (added leading underscore) and move the notification to the top as suggested above.

 

The current versions of the programs are posted below, but problem still occurs that the trigger sometimes runs twice. Not sure if I should try to solve that, or try different logic entirely.

 

NOTE: I removed the 'And Control 'Main House / Motion-Door Sensors / South Gate Sensor-Opened' is not switched Off' line because I couldn't tell what it was doing and it didn't change behavior.

 

South Door (Door) - [iD 001C][Parent 0031]

 

If

Control 'Main House / Motion-Door Sensors / South Gate Sensor-Opened' is switched On

 

Then

Send Notification to 'Text' content '!South Door - Door (if)'

Run Program '_South Door (Door)' (If)

 

Else

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

 

__________________________________________________

 

 

_South Door (Door) - [iD 0033][Parent 0035][Not Enabled]

 

If

Status 'Outside / South Lights' is Off

And From Sunset - 30 minutes

To Sunrise + 30 minutes (next day)

 

Then

Send Notification to 'Text' content '!South Door - Door (then)'

Set 'Outside / South Lights' Fast On

Set 'Outside / North Lights' Fast On

Set 'Outside / West Lights' Fast On

Set 'Outside / Front Porch Shed' Fast On

Set 'Outside / Back Porch Shed' Fast On

Set 'Main House / Keypads / Front Door' Fast On

Set 'Main House / Keypads / Back Door' Fast On

Repeat 15 times

Set 'Main House / Kitchen Accents' 250 (Beep Duration)

Set 'Main House / Kitchen Island Cans' 250 (Beep Duration)

Set 'Main House / Keypads / Bedroom' 250 (Beep Duration)

Repeat 1 times

Wait 30 seconds

Set 'Outside / South Lights' 25%

Set 'Outside / North Lights' 25%

Set 'Outside / West Lights' 25%

Set 'Outside / Front Porch Shed' 25%

Set 'Outside / Back Porch Shed' 25%

Set 'Main House / Keypads / Front Door' 25%

Set 'Main House / Keypads / Back Door' 25%

Wait 60 seconds

Set 'Outside / South Lights' Off

Set 'Outside / North Lights' Off

Set 'Outside / West Lights' Off

Set 'Outside / Front Porch Shed' Off

Set 'Outside / Back Porch Shed' Off

Set 'Main House / Keypads / Front Door' Off

Set 'Main House / Keypads / Back Door' Off

 

Else

Send Notification to 'Text' content '!South Door - Door (else)'

Set 'Main House / Keypads / Front Door' Fast On

Set 'Main House / Keypads / Back Door' Fast On

Repeat 15 times

Set 'Main House / Kitchen Accents' 250 (Beep Duration)

Set 'Main House / Kitchen Island Cans' 250 (Beep Duration)

Set 'Main House / Keypads / Bedroom' 250 (Beep Duration)

Repeat 1 times

Wait 30 seconds

Set 'Main House / Keypads / Front Door' 25%

Set 'Main House / Keypads / Back Door' 25%

Wait 60 seconds

Set 'Main House / Keypads / Front Door' Off

Set 'Main House / Keypads / Back Door' Off

 

 

I think you should concentrate on what’s causing the South Gate Sensor to send multiple Ons. What kind of sensor is it?

 

You could use a variable set in the second program to short circuit the trigger event in the first program and then reset the variable after the second program was finished.

 

 

Sent from my iPhone using Tapatalk

Posted

What is the “switched on and not switched off” supposed to accomplish?

 

I like to think of it like this...

 

The device being ‘switched’ triggers the program. A test is then done, ‘Switched On’ or ‘Switched Off’ to decide if ‘Then’ or ‘Else’ should be executed.

 

So, testing only for ‘Switched On’ will cause ‘Then’ to run when the device is switched on, and ‘Else’ to run when the device is switched off.

 

If you want the program to respond ONLY to ‘On’ commands, you need to match the ‘Not Off’ as well.

Posted

NOTE: I removed the 'And Control 'Main House / Motion-Door Sensors / South Gate Sensor-Opened' is not switched Off' line because I couldn't tell what it was doing and it didn't change behavior.

 

It causes your triggering program to only trigger when the door is opened, and ignore the door closing.

 

Currently, it triggers on both, running ‘Then’ when it opens, and ‘Else’ when the door closes.

 

Not an issue in the program you posed, but it’s important to know why the construct may sometimes be needed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...