locative/geofancy used for indicating when someone home

Moderator: leecollings

Post Reply
pac0leuk
Posts: 2
Joined: Thursday 19 November 2015 22:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

locative/geofancy used for indicating when someone home

Post 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.
Raspberry Pi 2
Lightwaverf door sensors
Lightwaverf sockets
Lightwaverf light switches
Home Easy PIRs
Truff
Posts: 15
Joined: Tuesday 15 March 2016 8:42
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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.
brainpaincgn
Posts: 16
Joined: Wednesday 03 February 2016 0:35
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9052
Location: Cologne, Germany
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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
--
brainpaincgn
User avatar
Marci
Posts: 531
Joined: Friday 22 January 2016 18:00
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Wakefield, West Yorkshire UK
Contact:

Re: locative/geofancy used for indicating when someone home

Post by Marci »

Need upper case O for switchcmd...

ie:

Code: Select all

switchcmd=On
Extended Domoticz homebridge-plugin for latest Homebridge - adds temp/humidity/pressure sensors, power consumption sensors, DarkSkies virtual weather station support, YouLess Meter support, general % usage support & switch/lamp status checking!
brainpaincgn
Posts: 16
Joined: Wednesday 03 February 2016 0:35
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9052
Location: Cologne, Germany
Contact:

Re: locative/geofancy used for indicating when someone home

Post by brainpaincgn »

Thanks for the fast reply!
That was the problem.

Thanks,
Sascha
--
brainpaincgn
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
pvm
Posts: 550
Joined: Tuesday 17 June 2014 22:14
Target OS: NAS (Synology & others)
Domoticz version: 4.10538
Location: NL
Contact:

Re: locative/geofancy used for indicating when someone home

Post by pvm »

Alternative app is Pilot (domoticz client for ios/iPhone). No urls needed, just point to a switch
Synology NAS, slave PI3, ZWave (Fibaro), Xiaomi zigbee devices, BTLE plant sensor, DzVents, Dashticz on tablet, Logitech Media Server
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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.
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
pac0leuk
Posts: 2
Joined: Thursday 19 November 2015 22:56
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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
Raspberry Pi 2
Lightwaverf door sensors
Lightwaverf sockets
Lightwaverf light switches
Home Easy PIRs
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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.
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
PCRover
Posts: 5
Joined: Saturday 01 July 2017 2:27
Target OS: Windows
Domoticz version:
Contact:

Re: locative/geofancy used for indicating when someone home

Post by PCRover »

Would you mind posting what settings to reset? I can't get my iPhone 5 working with location.
User avatar
rbisschops
Posts: 63
Joined: Monday 12 May 2014 11:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Schiedam, Netherlands
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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.
RPi 3B (master): RFXtrx433, Harmony Hub, Z-Wave devices, CoCo units, Hue, Xiaomi Aquara
RPi 2B (slave): P1 connection, MySensors with custom built watermeter sensors on Aquadis+
RPi’s with: Mosquitto MQTT, Home Bridge, Home Assistant (for evaluation only)
denman091
Posts: 30
Joined: Monday 31 July 2017 15:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Pijnacker
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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?
User avatar
ecvn
Posts: 8
Joined: Sunday 29 April 2018 23:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Rotterdam
Contact:

Re: locative/geofancy used for indicating when someone home

Post 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
PM > Dutch + English
freijn
Posts: 536
Joined: Friday 23 December 2016 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: Netherlands Purmerend
Contact:

Re: locative/geofancy used for indicating when someone home

Post by freijn »

Thanks for posting!

Will give it a try.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest