GPSTracker regionTrigger not receiving events

I’ve read all the threads I can find and I think this is supposed to work.

I’ve installed OwnTracks on two phones and they both are reporting locations to OH successfully. Woohoo! But I couldn’t get the regionTrigger to fire.

I defined a couple of regions in the apps on the phones and pressed “Publish”. There does not appear to be a “share” option for regions any more. And the regions are correctly reporting when I’m inside or outside the defined region in the app itself.

I have a Rule to trigger from the Trigger Channel:

from core.rules import rule
from core.triggers import when

@rule("Region Change",
      description="Triggeredn when someone changes a geofence region",
@when("Channel gpstracker:tracker:RK:regionTrigger triggered")
@when("Channel gpstracker:tracker:JC:regionTrigger triggered")
def region_change(event):"The region changed: {} - {}".format(, event.event))

    name = "Unknown"
    if "RK" in str(
    if "JC" in str(

    if name == "Unknown":"Unknown trigger!")

    region = event.event.split("/")[0]
    move = event.event.split("/")[1]
    if move == "leave":
        region = "away""Updating v{}_Region to {}".format(name, region))
    events.postUpdate("v{}_Region".format(name), region)

I used curl to POST some JSON to simulate entering a region and nothing would appear to happen. It wasn’t until I issued a POST to simulate leaving a region that the channel started to trigger the Rule.

I’m not sure if this is a bug, I failed to do something, or what but I’m posting this here in case someone else runs into the same problem. I used the following commands to send the enter and leave events.

// Leave
curl -v -X POST --header "Content-Type: text/plain" --header "Accept:application/json" -d '{"_type":"transition","tid":"<ID>","acc":10.0,"desc":"<region>","event":"leave","lat":<LAT>,"lon":<LON>,"t
st":1527966973,"wtst":1524244195,"t":"c"}' "http://argus:8080/gpstracker/owntracks"

// Enter
curl -v -X POST --header "Content-Type: text/plain" --header "Accept:application/json" -d '{"_type":"transition","tid":"<ID>","acc":10.0,"desc":"<region>","event":"enter","lat":<LAT>,"lon":<LON>,"t
st":1527966973,"wtst":1524244195,"t":"c"}' "http://argus:8080/gpstracker/owntracks"

Make sure to replace the stuff in <> with your information.

I’ve just been playing with this binding and it appears that it needs to leave and then enter a geofence before things happen.

From the bottom of the bindings webpage

Note :

  • If the binding was restarted only the second transition update will trigger event as the binding has to know the previous state.

For me this means I’ve started seeing if I can use the MQTT binding and a set of rules instead as I don’t want presence to stop working everytime I reboot.

I’d go about it a different way. We’ll see if I need to deploy it over time. I don’t use it for presence detection.

First I’d set up the region switch with the profile like defined in the docs and set that switch to be persisted and restoreOnStartup. Then in a System started Rule I’d go through all those switches and if any of them were ON I’d issue a POST of the above JSON to tell the binding that I’ve entered that region and all should be OK.

That would be less work in the long run than setting up an MQTT broker, securing it with certs, exposing it to the Internet (with all the long term maintenance and monitoring that comes with that) and writing all the Rules that are required to parse out the information.

In my case I already have the MQTT broker secured and working as I’m retiring V1 bindings in preparation for the compatibility layer being removed in OH3. I run multiple brokers.
I’ve discovered within a second of every geofence enter / leave message a general status message containing all the geofence infomation follows. I’ve created a mqtt thing monitoring the base topic


with 3 channels. One provides the full String which I use in a rule to extract the region information from, and the other 2 channels use JSONPATH to extract the Latitude and Longitude which I use in the distance calculation. I tried using JSONPATH to extract the “regions” string from the JSON but it didn’t like it when there was no “regions” string present which occurs when the phone is outside all geofences.
The rule is:

val PointType homeLocation = new PointType("xx.xxxxxxxxxxxxxx,yy.yyyyyyyyyyyyyyyy")
rule "Owntracks"
when Item OwntracksJSON received update then
var ot = OwntracksJSON .state.toString
if (ot.contains("Home1")){logInfo("test", "I'm inside Home1")} else {logInfo("test", "I'm outside Home1")}
val PointType newLocation = new PointType(MyLatitude.state as DecimalType, MyLongitude.state as DecimalType)
var MyDistance = ((newLocation.distanceFrom(homeLocation))/1000).intValue
logInfo("test", "I am "+MyDistance +"km away")

I’ll keep an eye on the gpstracker bindings development and maybe give it a try when its more mature.

If you are still using MQTT 1 you can use a REGEX filter to ignore those messages for that Item. In MQTT2 you can chain transformations and similarly filter out those messages by first applying a REGEX. See MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters.

It’s been out since OH 2.4 (nearly two years now). If you find it lacking, Issues are a great way to bring the need to the developer’s attention.


I’ll check a couple of facts with the developers of Owntracks and file an issue if it will help

The issue would be with the gpstracker binding I would think, not OwnTracks itself. Unless they’re is an additional piece of information you want OT to publish that it isn’t.

I’m checking that a general status message is always published to the main topic at around the time that an enter / leave message is published to the event channel. If that’s expected behaviour the binding could use the general status messages to update its regions with every update and not use the event channel, or perhaps use the event channel to create a list of possible regions as each one is passed. If the main topic is used the individual region switch items can be persisted and after a reboot the first general update could update them all, which is similar behaviour to the old binding which just needed the individual items to be persisted.

One thing to keep in mind is that the binding users https, not MQTT. So in your along make sure to find it if it works differently that way.

Honestly, I don’t understand why the binding needs to know it care whether you are entering it leaving. Just is the event on through and let us reconcile it in Rules. I don’t need the binding’s help in this regard. If it receives a leave without a matching enter it’s still useful to know. If you receive an enter but didn’t leave the may region, just assume the leave event was missed and pass that event on through.

But I haven’t looked at the code so I don’t know why it was done the way it was done. But I know the events are generated because I can see the my wife’s events on my OT app and she can see mine. It just seems, now that I’ve used it a couple of days, that it gets stuck if you miss the leave events.

Very true about the region events. I’ve been using the old binding for a couple of years and it works very well once I worked out how to get around the phone going into deep sleep. Hopefully my new MQTT Rule Bodge will be just as good, assuming Apple haven’t changed anything in the latest iOS

I opened the issue.


Thanks, the authors of Owntracks got back to me and it is standard behaviour for both an enter / leave message to be published together with a general status message. I’ve added it to the issue