locative/geofancy used for indicating when someone home
Posted: Wednesday 20 January 2016 11:56
I know a few posts have referenced geofancy and the information on using it is buried deep inside posts on other topics, so I thought I would break it out and make it easier to find. Firstly, geofancy is now called Locative. There are two parts to these instructions, general stuff you need to do to your Domoticz installation to make it safely visible from outside, and the geofencing configuration itself.
Part I: Opening up Domoticz to the outside world.
To get this to work, your Domoticz installation will have to be accessible from the Internet. This ought to make you feel a little nervous but with a few precautions ought to be safe. Here are my recommendations:
1. Make sure your default password is changed, e.g. on your pi, to something hard to guess.
2. Install fail2ban as a precaution.
3. Don't enable external ssh access anyway.
4. Make sure your domoticz installation is running using SSL for the port you are going to make available externally, do this by editing the domoticz.sh in /etc/init.d to have a line uncommented like this (replace MYINTPORT with something non obvious way above 1024):5. Make sure Domoticz has some password authentication enabled, I couldn't get Basic Auth to work with Locative so I used the Login page to set a USERNAME and a PASSWORD
6. Open a different port number in your firewall (MYEXTPORT) to MYINTPORT and use the router config to map this external port (MYEXTPORT) to the internal port and the local hostname of your Domoticz installation.
7. Use a DNS service to give your router an externally accessible hostname independent of its IP address. I used duckdns as it is free. We will refer to this external hostname as HOSTNAME.
Part II: Configuring Locative for geofencing:
To use locative (formerly known as geofancy):
1. Download Locative from the app store and put it on the phone(s) you want to use.
2. In Domoticz: Create a Dummy On/Off switch which will represent when you are in a named location, e.g. "Peter Home", use the devices page to find the IDX for this dummy device.
3. In Locative: Add a new Geofence, zoom out from the map to make it cover a bigger area if you want. You will need to set both a Trigger on Arrival and a Trigger on Departure with a similar format URL. I use the GET method. Together with HTTPS will keep your passwords and usernames the most secure. You will need to make sure Basic Authentication is switched on in Locative, regardless of which security you use on Domoticz.
For Arrival use:and for departure, use the same except switch the light off now:
Substitute in appropriate values for the variables in angle brackets (USERNAME, PASSWORD, HOSTNAME, MYEXTPORT and IDX, remember to remove the <>)
And you're done. I have a switch for each phone so far, and have then used Blockly to create joining events to indicate when "Someone is Home" or "Someone is Coming Home". I plan to convert this to a LUA script and then update this post in a few days to include my LUA script.
Part I: Opening up Domoticz to the outside world.
To get this to work, your Domoticz installation will have to be accessible from the Internet. This ought to make you feel a little nervous but with a few precautions ought to be safe. Here are my recommendations:
1. Make sure your default password is changed, e.g. on your pi, to something hard to guess.
2. Install fail2ban as a precaution.
3. Don't enable external ssh access anyway.
4. Make sure your domoticz installation is running using SSL for the port you are going to make available externally, do this by editing the domoticz.sh in /etc/init.d to have a line uncommented like this (replace MYINTPORT with something non obvious way above 1024):
Code: Select all
DAEMON_ARGS="$DAEMON_ARGS -sslwww MYINTPORT"
6. Open a different port number in your firewall (MYEXTPORT) to MYINTPORT and use the router config to map this external port (MYEXTPORT) to the internal port and the local hostname of your Domoticz installation.
7. Use a DNS service to give your router an externally accessible hostname independent of its IP address. I used duckdns as it is free. We will refer to this external hostname as HOSTNAME.
Part II: Configuring Locative for geofencing:
To use locative (formerly known as geofancy):
1. Download Locative from the app store and put it on the phone(s) you want to use.
2. In Domoticz: Create a Dummy On/Off switch which will represent when you are in a named location, e.g. "Peter Home", use the devices page to find the IDX for this dummy device.
3. In Locative: Add a new Geofence, zoom out from the map to make it cover a bigger area if you want. You will need to set both a Trigger on Arrival and a Trigger on Departure with a similar format URL. I use the GET method. Together with HTTPS will keep your passwords and usernames the most secure. You will need to make sure Basic Authentication is switched on in Locative, regardless of which security you use on Domoticz.
For Arrival use:
Code: Select all
https://<USERNAME>:<PASSWORD>@<HOSTNAME>:<MYEXTPORT>/json.htm?type=command¶m=switchlight&idx=<IDX>&switchcmd=On
Code: Select all
https://<USERNAME>:<PASSWORD>@<HOSTNAME>:<MYEXTPORT>/json.htm?type=command¶m=switchlight&idx=<IDX>&switchcmd=Off
And you're done. I have a switch for each phone so far, and have then used Blockly to create joining events to indicate when "Someone is Home" or "Someone is Coming Home". I plan to convert this to a LUA script and then update this post in a few days to include my LUA script.