Geofences in Android App - design choices

Hey there,

I wanted to use geofences in my OH2 setup, but didnt want to use any external apps like IFTTT
and i saw that there was already a old pull request on github about it.

After reading through the comments i wasnt realy any smarter (the main point was probably that it should work with a standard openhab installation without any additional bindings etc.) and decided to just start with the ui and registering on the google location api and see from there.

My main idear now was to just have the App add a new Switch-Item to the server (name, label and stuff are all configurable in the app; radius and location also but that would stay on andorid) via REST and update that item on entering and exiting the fence.

Now i need some feedback / help on how to continue now :slight_smile:
My branch:

Thanks :slight_smile:


I use owntracks that reports location via mqtt (firewall, server). then using dark sky that can take an long/lat to a post code/vice vesa

Hey Nils,
thanks for your work.
The main point in was that the user has to enter the coordiantes in a text field. It would be a lot smarter if a Google map is showing up and the user can select the geo fence there. Can you open a PR, so we can continue the discussion on github?

currently using owntracks for geofencing, would be nice to use the built in google geofencing to avoid the extra battery drain.
I read through the thread, but wasn’t quite sure where we are proposing the fencing to be implemented. I like the idea of integrating with google location api.

@CasualTriangle are you saying you updated the android app to use the built in geo fencing support from android?

If so, that would be awesome so I could get rid of owntracks.

It would be nice to see this move forward even if you have to enter the location manually for now. I’m sure someone would add the map based selection quickly after.

the Geofencing itself is done with the google location API.
that part is manly done already, what still needs work is having thouse hooks actually send stuff to openhab.
Also the picking of the location with a map should not be too much of an issure, there are parts of the Google API that should allow that feature easily.

I have opened a Pull Request with a Done/Todo list in the description :slight_smile:

FWIW, the gpstracker binding was recently added to 2.4. It can do the geofencing on its own, toggling OH switch items. No need for and no dependency on G**gle.
It’s built to be ‘fed’ with JSON-encoded either location data or transition messages over HTTP. So you can use either client-side geofencing and just send transition messages, or you use apps like owntracks or gpstracker or your own to send pure location data and have the binding do the geofencing.