Distance check is a LUA script to turn on the lights when you’re coming home, for example to turn on the garden light.
It uses the GPS functionality of the Fibaro HC2.
The script tries to manage the delays or the errors that sometimes there are acquiring the user's location by the Fibaro/GPS and it requires an interval of 1 minute for the Fibaro HC2 parameter "How frequently GPS position from the user’s iPhone should be collected".
It has been tested in scenario where you are some kilometers away from home and you are going to home.
How it works.
You can define four areas: large area and small area, gap area and extra large area.
The area are circles around the location of the house.
When you enter in the large area the light is turned on and a timer is started.
If you reach the small area before the timer has expired the light will be “confirmed on” otherwise the light will be turned off. Perhaps you was not going to home but you have entered in the large area for a while.
When the light is “confirmed on” by the first timer a second timer is started. If you exit from the small area before that this timer has expired the light will be turned off. This second timer avoids that the light remains on when, for example, you pass near the house (inside the small area) without to stop at the house.
If you remains in the small area the script will continue to run to check when you will go away from home just to reset at the condition where it checks when you area arriving to home.
The reset happens when you will be out of the “large area + a gap distance”.
Large area + gap distance define the gap area.
The gap area is to avoid that the script switches exactly on large area border when you are going away from home. Infact it could be that the road you are on goes in and out from the large area or that the FIBARO GPS reports different values (greater or less than large area radius) when you are next to the large area border. So, without the gap area the script could turn on the light when you are going away from home.
It is important to note that even though the script should erroneously turned on the light when you are going away from home the light will be turned off after the first timer is expired since you will not enter in the small area.
Anyway the gap area avoids this kind of error and it is used only when you are going away from home.
Link for script (ZIP file) and documentation (PDF) download:
http://domotica.gposta.it