Jump to content

Geofencing programs


Go to solution Solved by dbuss,

Recommended Posts

Posted

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

Posted
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

 

Posted (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 by glacier991
Posted

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

 

Posted

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.

 

Posted

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')
 

Posted (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 by glacier991
  • Solution
Posted

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

 

Posted
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')
 

Posted

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!

Posted

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?

Posted
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.

Posted

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).

Posted
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)

 

Guest
This topic is now closed to further replies.

  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      37.1k
    • Total Posts
      371.5k
×
×
  • Create New...