I know, I did define a home region in there. But owntracks didn’t send anything when I entered/left.
I think I’ve configured it correctly.
One of the binding’s feature is that it can measure distance from “home” if you set the system location at Configuration/sSystem/Regional settings
This is a new not too well documented feature of OH. You can link switch items to the trigger channel with Geofencing
profile. Doing so the UI will ask you to enter/select a region name. When you enter/leave a region and the binding receives enter/leave transition messages from the OwnTracks app the switch will be updated accordingly.
First of all: thanks for the binding, this is exactly what I was looking for!
But I also struggle with the setup. I have defined the following items:
Number iPhone_Owntracks_BatteryLevel "Battery Level [%d %%]" <battery> {channel="gpstracker:tracker:2da78bf5:batteryLevel"}
Location iPhone_Owntracks_Location "Coordinates" {channel="gpstracker:tracker:2da78bf5:lastLocation"}
DateTime iPhone_Owntracks_LastUpdate "Last Update [%1$td.%1$tm.%1$tY, %1$tH:%1$tM]" <time> {channel="gpstracker:tracker:2da78bf5:lastReport"}
So far so good. Then I have defined a region “home” in OwnTracks.
But I am unsure what I should do with:
Switch iPhone_OwntracksHome "Owntracks Home [%s]" {channel="gpstracker:tracker:2da78bf5:distanceSystem", profile="gpstracker:trigger-geofence"}
Especially the last part profile="gpstracker:trigger-geofence"
Do I have to change trigger-geofence
to "home"
?
In PaperUI I have the channel System Distance
which I assume just takes the location information from the openHAB settings, correct? There I renamed the “Region Name” to “home”.
But I still can’t get the switch to trigger ON when entering the home-zone in OwnTracks.
Help
There should be a Share flag in OwnTracks app. Only shared region events are shared. Check pls
Yes, it’s enabled, too.
Will take another walk in the park to retry
Before you leave play a bit with advanced setting of your OwnTracks app. Phones usually don’t like to run things in the background. Try different settings for Preferences/Advanced/… settings.
Already did. I used to have owntracks working with MQTT and mqttitude binding for several months long ago so I know the settings … well unless they changed how that thing works. This is why I’m wondering why it doesn’t send anything…
The correct syntax is:
Switch iPhone_OwntracksHome "Owntracks Home [%s]" {channel="gpstracker:tracker:2da78bf5:regionTrigger" [profile="gpstracker:trigger-geofence", regionName="home"]}
This should link the switch to trigger channel and set the region name to home
Ok, that still means that I need an enter/leave event from OwnTracks, right?
I have updated the setup now but I can only test tomorrow.
Thank you!
Yes. This only provides you a stateful switch item preserving the last state update received from OwnTracks.
There is a free windows application called Postman I used for testing. It can POST json payloads to OH…
Nice! Spares me the walk in the park
Just downloaded and installed it - would you be willing to share an example json payload with an enter
-event?
I have never really worked with json…
Sure. Change the tid
to match your settings.
This is a simple location update:
{"_type":"location","tid":"??","acc":10.0,"lat":48.536263579765404,"lon":17.16983495684085,"tst":1527966973,"wtst":1524244195,"t":"c","batt":96}
Entering:
{"_type":"transition","tid":"??","acc":10.0,"desc":"Home","event":"enter","lat":48.5193629,"lon":17.2280611,"tst":1527966973,"wtst":1524244195,"t":"c"}
Then leaving:
{"_type":"transition","tid":"??","acc":10.0,"desc":"Home","event":"leave","lat":48.5193629,"lon":17.2280611,"tst":1527966973,"wtst":1524244195,"t":"c"}
Set POST as action and you wont need any authentication if you set the direct OH url on your local network.
That is really interesting. But I can’t get a leave or enter message to trigger my switch:
{channel="gpstracker:tracker:2da78bf5:distanceSystem" [profile="gpstracker:trigger-geofence", regionName="home"]}
{"_type":"transition","tid":"c1","acc":10.0,"desc":"home","event":"enter","lat":xx.xxxxx,"lon":xx.xxxxx,"tst":1527966973,"wtst":1524244195,"t":"c"}
Any idea why?
openHAB reacts to the location entered though - so the message is received.
No. Check my example above. The channel is NOT distanceSystem
but regionTrigger
. The switch should be linked to the trigger channel.
{channel=“gpstracker:tracker:2da78bf5:regionTrigger” [profile=“gpstracker:trigger-geofence”, regionName=“home”]}
Check in the PaperUI. You should see the switch if you open the trigger channel.
This is a bug in the documentation. Ill fix that later…
Duh, right. To be on the safe side I deleted the thing and let the binding re-discover it.
it seems I also had an incorrect TID.
Now it looks like below - but the switch is still not triggering.
Number iPhone_ChristianOwntracks_BatteryLevel "Battery Level [%d %%]" <battery> {channel="gpstracker:tracker:c1:batteryLevel"}
Location iPhone_ChristianOwntracks_Location "Coordinates" {channel="gpstracker:tracker:c1:lastLocation"}
DateTime iPhone_ChristianOwntracks_LastUpdate "Last Update [%1$td.%1$tm.%1$tY, %1$tH:%1$tM]" <time> {channel="gpstracker:tracker:c1:lastReport"}
Switch iPhone_ChristianOwntracksHome "Christian Owntracks Home [%s]" {channel="gpstracker:tracker:c1:regionTrigger" [profile="gpstracker:trigger-geofence", regionName="home"]}
I thing the config is ok now. So the home is defined in the binding now and NOT in OwnTracks app. In this case you should send only the first location type json payload (as the OwnTracks doesn’t know anything about the region defined in the binding). Play with the coordinates in the location message: send something far and then in the next message the coordinates of the home. It should work.
Transition messages can be used only in case the region is external (defined in OwnTracks)
Ok, I guess that was my misunderstanding. I will play with the settings and see if that helps.
Thank you for your help!
BTW in you edit the link under the trigger channel can you see the Geofencing profile and the home region selected? That’s important and I can’t see that on the screenshots…