GPSBinding Distance from location not working


(captain118) #1

I have setup the GPS binding just like in the tutorial using ontracks. It would appear that everything is working but the region settings. I have tried several variations but I cant seem to get either the distance from home or atHome working. No matter what I try I get a message that the item does not exist. The docs dont really explain the channels part of the things file.

Things

//tracker definition with extra distance channel
Thing gpstracker:tracker:KM   "Kirk tracker" [trackerId="KM"] {
    Channels:
            Type regionDistance : homeDistance "Distance from Home" [
                regionName="Home",
                regionCenterLocation="44.7736825,-46.6935502",
                regionRadius=100,
                accuracyThreshold=30
            ]
}

Items:

//items for basic channels
Location        locationKM      "Location"              {channel="gpstracker:tracker:KM:lastLocation"}
DateTime        lastSeenKM      "Last seen"             {channel="gpstracker:tracker:KM:lastReport"}
Number          batteryKM       "Battery level"         {channel="gpstracker:tracker:KM:batteryLevel"}
Number:Length           accuracyKM      "GPS Accuracy [%d m]"           {channel="gpstracker:tracker:KM:gpsAccuracy"}

//linking switch item to regionTrigger channel. assuming the Home distance channel is defined in the binding config (see above)
Switch atHomeKM "Home presence" {channel="gpstracker:tracker:KM:regionTrigger" [profile="gpstracker:trigger-geofence", regionName="Home"]}

//another switch for work region. assuming the OTWork is defined in OwnTracks application (no distance channel is needed like for Home)
Switch atWorkKM "Work presence" {channel="gpstracker:tracker:KM:regionTrigger" [profile="gpstracker:trigger-geofence", regionName="Work"]
}

SItemap:

sitemap gpstracker label="GPSTracker Binding" {
    Text        item=homeDistance
    Switch      item=atWorkKM
    Switch      item=atHomeKM
    Text        item=lastSeenKM
    Text        item=batteryKM
    Text        item=accuracyKM
    Mapview item=locationKM height=4
}

(Rich Koshak) #2

It will be easier to read your configs if you How to use code fences.

I can’t help with you specific problem but code fences will help those who can.


(Gabor Bicskei) #3

You have two items with the same name. The .items file will not load this way…


(captain118) #4

I’m not sure how that happened but thanks for catching it. Sadly it didnt solve the problem. Same situation everything works but the distance from location and the region settings.


(Marco) #5

homeDistance seems to be a thing channel in your configuration, not an item. So probably that’s where the ‘item does not exist’ error comes from.


(captain118) #6

I saw that, but since thats how they have it in the documentation that is how I did it.
The documentation didnt really go into how channels in a thing config file works so I didnt know where to go other than the forums.


(Marco) #7

Try to put the following in your items file and see if that works:

Number:Length homeDistance "Distance from home" { channel="gpstracker:tracker:KM:distanceSystem" }

(captain118) #8

I just figured it out you were close:

The definition of the channel in the thing file makes the option homeDistance available as a channel source for a thing.

Number homeDistanceKM "Distance From Home" {channel="gpstracker:tracker:KM:homeDistance"}

I submitted a pull request for that page so the documentation includes it.

Thanks for the help guys.