Page 1 of 1

locative/geofancy used for indicating when someone home

Posted: Wednesday 20 January 2016 11:56
by pac0leuk
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):

Code: Select all

DAEMON_ARGS="$DAEMON_ARGS -sslwww MYINTPORT"
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:

Code: Select all

https://<USERNAME>:<PASSWORD>@<HOSTNAME>:<MYEXTPORT>/json.htm?type=command&param=switchlight&idx=<IDX>&switchcmd=On
and for departure, use the same except switch the light off now:

Code: Select all

https://<USERNAME>:<PASSWORD>@<HOSTNAME>:<MYEXTPORT>/json.htm?type=command&param=switchlight&idx=<IDX>&switchcmd=Off
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.

Re: locative/geofancy used for indicating when someone home

Posted: Monday 28 March 2016 13:01
by Truff
Any idea how to delete a geofence ? The app appears to refuse to allow you to delete one unless you back it up to their site. Sigh.

Re: locative/geofancy used for indicating when someone home

Posted: Tuesday 05 April 2016 0:47
by brainpaincgn
Hi,

I was playing with Locative and pasted the URL into my browser and everything was working. But now I am receiving this error message every time.

{
"message" : "Error sending switch command, check device/hardware !",
"status" : "ERROR",
"title" : "SwitchLight"
}

Here is my command:

Code: Select all

https://USERNAME:PASSWORD@HOSTNAME:PORT/json.htm?type=command&param=switchlight&idx=102&switchcmd=on
Any ideas? I am pretty sure that I am using the correct idx.

Thanks,
Sascha

Re: locative/geofancy used for indicating when someone home

Posted: Tuesday 05 April 2016 19:28
by Marci
Need upper case O for switchcmd...

ie:

Code: Select all

switchcmd=On

Re: locative/geofancy used for indicating when someone home

Posted: Tuesday 05 April 2016 21:56
by brainpaincgn
Thanks for the fast reply!
That was the problem.

Thanks,
Sascha

Re: locative/geofancy used for indicating when someone home

Posted: Saturday 04 February 2017 16:16
by rbisschops
Hi All,

Does anyone have this running at an iPhone 7 with iOS 10.2.1?
The requests don't fire when I leave/enter the set geofence. I have location always enabled for locative.

I also tested with IFTTT (wokrked flawless on my old iPhone 5. IFTTT events also don't fire.

Thx

Ralph

Re: locative/geofancy used for indicating when someone home

Posted: Saturday 04 February 2017 18:17
by pvm
Alternative app is Pilot (domoticz client for ios/iPhone). No urls needed, just point to a switch

Re: locative/geofancy used for indicating when someone home

Posted: Saturday 04 February 2017 19:06
by rbisschops
@pvm: Thanks for the tip. I know Pilot. I use it myself. As mentioned, it was working on the iPhone 5. As also Pilot depends on the iOS functionality I’m afraid it also won’t work. Geo-fencing is not in the free version. And to be honest to spend €10 for geo-fencing where I risk it not to work is a bit much.

Re: locative/geofancy used for indicating when someone home

Posted: Monday 06 February 2017 11:37
by pac0leuk
Ralph, I have it working under iOS 10.2.1 on an iPhone SE. It is not 100% clear from your post if it was working prior to the combination you mention? I get the idea from your post something changed though as you mention your old iPhone 5. If you let me know I will post to the Locative Slack support group.

Best regards,
Peter

Re: locative/geofancy used for indicating when someone home

Posted: Monday 06 February 2017 19:50
by rbisschops
Hi All,
[Solved] I've got it working. I had to reset some vital settings on the iPhone 7 like network settings. That also kills all apps access to the location, so for every app you have to agree on using the location again. Today both Locative and IFTTT fired as expected on leaving and returning home. Thanks for all the suggestions.

Re: locative/geofancy used for indicating when someone home

Posted: Saturday 01 July 2017 2:29
by PCRover
Would you mind posting what settings to reset? I can't get my iPhone 5 working with location.

Re: locative/geofancy used for indicating when someone home

Posted: Saturday 01 July 2017 19:25
by rbisschops
PCRover wrote:Would you mind posting what settings to reset? I can't get my iPhone 5 working with location.
I had to reset the network settings in the iPhone.

Re: locative/geofancy used for indicating when someone home

Posted: Tuesday 27 February 2018 17:30
by denman091
Hello,

I'm trying to use Locative on my One Plus 3T with android 8.0.0.
My domoticz is accessible from the internet. this is via https and port 443.
I have enabled Basic Authentication in Domoticz.
I use the following URL:
https://<USERNAME>:<PASSWORD>@<MYIPADRES>:443/json.htm?type=command&param=switchlight&idx=50&switchcmd=On
For sure i have set my username and password in the HTTP authentication fields in Locative and i had this enabled.
but when i send a test request i get the message: "error when sending http request wihle entering"

When i send this URL in my browser i get a popup that the site is not secure and when i make an expetion for this site in my browser the URL works fine and the device is set to "On".

How do i get this work in locative?
Is it because the https is not secure? do i use http instead of https?

Re: locative/geofancy used for indicating when someone home

Posted: Thursday 10 May 2018 7:42
by ecvn
denman091 wrote:Hello,

I'm trying to use Locative on my One Plus 3T with android 8.0.0.
My domoticz is accessible from the internet. this is via https and port 443.
I have enabled Basic Authentication in Domoticz.
I use the following URL:
https://<USERNAME>:<PASSWORD>@<MYIPADRES>:443/json.htm?type=command&param=switchlight&idx=50&switchcmd=On
For sure i have set my username and password in the HTTP authentication fields in Locative and i had this enabled.
but when i send a test request i get the message: "error when sending http request wihle entering"

When i send this URL in my browser i get a popup that the site is not secure and when i make an expetion for this site in my browser the URL works fine and the device is set to "On".

How do i get this work in locative?
Is it because the https is not secure? do i use http instead of https?
Can you try to remove <USERNAME>:<PASSWORD> in the on/off urls. I'm on ios and had to store the username password in the settings of the app. Make sure to use GET. Paste url in a browser. When you get a popup, enter username password > you get a few lines of code feedback > open domoticz to check if the virtual switch is toggled on (or off depending on which url you used)
Hope this helps. If you need assistance just send me a pm.


Verzonden vanaf mijn iPhone met Tapatalk

Re: locative/geofancy used for indicating when someone home

Posted: Thursday 10 May 2018 15:39
by freijn
Thanks for posting!

Will give it a try.