Hi Guys,
I have a really custom application I would like to develop.
I really would like to add a geofencing with some constrains to open my gate when I drive near my house.
There are some off the shelf solution I can use, starting from some available apps communicating the coordinates to OH up to develop a custom app using the OH REST interface.
Now, one of the ideas are to edit the OH android application (and then create a PR, of course) to implement geofencing using the android libraries. (I see some works on geofencing back in 2018 but it seem no more mantained)
The whole idea is to add the capabilities to add geofences in the settings menu with ENTERING and EXITING events that can “trigger” an item and also the capabilities to check if a bluetooth device is connected to set an item as “trusted device in range”. This will allow OH rules to process the geofencing event and the trusted device connected (e.g. you turn on your car while inside the geofencing area and a gate open) and then execute actions…
How do you see this upgrade, do you think it will be well accepted by the other contributors and the comunity? Am I overengineering the whole thing?
This isn’t all that uncommon of a task. Almost all of us who have been at this for a long time have had a go at something like this.
The challenges are:
GPS chews through your phone’s battery unless you turn down the checking to be infrequent, but that adds significant latency in detecting geofence changes (this is the biggest thing holding back adding this to the Android app)
GPS is really not all that accurate, unless your geofence is pretty large you’ll find yourself jumpping in and out of it frequently because of errors in the position calculation
Using some sort of beacon approach ends up being much more timely and accurate (SSID near, cell tower near, BT beacon, etc.); the Android app will report the SSID to an Item when you connect
However, there are ways you can prove out whether this will work for you without going through changes to the Android app and the like.
You can use GPSTracker - Bindings | openHAB with OwnTracks or GPSLogger, both of which have lots of configurability so you can experiment with timing, latency, battery drain, etc. That can give you your geofencing and events to OH which you can run your rules against.
An alternative is to use Task which has an openHAB plug-in and GPS geofencing as well. Tasker can command and update Items directly which can be used to drive your rules. Again, this can be used to test out latency, battery drain, etc.
I’ve done a bunch of stuff on this over the years. I’ve used GPS, WiFi, BT beacons, BT trackers, Baysean reasoning based on OH events, etc. In the end I’ve abandonded pretty much all of them as not fast enough, not accurate enough, and far too complex.
All I do now is:
Android app reports when one of our phones is on the home WiFi which is used for presence detection
Task implements a fairly large geofence and pops up a dialog where I can press a button to command the garage door opener.
That’s it. These two are more timely and more accurate than anything else I’ve tried over the years and because I’m using the GPS while driving anyway the battery drain is not a problem.