Jim P Posted February 22, 2023 Posted February 22, 2023 This program ran at 7:05 AM this morning. LRLAMPOFF10 - [ID 003B][Parent 0057] If From 10:00:00PM To 5:00:00AM (next day) And 'Living Room Lamp' Status is On Then Wait 10 minutes Set 'Living Room Lamp' Off Else - No Actions - (To add one, press 'Action') SUMMARY shows it ran at 07:05 AM Status is false
Solution dbwarner5 Posted February 22, 2023 Solution Posted February 22, 2023 Any time this light is turned on or off, ie: the state of the light changed, this program will run because evaluating the state of the light is part of the IF. And subsequently, if the time is outside of your designated window, it will be false. 1
Jim P Posted February 22, 2023 Author Posted February 22, 2023 I would think that if the schedule time range is not true that nothing should run???? Since it is an IF AND statement doesn't both have to be true for the THEN section to run??? So I can't see how the THEN section should ever run if the time was not between 10PM and 5 AM the next day???
Javi Posted February 22, 2023 Posted February 22, 2023 5 minutes ago, Jim P said: I would think that if the schedule time range is not true that nothing should run???? Since it is an IF AND statement doesn't both have to be true for the THEN section to run??? So I can't see how the THEN section should ever run if the time was not between 10PM and 5 AM the next day??? 7 hours ago, Jim P said: SUMMARY shows it ran at 07:05 AM Status is false The THEN section did not run if the Status is false, the else section ran. Think of last run as last evaluated.
Geddy Posted February 22, 2023 Posted February 22, 2023 27 minutes ago, Jim P said: I would think that if the schedule time range is not true that nothing should run???? I think you're misinterpreting the meaning of "run" in your situation. Programs always run unless they are disabled. If you didn't want something to "RUN" then you could handle that in two ways... Split this into 2 programs and disable the 2nd program and only call on it from the first program. Put program in a folder and then set folder permissions to only evaluate during the schedule. This is tricky and should only be done in rare cases and by advanced planning and understanding of folder conditions. (See section 9.5.7 of the ISY cookbook for discussion of Folder Conditions) The program "evaluated" the IF portion. It didn't "RUN" the "then" portion because it was "False". With nothing in the "Else" there was nothing to "RUN". 16 minutes ago, Jim P said: So I can't see how the THEN section should ever run if the time was not between 10PM and 5 AM the next day??? Are you saying that the lamp was on and turned off at a time you were not expecting it to turn off? Both @dbwarner5 and @Javi have explained the program will always evaluate the "if" and react accordingly. In your program both events must be true for the "then" to trigger. Otherwise, the program is false and the "else" would trigger. With nothing in the else then you don't perceive the program ran unless you look at the summary tab in admin console and see the "Last run time" as you are showing. To test this you can set a random light to turn off in the else then manually trigger the program "run if" while the lamp is on. The random light should turn off. Now...delete that from your program because you don't want it randomly turning off later! Additionally, you can test the current program while sitting at the computer by right clicking the program and selecting "run if". The program would trigger and set a "Last Run Time". The "Status" should also remain "False". While still viewing the summary tab, use UD Mobile, admin console, or other method to trigger the lamp on. You should see the "Last Run Time" update again. And it should still show status = false. This means programs always evaluate the "IF" statements. To stop that the programs need to be disabled or in a folder with conditions met to stop programs from being evaluated. Lastly, if you indeed come back and say, "yes, my lamp turned off at 7:05am" then you could have an issue with another program. The program you pasted would not have turned the lamp off at 7:05am.
Jim P Posted February 22, 2023 Author Posted February 22, 2023 Ok thanks... I will investigate this... What I was thinking is that if a program's if statements are false and there is no else clause, then there would be minimal utilization of cpu process time. So along those lines if the From To clause was false with no else actions then that program would use little resources... I will do more investigating...
gzahar Posted February 22, 2023 Posted February 22, 2023 Ok thanks... I will investigate this... What I was thinking is that if a program's if statements are false and there is no else clause, then there would be minimal utilization of cpu process time. So along those lines if the From To clause was false with no else actions then that program would use little resources... I will do more investigating...The only extra processing it did, was create a log entry of the fact it didn’t need to do anything more (showing that it ran else). It will always have to see if the input conditions are true or not every time the lamp status changes. And the minor overhead of logging that it was false is very helpful for debugging. 1 1
dbwarner5 Posted February 23, 2023 Posted February 23, 2023 This is the "trick" that experienced programmers miss with ISY state related programming. The IF statement will be evaluated ANYTIME one of the if condition's state changes. In this case, the light changing states causes the program to be evaluated and the result is FALSE, because the time condition in the IF is not met. The easiest way to test this and verify it is to simply turn the light on during the day. You should see that every time you turn the light on or off, (the state of the light changed), the IF will be evaluated and the program will run, resulting in a FALSE condition. The time in the status time should match exactly when you turn the light on or off. Cheers. 1 2
TRI0N Posted February 23, 2023 Posted February 23, 2023 (edited) 15 hours ago, Jim P said: This program ran at 7:05 AM this morning. LRLAMPOFF10 - [ID 003B][Parent 0057] If From 10:00:00PM To 5:00:00AM (next day) And 'Living Room Lamp' Status is On Then Wait 10 minutes Set 'Living Room Lamp' Off Else - No Actions - (To add one, press 'Action') SUMMARY shows it ran at 07:05 AM Status is false You don't need to check if the Living Room Lamp is on. Simply just make the "Then" statement Set 'Living Room Lamp' Off and that will do what you need. Regardless if the light is on or not it will schedule it to tun off. If you want it to turn off at 5:10:00AM. The only time I check a light status is on in the IF statement is to check if another light is on. Such as my under cabinet lights. If the main kitchen lights are on, they don't turn on when motion is detected. Doing so this way you can force a light to behave that way during that time by using the else statement regardless if someone turns it on/off Manually. An example would be; lets make sure the porch light is always on no matter what the status of the switch is at night. I use Sunrise/Sunset for that and the "Then" is Turn Porch Light Off, "Else" is Turn Porch Light On. So if someone accidently presses the wrong switch in the entry it will turn the light on/off respectively on the next status cycle. TRI0N Edited February 23, 2023 by TRI0N
lilyoyo1 Posted February 23, 2023 Posted February 23, 2023 (edited) 11 hours ago, TRI0N said: You don't need to check if the Living Room Lamp is on. Simply just make the "Then" statement Set 'Living Room Lamp' Off and that will do what you need. Regardless if the light is on or not it will schedule it to tun off. If you want it to turn off at 5:10:00AM. The only time I check a light status is on in the IF statement is to check if another light is on. Such as my under cabinet lights. If the main kitchen lights are on, they don't turn on when motion is detected. Doing so this way you can force a light to behave that way during that time by using the else statement regardless if someone turns it on/off Manually. An example would be; lets make sure the porch light is always on no matter what the status of the switch is at night. I use Sunrise/Sunset for that and the "Then" is Turn Porch Light Off, "Else" is Turn Porch Light On. So if someone accidently presses the wrong switch in the entry it will turn the light on/off respectively on the next status cycle. TRI0N From the way things look, for his use case, he has it programmed properly. He's not simply trying to turn the light off at 0510; but off should it be on (or turned on) via various methods that control wouldn't capture. As written, if they turned the light on at 8pm it would turn off at 1010 if left on. If he used his voice at 1156 to turn the light on, it would turn off at 1206.... Ditto for any other time as well. If he turned on the light at 0510, it would stay on all day (unless turned off manually) until 1010 at night Edited February 23, 2023 by lilyoyo1 2
TRI0N Posted February 23, 2023 Posted February 23, 2023 5 hours ago, lilyoyo1 said: From the way things look, for his use case, he has it programmed properly. He's not simply trying to turn the light off at 0510; but off should it be on (or turned on) via various methods that control wouldn't capture. As written, if they turned the light on at 8pm it would turn off at 1010 if left on. If he used his voice at 1156 to turn the light on, it would turn off at 1206.... Ditto for any other time as well. If he turned on the light at 0510, it would stay on all day (unless turned off manually) until 1010 at night Yes that is perfect of a delayed light inside that time frame. Kind of looked like he was just experimenting with the programing... TRI0N
Recommended Posts