Geofence for Domoticz

Moderator: leecollings

Post Reply
Appesteijn
Posts: 134
Joined: Friday 10 April 2015 23:53
Target OS: Linux
Domoticz version:
Contact:

Geofence for Domoticz

Post by Appesteijn »

I recently created a small app that flips a virtual switch on your domoticz server. It is a little basic, but it creates a geofence and once created, the geofence survives a possible reboot of your phone.

GeoFence
It is free, just let me know what you think of it :)

Just created a wiki-page: http://www.domoticz.com/wiki/GeoFence
Last edited by Appesteijn on Sunday 12 April 2015 13:10, edited 1 time in total.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Geofence for Domoticz

Post by Derik »

Thanks...

Please tell me how this is working?
Or make please a Wiki..

I do not understand how this geo is working...
And basic is what i like.. :D :D :D :D
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Appesteijn
Posts: 134
Joined: Friday 10 April 2015 23:53
Target OS: Linux
Domoticz version:
Contact:

Re: Geofence for Domoticz

Post by Appesteijn »

thanks, I'll try to make a wiki today. The setup is:

When you enter or leave your geofence this app calls a URL on your Domoticz server so you can flip a virtual switch.
Entering sends a 'On' and leaving sends a 'Off'

Setup:

On your Domoticz server:

Create a virtual switch that DomoFence will trigger
Go to 'Setup -> Hardware' and add a 'Dummy device'
Go to 'Switches' and add a 'Manual light/switch'
Select the right 'Hardware' and 'On/Off' the rest doesn't matter.
Add the device
Now go to 'Setup -> Devices' and note the 'Idx' of the switch you just created.

Secure your Domoticz server with a username and password
Go to 'Setup -> Settings'
At 'Website protection' fill in a username, password and select 'Basic-Auth'
Now Save your settings

Open a port on your router and pass it to your internal domoticz server (usually through NAT)

To test the connection to your Domoticz server you can use the button on the bottom right of the app.

You can use http://www.latlong.net/ to get the coordinates for the center of your geofence. I use a radius of 100 meters myself, but it is also possible to make the geofence smaller. Because of the errors on gps and location services, setting the radius too small (e.g. 10 meters) might give false 'enter' and 'leaves'. This depends on you environment so you should experiment a little to find the optimal setting.
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Geofence for Domoticz

Post by Derik »

Is there a option to trace the mobile everywhere?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
Appesteijn
Posts: 134
Joined: Friday 10 April 2015 23:53
Target OS: Linux
Domoticz version:
Contact:

Re: Geofence for Domoticz

Post by Appesteijn »

Derik wrote:Is there a option to trace the mobile everywhere?
No there is no option to trace your phone.
User avatar
fl1p
Posts: 17
Joined: Friday 19 July 2013 12:27
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Belgium
Contact:

Re: Geofence for Domoticz

Post by fl1p »

The geofence radius, is that in meters, centimeters, kilometers? :D

I just installed it :-)
Skippiemanz
Posts: 230
Joined: Sunday 14 July 2013 20:21
Target OS: Linux
Domoticz version: 4.10233
Location: Alkmaar, The Netherlands
Contact:

Re: Geofence for Domoticz

Post by Skippiemanz »

I think it's in meters!
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Geofence for Domoticz

Post by tlpeter »

It is but i guess it is a good idea to put some text un for the fields.
I use it for a couple of weeks now and it works fine.
IanDury
Posts: 47
Joined: Wednesday 08 April 2015 15:22
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Geofence for Domoticz

Post by IanDury »

Works fine. However I'm reluctant to have a non secure external connection to my domoticz server. The credentials are just encoded, not encrypted and could be intercepted. I'm using the nginx proxy server on my target to create a secure https connection to domoticz but unfortunately DomoFence does not seem to support https. Would this be hard to add?
Appesteijn
Posts: 134
Joined: Friday 10 April 2015 23:53
Target OS: Linux
Domoticz version:
Contact:

Re: Geofence for Domoticz

Post by Appesteijn »

I will have a look about adding meters to the radius and add https support tomorrow. Thanks for all the feedback!

After cleaning up the code, now it is time to look how to put https in it.
Appesteijn
Posts: 134
Joined: Friday 10 April 2015 23:53
Target OS: Linux
Domoticz version:
Contact:

Re: Geofence for Domoticz

Post by Appesteijn »

IanDury wrote:Works fine. However I'm reluctant to have a non secure external connection to my domoticz server. The credentials are just encoded, not encrypted and could be intercepted. I'm using the nginx proxy server on my target to create a secure https connection to domoticz but unfortunately DomoFence does not seem to support https. Would this be hard to add?
It was more difficult that I thought, but I just put a new version on the Play Store which lets the use choose between http and https.
IanDury
Posts: 47
Joined: Wednesday 08 April 2015 15:22
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Geofence for Domoticz

Post by IanDury »

Looks good. Using the test button https works fine and switches on my virtual device. Will do some real testing by entering/leaving the fence this weekend.

Thanks!
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Geofence for Domoticz

Post by Derik »

great....

Only the what i use is:
https://www.life360.com/tour/
I can see my kids the whole day...


Or maffemuis:
http://www.domoticz.com/forum/viewtopic ... uis#p29448

Where is nicks phone... :D ;)

Only looks maffemuis is just left Domoticz..:-(
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Geofence for Domoticz

Post by tlpeter »

After updating it stopped working for me.
I use http and when I press the test button I get an error with the url.
Appesteijn
Posts: 134
Joined: Friday 10 April 2015 23:53
Target OS: Linux
Domoticz version:
Contact:

Re: Geofence for Domoticz

Post by Appesteijn »

tlpeter wrote:After updating it stopped working for me.
I use http and when I press the test button I get an error with the url.
This is fixed now, right? Ill try to see if 'login page' as authentication can als be implemented.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Geofence for Domoticz

Post by tlpeter »

Yes, when i use basic-auth it works.
Using login page doesn't work.
IanDury
Posts: 47
Joined: Wednesday 08 April 2015 15:22
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Geofence for Domoticz

Post by IanDury »

IanDury wrote:Looks good. Using the test button https works fine and switches on my virtual device. Will do some real testing by entering/leaving the fence this weekend.

Thanks!
Real tests work fine too. I'm using https and Basic-Auth
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Geofence for Domoticz

Post by tlpeter »

I noticed lately that i entered the zone while i did not even left it (i was asleep) :mrgreen:
This happened a couple of times yesterday.
I will keep an eye on this.
What could be the reason for this?
Appesteijn
Posts: 134
Joined: Friday 10 April 2015 23:53
Target OS: Linux
Domoticz version:
Contact:

Re: Geofence for Domoticz

Post by Appesteijn »

tlpeter wrote:I noticed lately that i entered the zone while i did not even left it (i was asleep) :mrgreen:
This happened a couple of times yesterday.
I will keep an eye on this.
What could be the reason for this?
Do you have a small geofence radius? I also experienced some false positives latety (but I live on the edge of a few gsm-masts).
The Google Play Service does the geofence measuring, I'm not sure what might have changed there.

Other people noticing this?
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Geofence for Domoticz

Post by tlpeter »

I have it set to a 100 metres.
What you say about gsm could be the problem.
Because of maintenance I have very little gsm reach at the moment and most of the time I am unreachable.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests