PB11 Posted November 4, 2021 Posted November 4, 2021 (edited) Hello All I'm hoping I can get someone's opinion on this little program. I've previously run this successfully without the else, but I found as my wife came home and I was in the kitchen it triggered the changing of my kitchen to coming home lighting. I've now created a second PB Arriving Home which will not change the kitchen lighting if one of us is home. What I'm not certain about is what triggers the assessment of the "else" statement. My assumption is that the "Else" will not be considered unless the "If" is triggered by the changing of our geofence status and the "If" criteria not being met . Is this correct, or will ISY run through it based on something else? When is it correct to group "if" statements in "( )" Thanks very much Edited November 4, 2021 by PB11
MrBill Posted November 4, 2021 Posted November 4, 2021 This Program Runs when either geofence changes state. Assuming that iNeighborhood is an Interger variable it will not run when the variable changes state. (however, if it was a State variable it would also run when the variable changes state.) When it runs it will evaluate all 3 conditions to either true or false. When all 3 are true the THEN block will run, OTHERWISE the ELSE Block will run. So in a nutshell, if EITHER geofence changes state, then EITHER "Then" or "Else" will be executed. 16 minutes ago, PB11 said: When is it correct to group "if" statements in "( )" Grouping with ( ) causes what's inside the () to be evaluated first. (just like algebra) so if you put the 2nd and 3rd elements in your above IF statement in ( ) then the iNeighboorhood condistion would only apply to APiPhone.
PB11 Posted November 4, 2021 Author Posted November 4, 2021 (edited) Ok, clear on the (). Thanks for that. Regarding the "If", 49 minutes ago, MrBill said: So in a nutshell, if EITHER geofence changes state, then EITHER "Then" or "Else" will be executed. So PB geofence changing to false, and AP Geofence still at false, will execute "Else". So this would result in my light coming on when no one is home? Edited November 4, 2021 by PB11
MrBill Posted November 4, 2021 Posted November 4, 2021 (edited) 10 minutes ago, PB11 said: So PB geofence changing to false, and AP Geofence still at false, will execute "Else". So this would result in my light coming on when no one is home? Yes. If EITHER change then ALL are evaluated. Most of the time if you have AND (or even sometimes OR) in an IF statement you won't want to use the ELSE. (it will run too often since it runs anytime any portion of the IF statement is false. Instead write a second program with inverted IF logic for what your wanting to put in Else. Edited November 4, 2021 by MrBill 1
MrBill Posted November 4, 2021 Posted November 4, 2021 BTW... since you're using Locative and the Portal nodeserver, you might want to revisit the wikipage and add the HOME folder node (step 4). @Javiand I recently corrected Step 4 so that it makes better sense. Essentially by adding Location, you get a third condition that is True if EITHER of you are Home, and false if NEITHER of you are home. This greatly simplifies what you're trying to do above.
PB11 Posted November 4, 2021 Author Posted November 4, 2021 28 minutes ago, MrBill said: Instead write a second program with inverted IF logic for what your wanting to put in Else. Really, that easy? And this would cover either of us home and one arriving home. 20 minutes ago, MrBill said: BTW... since you're using Locative and the Portal nodeserver, you might want to revisit the wikipage and add the HOME folder node (step 4). Ok, before I go any further on this, I'll definitely check it out. Thanks very much.
PB11 Posted November 4, 2021 Author Posted November 4, 2021 Wait, I think this is what I already have set up. Or is this something different?
PB11 Posted November 4, 2021 Author Posted November 4, 2021 Maybe its the way I'm utilizing it in the programs that needs to be adjusted. Rather then looking at it as an individual status, the "Home" dictates the status. Ok. I'll try a few tests.
PB11 Posted November 4, 2021 Author Posted November 4, 2021 (edited) Wait, that wouldn't let me set conditions based on one person already home or me just arriving home. The "LakeHouse" status would be True when the "If" statement is assessed in either situation. Correct? I will keep the universal "home" status in mind though. I hadn't considered that. Edited November 4, 2021 by PB11
MrBill Posted November 4, 2021 Posted November 4, 2021 right, if you want to know if someone is already home If lakehouse is true and PB is true would mean someone is already home Unfortunitly If lakehouse is false and PB is true will never work because if PB is true at least one person is home and lakehouse will also be true.
Recommended Posts