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.