Jump to content

Programming Else statement issue with time?


sdynak

Recommended Posts

Hi Guys & Gals..

Hope everyone are doing great!

I am going in circles here and I'm sure it is something simple but I'm off track and hit the dirt. 

I have a program that turns the front porch lights on in the evening when the front door is opened and it has been working ok for me up until I added a program to also turn it on in the morning when it is still dark out. My wife's schedule changed and now leaves before it gets light so was trying to make it safer for her. 

Problem is in the morning program I want the lights to shut off after 5 minutes of the door closing and put this in the "Then" statement initially but they didn't shut off so I put it in the "Else" statement and it worked. The problem came in where the evening program now shuts off after 5 minutes now so the "Else" statement is triggering it. I tried to work on a separate program to turn them off but things stopped working all together so I just removed them for now as I must not made some errors. 

If you have any suggestions it may help me from pulling the last hairs I have :) .. Thanks in advance Stan.

 

This is the Evening Program:

Front Lights On Dark 1 - [ID 007E][Parent 0072]

If
        From    Sunset  +  1 minute
        To      11:59:00PM (same day)
    And (
             Status  'Christmas Tree' is Off
         And Status  'Front Lights and Porch / Front Lights' is Off
         And Control 'Front-Door / Front Door-Opened' is switched On
        )
 
Then
        Set 'Front Lights and Porch / Front Lights' On
 
Else
   - No Actions - (To add one, press 'Action')

 

This is the AM Program:

Front Lights On Dark 2 - [ID 0099][Parent 0072]

If
        From     5:00:00AM
        To      Sunrise +  1 second (same day)
    And (
             Status  'Christmas Tree' is Off
         And Status  'Front Lights and Porch / Front Lights' is Off
         And Control 'Front-Door / Front Door-Opened' is switched On
        )
 
Then
        Set 'Front Lights and Porch / Front Lights' On
        Wait  5 minutes 
        Set 'Front Lights and Porch / Front Lights' Off
 
Else
        Wait  5 minutes 
        Set 'Front Lights and Porch / Front Lights' Off
 

Edited by sdynak
Link to comment
2 hours ago, sdynak said:

This is the AM Program:

Front Lights On Dark 2 - [ID 0099][Parent 0072]

If
        From     5:00:00AM
        To      Sunrise +  1 second (same day)
    And (
             Status  'Christmas Tree' is Off
         And Status  'Front Lights and Porch / Front Lights' is Off
         And Control 'Front-Door / Front Door-Opened' is switched On
        )
 
Then
        Set 'Front Lights and Porch / Front Lights' On
        Wait  5 minutes 
        Set 'Front Lights and Porch / Front Lights' Off
 
Else
        Wait  5 minutes 
        Set 'Front Lights and Porch / Front Lights' Off

The issue with your AM Program is that you change one of the IF criteria (bolded above) within the THEN.  You then execute a WAIT which allows the IF to be reevaluated, and upon reevaluation it transfers control to the ELSE.  You really don't need to check whether the 'Front Lights and Porch / Front Lights' are OFF before turning them ON.  Remove that test from both your AM and Evening programs and remove the two statements in the ELSE of the AM program and you'll be good to go.

  • Like 2
Link to comment
The issue with your AM Program is that you change one of the IF criteria (bolded above) within the THEN.  You then execute a WAIT which allows the IF to be reevaluated, and upon reevaluation it transfers control to the ELSE.  You really don't need to check whether the 'Front Lights and Porch / Front Lights' are OFF before turning them ON.  Remove that test from both your AM and Evening programs and remove the two statements in the ELSE of the AM program and you'll be good to go.

 

I believe he’ll have the same problem when the door closes during the 5 minute wait and it re-evaluates (appears to be an Insteon sensor which I don’t use so maybe there’s an option there). Regardless I would split this into 2 programs.

 

(Edited:)

If you want the lights on (time and door open)

Then:

turn lights on

ENABLE program 2

 

Program 2

If door is closed

Then:

wait 5 minutes

Turn off lights

DISABLE program 2

 

Might want to have this 2nd program to run at startup so it doesn’t get goofed up if the ISY loses power while it’s running? Others may have cleaner suggestions. There are several ways to do what you want.

 

AM and PM programs will work best I think if you split each into 2 programs like this. This also prevents the lights turning off if the door is left open, which your program would do and I’m not sure you really want that.

 

My original suggestion maybe was too simple and wouldn’t work. Here was my original suggestion. Problem is that the 2nd program wouldn’t keep checking if the door is closed.

 

If you want the lights on (time and door open)

Then:

turn lights on

Run IF of program 2

 

Program 2 (disabled)

If door is closed

Then:

wait 5 minutes

Turn off lights

 

Sent from my iPhone using Tapatalk

  • Like 1
Link to comment
20 hours ago, TrojanHorse said:

I believe he’ll have the same problem when the door closes during the 5 minute wait and it re-evaluates (appears to be an Insteon sensor which I don’t use so maybe there’s an option there). Regardless I would split this into 2 programs.

I don't think he'll have a problem.  His test is "And Control 'Front-Door / Front Door-Opened' is switched On".  While "Status is ON" and "Status is OFF" are opposites "switched ON" and "switched OFF" are not.  So the WAIT won't be interrupted when the door is closed and a "switched OFF" is generated.  It's this nature of "switched ON/OFF" events that causes people to test for "switched ON AND NOT switched OFF" when they want the THEN to execute upon a "switched ON" event and the ELSE to execute upon a "switched OFF" event.  So net, no need to switch to two program instead of one.

  • Like 2
Link to comment
22 minutes ago, kclenden said:

I don't think he'll have a problem.  His test is "And Control 'Front-Door / Front Door-Opened' is switched On".  While "Status is ON" and "Status is OFF" are opposites "switched ON" and "switched OFF" are not.  So the WAIT won't be interrupted when the door is closed and a "switched OFF" is generated.  It's this nature of "switched ON/OFF" events that causes people to test for "switched ON AND NOT switched OFF" when they want the THEN to execute upon a "switched ON" event and the ELSE to execute upon a "switched OFF" event.  So net, no need to switch to two program instead of one.

Good point and helpful explanation of how Insteon devices work.  I think many people have been confused about when to use a "switched ON AND NOT switched OFF" structure so this is helpful.  I don't use Insteon door open/close sensors so I may be wrong.  

Yet, I still see that the lights will go off (after 5 minutes) even when the door is open.  I remember when I had a similar program structure with Elk security sensors and the lights turned off during a "long goodbye" and car loading when the door was open.  I believe it's best to turn the lights off (say 5 minutes) after the door is closed. 

Ugh.  Complicated, but I'm having fun with Home Automation!

  • Like 1
Link to comment
5 minutes ago, TrojanHorse said:

I believe it's best to turn the lights off (say 5 minutes) after the door is closed.

Good point.  Though in my case, if it's an outside door, I almost always immediately close the door after opening it so ON and OFF would basically be the same.  ?

  • Like 1
Link to comment

I might end up with that as well.. I agree with eliminating that 1% area especially if that one time we happen to leave the door open. Trying both options helps me think it through as well and learn. Can't thank you both enough for sharing your experience & expertise. 

  • Like 1
Link to comment
I might end up with that as well.. I agree with eliminating that 1% area especially if that one time we happen to leave the door open. Trying both options helps me think it through as well and learn. Can't thank you both enough for sharing your experience & expertise. 


Learning is the best way. To test things I’ll often shorten the waits from say 5 minutes to 10 seconds or more depending on the situation so I can test more quickly. Then when comfortable with the programs I extend the wait times and monitor their behavior. I like to send texts from ISY to myself upon events if needed to troubleshoot.

Good luck and have fun!


Sent from my iPhone using Tapatalk
  • Like 2
Link to comment

So I have not been back yet as the 1st option has kind of stumped me just trying it and I think I have about lost my wits trying to understand why. 

 The program runs ok and turns the light on now and does not impact my evening program turning it off but it doesn't turn off at all. I have similar programs that do as expected so I really feel my eyes are getting the better part of me and I'm missing something. 

 

Does anyone see why the lights should not shut off after the 5 minutes wait period?

Thanks in advance!

Stan

 

Front Lights On Dark 2 - [ID 0099][Parent 0072]

If
        From     5:00:00AM
        To      Sunrise +  1 second (same day)
    And (
             Status  'Christmas Tree' is Off
         And Status  'Front-Door / Front Door-Opened' is On
        )
 
Then
        Set 'Front Lights and Porch / Front Lights' On
        Wait  5 minutes 
        Set 'Front Lights and Porch / Front Lights' Off
 
Else
   - No Actions - (To add one, press 'Action')
 

Link to comment

I'm going to try adding it to the else now as well.. Last time it triggered my evening program I believe but I removed the "IF" statement for being off so maybe it will work this way again and not impact my evening program. 

 

Front Lights On Dark 2 - [ID 0099][Parent 0072]

If
        From     5:00:00AM
        To      Sunrise +  1 second (same day)
    And (
             Status  'Christmas Tree' is Off
         And Status  'Front-Door / Front Door-Opened' is On
        )
 
Then
        Set 'Front Lights and Porch / Front Lights' On
        Wait  5 minutes 
        Set 'Front Lights and Porch / Front Lights' Off
 
Else
        Wait  5 minutes 
        Set 'Front Lights and Porch / Front Lights' Off
 

Edited by sdynak
Link to comment
2 minutes ago, sdynak said:

So I have not been back yet as the 1st option has kind of stumped me just trying it and I think I have about lost my wits trying to understand why. 

 The program runs ok and turns the light on now and does not impact my evening program turning it off but it doesn't turn off at all. I have similar programs that do as expected so I really feel my eyes are getting the better part of me and I'm missing something. 

 

Does anyone see why the lights should not shut off after the 5 minutes wait period?

Thanks in advance!

Stan

 

Front Lights On Dark 2 - [ID 0099][Parent 0072]

If
        From     5:00:00AM
        To      Sunrise +  1 second (same day)
    And (
             Status  'Christmas Tree' is Off
         And Status  'Front-Door / Front Door-Opened' is On
        )
 
Then
        Set 'Front Lights and Porch / Front Lights' On
        Wait  5 minutes 
        Set 'Front Lights and Porch / Front Lights' Off
 
Else
   - No Actions - (To add one, press 'Action')
 

Because the front door "status" open is probably closing before the 5 minutes, which resets the program since all status items trigger on any change.  "control" items trigger strictly on the designated action and no other.

I have no idea what is monitoring your front door, but if it has a "control" option use it.  If not, you'll need two programs.

  • Like 1
Link to comment
5 minutes ago, apostolakisl said:

Because the front door "status" open is probably closing before the 5 minutes, which resets the program since all status items trigger on any change.  "control" items trigger strictly on the designated action and no other.

I have no idea what is monitoring your front door, but if it has a "control" option use it.  If not, you'll need two programs.

It is a Insteon 2843-222 Open / Close sensor and has a control option.. I'll give it a try! Thank you..

Link to comment
5 minutes ago, lilyoyo1 said:

Are all the conditions being met after 5 minutes? My guess is that either the door is closed or the tree is on which makes the program reevaluate

So the door does get closed right away usually.. The tree is actually outside X-Mas lights so I don't want the front light to come on if they are on. It should all be met within 5 minutes. 

Link to comment
37 minutes ago, sdynak said:

I think Control got me once before in a situation like this.. I don't know why I forgot about that. 

You solved your own problem. With the door closed, the conditions are no longer met. 

If it were me, I'd create a folder and put the status of the tree in it. If status tree light is off allow the programs to run

Then have a program in the folder that says

If time is x to y and control door is open 

Then set light on wait 5 minutes turn off.

 

Edited by lilyoyo1
  • Like 1
Link to comment
4 minutes ago, lilyoyo1 said:

You solved your own problem. With the door closed, the conditions are no longer met. 

If it were me, I'd create a folder and put the status of the tree in it. If status tree light is off allow the programs to run

Then have a program in the folder that says

If time is x to y and control door is open 

Then set light on wait 5 minutes turn off.

 

Thank you .. I appreciate the options and advice. Glad to know there are a few ways to do things and seeing that is helpful. 

Link to comment
9 minutes ago, lilyoyo1 said:

You solved your own problem. With the door closed, the conditions are no longer met. 

If it were me, I'd create a folder and put the status of the tree in it. If status tree light is off allow the programs to run

Then have a program in the folder that says

If time is x to y and control door is open 

Then set light on wait 5 minutes turn off.

 

Folder conditions are not a good technique. The conditions are obscure, and can be forgotten about, making it a bad programming method, and altering the status can leave devices in undesirable positions when the programs stall. Almost every folder condition I have installed has been removed after discovering these problem over the years.

  • Like 1
Link to comment
1 hour ago, sdynak said:

It is a Insteon 2843-222 Open / Close sensor and has a control option.. I'll give it a try! Thank you..

So you'll need to consider the status of the tree.  If the tree changes status during the 5 minutes that will also kill the program.   The best way to manage that is to use a second program that is disabled.  The first program runs the "if" on the second, disabled program.  This program checks the status of the tree and contains your "then" stuff above.  A disabled program only runs when called, it never runs on a self trigger.  So in other words, the only thing that can kill the 5 minute wait is something in the "if" of the first program.

Alternatively, you could have a program that shuts the light off if the tree turns on.  This might be more to your objective of not having both the tree and light on at the same time since it will shut the light off immediately, not waiting for the 5 minute timer. 

 

Edited by apostolakisl
  • Like 1
Link to comment
10 minutes ago, apostolakisl said:

So you'll need to consider the status of the tree.  If the tree changes status during the 5 minutes that will also kill the program.   The best way to manage that is to use a second program that is disabled.  The first program runs the "if" on the second, disabled program.  This program checks the status of the tree and contains your "then" stuff above.  A disabled program only runs when called, it never runs on a self trigger.  So in other words, the only thing that can kill the 5 minute wait is something in the "if" of the first program.

Alternatively, you could have a program that shuts the light off if the tree turns on.  This might be more to your objective of not having both the tree and light on at the same time since it will shut the light off immediately, not waiting for the 5 minute timer. 

 

Thanks for the reminder on that.. Interesting thoughts. Given the time of this program most likely I will not be having the trees on manually or through a program so I might just remove it to eliminate the possibility. But then that one time it is on I will probably annoy me if the X-Mas lights were on and the front lights popped on opening the door :). 

Link to comment
50 minutes ago, larryllix said:

Folder conditions are not a good technique. The conditions are obscure, and can be forgotten about, making it a bad programming method, and altering the status can leave devices in undesirable positions when the programs stall. Almost every folder condition I have installed has been removed after discovering these problem over the years.

That depends on the person. I've used it for years without any issues. Ive found it's the easiest way for someone who may not have much experience to accomplish what they are trying to do without being overwhelmed as well as someone not versed in programming to pick up vs other methods 

  • Like 1
Link to comment
Guest
This topic is now closed to further replies.

×
×
  • Create New...