glacier991 Posted January 27 Posted January 27 I managed to get some great help here and have a working geofence for home. I not only have the HOME node with my phoone showing if I am home or not. I also set up a state variable that varies with my occupancy between 0 and 1, depending. I don't seem to be able to write a program that will trigger lights coming on when I arrive home after dark. Does some one have examples of what they have done? Thanks
gzahar Posted January 27 Posted January 27 10 minutes ago, glacier991 said: I managed to get some great help here and have a working geofence for home. I not only have the HOME node with my phoone showing if I am home or not. I also set up a state variable that varies with my occupancy between 0 and 1, depending. I don't seem to be able to write a program that will trigger lights coming on when I arrive home after dark. Does some one have examples of what they have done? Thanks Have you tried: If From Sunset to Sunrise the next day And state variable = 1 Then Turn on lights
glacier991 Posted January 28 Author Posted January 28 (edited) Yes, and somehow that did not work as expected. Also assume the situation where I am already home at sunset, not arriving home. I would not want it to run under that circumstance. Edited January 28 by glacier991
sumguy Posted January 28 Posted January 28 I just went through this. You have to create two programs. FIrst program: If State Variable _ 1 Then Run program 2 (if) Program 2 is disabled: If From Sunset To Sunrise (next day) Then Set lights on
glacier991 Posted January 28 Author Posted January 28 Thanks sumguy. Not sure I am fully understanding. Can you give me what each program function is..eg. Does the first program act to "weed out" turning lights on if I am already at home? What disables program 2? Sorry...I am just a little dense.
glacier991 Posted January 28 Author Posted January 28 Here is what I had: Arrival Home - [ID 0020][Parent 0001] If $Chris_is_home is 0 And From Sunset To 11:00:00PM (same day) And $Chris_is_home is 1 Then Set 'Front Entry / Front Porch Light / ZY 012 Front Porch Light' On Set 'Front Entry / Entryway light / Entry way overhead light 011' On Set 'Side Deck Lights / Side Deck Lights' On Else - No Actions - (To add one, press 'Action')
glacier991 Posted January 28 Author Posted January 28 (edited) I had also tried to put the program into another folder which only enabled running the program if "Chris is at Home "was 0. and then running the rest in the nested program, neither seemed to work. (leaving out of course, the first line of IF) Edited January 28 by glacier991
Solution dbuss Posted January 28 Solution Posted January 28 I've used this to do something similar to what you want to do. Program 1 Set a variable to 3 when you enter your geofence. If Chris has entered the geofence Then $Chris is home = 3 Else $Chris is home = 0 Program 2 Turns the lights on and sets $Chris is home = 1 should you want to use the $Chris is home = 1 for something else when you are home. If From Sunset To 11:00:00PM (same day and $Chris is home= 3 Then Set 'Front Entry / Front Porch Light / ZY 012 Front Porch Light' On Set 'Front Entry / Entryway light / Entry way overhead light 011' On Set 'Side Deck Lights / Side Deck Lights' On Set $Chris is home = 1 Else $Chris is home = 0
glacier991 Posted January 28 Author Posted January 28 I will try that, great ideas. You have been so helpful!! Thank you, will report back.
sumguy Posted January 28 Posted January 28 1 hour ago, glacier991 said: Thanks sumguy. Not sure I am fully understanding. Can you give me what each program function is..eg. Does the first program act to "weed out" turning lights on if I am already at home? What disables program 2? Sorry...I am just a little dense. Yes, program 1 only runs when I arrive home and the variable changes to 1. So every time I arrive home, it will tell program 2 to run. Program two will only run if it is between sunset and sunrise the next day. After creating program 2, you have to right click and disable it otherwise it will automatically run at sunset each night. Even though it is disabled, it will still run when program 1 tells it to. I posted my exact programs below. Hope it makes sense. It's late and I'm half asleep! Jason Arrive Home Night Lights If $Jason_Home_Away is 1 Then Run Program 'Jason Arrive Home Night Light2' (If) Else - No Actions - (To add one, press 'Action') Jason Arrive Home Night Light2 -[Not Enabled] If From Sunset To Sunrise (next day) Then Set 'Outside / Flood_Walkway' On Else - No Actions - (To add one, press 'Action')
glacier991 Posted January 28 Author Posted January 28 Thanks .. very helpful. One thing I liked about Dbuss's solution was the out of the box idea of divorcing from the binary home/away state variable to broaden a number that could be used outside that binary paradigm. On the other hand your solution seems simpler. Ocam's Razor? I am tremendously grateful to you both. This is why I suggested a programming place on this forum. We all tend to get stuck and other ideas are fabulously helpful. Thanks to Administrator GEDDY for this!
glacier991 Posted January 28 Author Posted January 28 One last thing...I learned something I did not know, that a disabled program WILL run if called by another program. One question in my mind, if a program contains a variable value in IF, does it only trigger if that variable has changed to that variable value? In other words if the IF line says IF variable X equals 1, and time is 10pm until 2 am, and if variable it sitting on 1 when 10 pm rolls around, will the program run?
gzahar Posted January 28 Posted January 28 2 hours ago, glacier991 said: One last thing...I learned something I did not know, that a disabled program WILL run if called by another program. One question in my mind, if a program contains a variable value in IF, does it only trigger if that variable has changed to that variable value? In other words if the IF line says IF variable X equals 1, and time is 10pm until 2 am, and if variable it sitting on 1 when 10 pm rolls around, will the program run? The program will evaluate the conditions anytime one of them changes and run Then or Else depending on the state of the conditions. The one exception is an integer variable which will not cause a program to run when it changes. In you example (assuming the variable is a state variable and you mean 2am the next day) your program will run (then or else) when the variable changes value (setting it to the same value will not cause execution) and at 10 pm and 2 am. So yes, if the variable is 1 at 10 pm it will execute the Then statement(s). At 2am (the next day), if the variable is 1 it will run the Else statement.
glacier991 Posted January 28 Author Posted January 28 Thanks. I had briefly looked at that another time for a different reason, but will go back and thoroughly digest it. So, just to make doubly sure I understand, if I have a state variable in an if statement, the if will trigger when that variable changes value, but otherwise not? What I am trying to avoid is the situation where I am sitting at home (with my state variable at 1) and then when 10 pm comes around, and the state variable is at 1 (unchanged) the program does NOT run. If I am understanding you correctly, it will not as it would be looking for a change in state commencing at 10 (or after).
dbwarner5 Posted January 28 Posted January 28 29 minutes ago, glacier991 said: Thanks. I had briefly looked at that another time for a different reason, but will go back and thoroughly digest it. So, just to make doubly sure I understand, if I have a state variable in an if statement, the if will trigger when that variable changes value, but otherwise not? What I am trying to avoid is the situation where I am sitting at home (with my state variable at 1) and then when 10 pm comes around, and the state variable is at 1 (unchanged) the program does NOT run. If I am understanding you correctly, it will not as it would be looking for a change in state commencing at 10 (or after). Not quite. Think about it this way.... If ANYTHING in the IF statement changes, that IF will be re-evaluated for true or false. So if you have two conditions such as your variable and time and the variable meets the condition and doesn't change, but then the time changes to make that part of the statement true (or false), the IF will evaluate and either the THEN or ELSE will run. That is why being very clear about what you want to achieve is important. If I understand, you want certain lights to come on when it is dark, when you arrive home, but if you are home, you dont want them to come on? If that is correct, then you should follow the two program method, with program 1 enabled and checking to see if you are home. The true should then run program 2 (if) that is disabled that has the time schedule in the IF and the lights in the then. Would suggest you use From Sunset + 30minutes to sunrise next day, so that it can vary time wise with seasonal changes of sunset (dark)
glacier991 Posted January 28 Author Posted January 28 (edited) Got it. Very helpful. Appreciate both your and Sumguy' s assistance on all this. Edited January 28 by glacier991 1
Recommended Posts