Please help! google map mqtt + owntracks on OH2?

Hello friends I have a question:
I see this thread on github:

https://github.com/openhab/openhab1-addons/wiki/GoogleMap

So i create exactly the same the example:
Items:

Location locationPatrik
String   mqttPositionPatrikRaw  "Patrik Raw Data"   { mqtt="<[home:owntracks/Lex/LexLuther:state:default]" }
String   mqttPatrikLatitude     "Patrik's Lat"
String   mqttPatrikLongitude    "Patrik's Lon"
String   mqttPatrikAccuracy     "Patrik's Accuracy"
String   mqttHtcOneBattery      "Patrik's HTC One Battery [%s%%]"       <battery>   (Phone, MQTT, Battery)

.rule:

import org.openhab.core.library.types.*

rule "MqttPostionParsePatrik"
  when 
    Item mqttPositionPatrikRaw changed
  then
    val String json = (mqttPositionPatrikRaw.state as StringType).toString
    // {"_type": "location", "lat": "47.5010314", "lon": "8.3444293",
    //    "tst": "1422616466", "acc": "21.05", "batt": "40"}
    val String type = transform("JSONPATH", "$._type", json)
    if (type == "location") {
      val String lat  = transform("JSONPATH", "$.lat", json)
      val String lon  = transform("JSONPATH", "$.lon", json)
      val String acc  = transform("JSONPATH", "$.acc", json)
      val String batt = transform("JSONPATH", "$.batt", json)

      mqttPatrikLatitude.postUpdate(lat)
      mqttPatrikLongitude.postUpdate(lon)
      locationPatrik.postUpdate(new PointType(lat + "," + lon))
      mqttPatikAccuracy.postUpdate(new DecimalType(acc))
      mqttHtcOneBattery.postUpdate(new PercentType(batt))
    }
  end

.html:

<!DOCTYPE html>
<html>
  <head>    
    <style type="text/css"> 
    <!--
    .Flexible-container {
      position: relative;
      padding-bottom: 0px;
      padding-top   : 0px;
      height        : 345px ;
      overflow: hidden;
    }

    .Flexible-container iframe,   
    .Flexible-container object,  
    .Flexible-container embed {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
   -->
   </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places,drawing,geometry"></script>

    <script type="text/javascript">
        ////////////////////////////////////////////////////////////////////////
        // Google Maps JavaScript API:
        // https://developers.google.com/maps/documentation/javascript/?hl=de
        // Marker Icons:
        // https://sites.google.com/site/gmapsdevelopment/
        ////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////
        // JQuery
        ////////////////////////////////////////////////////////////////////////

        var map = null;
        //make an empty bounds variable
        var bounds = new google.maps.LatLngBounds();

        // LatLng's we want to show 
        var latlngHome   = new google.maps.LatLng("47.501006", "8.344842");
        var latlngPatrik = new google.maps.LatLng("47.501006", "8.344842"); // initialize to home ...
        var latlngKarin  = new google.maps.LatLng("47.501006", "8.344842"); // initialize to home ...

        var map_options = { center    : latlngHome,
                            zoom      : 10,
                            mapTypeId : google.maps.MapTypeId.ROADMAP };

        $( "#map_canvas" ).ready($(function() {
          var map_canvas = document.getElementById('map_canvas');
          map = new google.maps.Map(map_canvas, map_options)

          var marker = new google.maps.Marker({
                            position  : latlngHome,
                            map       : map,
                            icon      : 'http://maps.google.com/mapfiles/kml/pal2/icon10.png',
                            title     : "Ehrendingen"
                        })

           var circle = new google.maps.Circle({
                        center        : latlngHome,
                        radius        : 1500,
                        map           : map,
                        strokeColor   : '#050505',
                        strokeOpacity : 0.5,
                        strokeWeight  : 2,
                        fillColor     : '#000000',
                        fillOpacity   : 0,
                      }); // end of [Circle]

           bounds.extend(latlngHome);
        }))

        $( document ).ready($(function() {
            // ******************************************************************************
            $.ajax({
              url     : "../rest/items/locationPatrik/state/",
              data    : {},
              success : function( data ) {
                  if ( map == null) { return; }
                  if ( data == "Uninitialized") { return; }

                  var coords = data.split(',');
                  var latlngPatrik = new google.maps.LatLng(coords[0],coords[1]);

                  var marker = new google.maps.Marker({
                    position  : latlngPatrik,
                    map       : map,
                    icon      : 'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
                    title     : "Patrik"
                  }) // end of [Marker]

                  $.ajax({
                    url     : "../rest/items/mqttPatikAccuracy/state/",
                    data    : {},
                    success : function( data ) {
                    if ( data == "Uninitialized") { return; }
                      var accuracy = parseInt(data);
                      var circle = new google.maps.Circle({
                        center        : latlngPatrik,
                        radius        : accuracy,
                        map           : map,
                        strokeColor   : '#00FF00',
                        strokeOpacity : 0.8,
                        strokeWeight  : 2,
                        fillColor     : '#00FF00',
                        fillOpacity   : 0.35,
                      }); // end of [Circle]

                      bounds.extend(latlngPatrik);
                      map.fitBounds(bounds);

                    } // end of [function]
                  }) // end of [$.ajax]
                } // end of [function]
            }) // end of [$.ajax]
            // ******************************************************************************
            $.ajax({
              url     : "../rest/items/locationKarin/state/",
              data    : {},
              success : function( data ) {
                  if ( map == null) { return; }
                  if ( data == "Uninitialized") { return; }

                  var coords = data.split(',');
                  var latlngKarin = new google.maps.LatLng(coords[0],coords[1]);

                  var marker = new google.maps.Marker({
                    position  : latlngKarin,
                    map       : map,
                    icon      : 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
                    title     : "Karin"
                  }) // end of [Marker]

                  $.ajax({
                    url     : "../rest/items/mqttKarinAccuracy/state/",
                    data    : {},
                    success : function( data ) {
                    if ( data == "Uninitialized") { return; }
                      var accuracy = parseInt(data);
                      var circle = new google.maps.Circle({
                        center        : latlngKarin,
                        radius        : accuracy,
                        map           : map,
                        strokeColor   : '#00FF00',
                        strokeOpacity : 0.8,
                        strokeWeight  : 2,
                        fillColor     : '#00FF00',
                        fillOpacity   : 0.35,
                      }); // end of [Circle]

                      bounds.extend(latlngKarin);
                      map.fitBounds(bounds);
                    } // end of [function]
                  }) // end of [$.ajax]
                } // end of [function]
            }) // end of [$.ajax]
            // ******************************************************************************
        }))
    </script>
  </head>
  <body>
    <div id="map_canvas" class="Flexible-container" />
  </body>
</html>

the only change is the coordinate in html - i amended to adapt to my current location:

]       // LatLng's we want to show 
        var latlngHome   = new google.maps.LatLng("47.501006", "8.344842");
        var latlngPatrik = new google.maps.LatLng("47.501006", "8.344842"); // initialize to home ...
        var latlngKarin  = new google.maps.LatLng("47.501006", "8.344842"); // initialize to home ...

I successfully made it displayed on my OH2 classic UI.
But I’ve an little obstacle and I hope you guys can help me
I installed owntracks for my android phone:


I don’t know how to config this app so that it can connect to my OH2 host (on raspberry pi 3) and send my phone’s location to the .html file. Please show me how?
If it doesn’t work with OH2, can you suggest me other ways to display my phone’s location on google map?

Have a look at ot-recorder (https://github.com/owntracks/recorder)
once setup (quite easy and well documented, you can integrate this in your sitemaps with a webview.
Works like a charm!

Thanks for the link
 :slight_smile:

In light of recent talk around documentation, I tried to install this app on a rPi and followed the guide to a T; and got to the point of launching the app, when the OS complained about “file not found”
 great! :blush:

@stefaanbolle
OK I followed all this steps:

Debian 8 "Jessie":

curl http://repo.owntracks.org/repo.owntracks.org.gpg.key | sudo apt-key add -
echo "deb  http://repo.owntracks.org/debian jessie main" | sudo tee /etc/apt/sources.list.d/owntracks.list > /dev/null
sudo apt-get update
sudo apt-get install libsodium-dev libsodium13
sudo apt-get install ot-recorder
systemd service

The packages we provide have a systemd unit file in /usr/share/doc/ot-recorder/ot-recorder.service which you can use to have the Recorder started automatically:

Ensure you have a configuration file with the settings you require
install -m444 /usr/share/doc/ot-recorder/ot-recorder.service /etc/systemd/system/ot-recorder.service
Enable the service to run at startup: systemctl enable ot-recorder
Launch the service systemctl start ot-recorder

It’s apparently that I don’t need Docker image
Then I continued to follow “Getting started” section and I was stuck right here. It said to launch the ot-recorder, I have to use this command:

$ ./ot-recorder 'owntracks/#'

But an error occurred:

-bash: owntracks/#: No such file or directory

Sorry, can’t help, but can confirm that I tried the same steps and got the same result. :frowning:

figured it out
 the following works for me:

sudo /usr/sbin/ot-recorder 'owntracks/#'

you would have to change the config in case you want to access the browser out of OTR from another rmachine, with

sudo nano /etc/default/ot-recorder

Oh thanks it works for me tooo <3
But what exactly is your idea by saying: “change the config”, may I ask?
Sorry I just a noob @Max_G

I have the original query working on my OH2 system, but beware that webviews are finicky with regards to being able to view them via myopenhab.

Items:

////Paul
Switch		phonePaul			"SGS7 Edge [%s]"       			<android>		(gPresencePaul, gPresence)       	{channel="network:device:PhonePaul:online"}
Switch		ownTracksPaul			"Paul - OwnTracks"  			<man>			(gPresencePaul, gPresence)       	{mqttitude="mosquitto:owntracks/paul/Paul/event:home" }

String		locationPaulPhone  		"Paul's Location [%s]"    						(gLocations)                   	{mqtt="<[mosquitto:owntracks/paul/Paul:state:JS(mqtt-coordinates.js)]"}

String		ownTracksPaulRaw		"Paul Raw Data [%s]"   										  {mqtt="<[mosquitto:owntracks/paul/Paul:state:default]"}
Number		ownTracksPaulLat		"Paul's Latitude [%.3f °]"  	<latitude>
Number		ownTracksPaulLon		"Paul's Longitude [%.3f °]"		<longitude>
Number		ownTracksPaulAcc		"Paul's Accuracy [%d m]"		<accuracy>
Number		ownTracksPaulBatt		"Paul's Battery [%s %%]"		<battery>

Rule:

// Owntracks Paul Raw data conversion
rule "Mqtt Position - Paul"
  when
    Item ownTracksPaulRaw changed
  then
  logInfo("MQTT", "OwnTracks Updated for Paul")
    val String json = (ownTracksPaulRaw.state as StringType).toString
    val String type = transform("JSONPATH", "$._type", json)
    if (type == "location") {
      val String lat  = transform("JSONPATH", "$.lat", json)
      val String lon  = transform("JSONPATH", "$.lon", json)
      val String acc  = transform("JSONPATH", "$.acc", json)
      val String batt = transform("JSONPATH", "$.batt", json)
      ownTracksPaulLat.postUpdate(new DecimalType(lat)*1)
      ownTracksPaulLon.postUpdate(new DecimalType(lon)*1)
      ownTracksPaulAcc.postUpdate(new DecimalType(acc)*1)
      ownTracksPaulBatt.postUpdate(new PercentType(batt)*1)
    }
end

html:

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
    <!--
    .Flexible-container {
      position: relative;
      padding-bottom: 0px;
      padding-top   : 0px;
      height        : 355px ;
      overflow: hidden;
    }

    .Flexible-container iframe,
    .Flexible-container object,
    .Flexible-container embed {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
   -->
   </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places,drawing,geometry"></script>

    <script type="text/javascript">
        ////////////////////////////////////////////////////////////////////////
        // Google Maps JavaScript API:
        // https://developers.google.com/maps/documentation/javascript/?hl=de
        // Marker Icons:
        // https://sites.google.com/site/gmapsdevelopment/
        ////////////////////////////////////////////////////////////////////////

        ////////////////////////////////////////////////////////////////////////
        // JQuery
        ////////////////////////////////////////////////////////////////////////

        var map = null;
        //make an empty bounds variable
        var bounds = new google.maps.LatLngBounds();

        // LatLng's we want to show
        var latlngHome   = new google.maps.LatLng("-41.338395", "174.780842");
        var latlngPaul   = new google.maps.LatLng("-41.338395", "174.780842"); // initialize to home ...
        var latlngEmily  = new google.maps.LatLng("-41.338395", "174.780842"); // initialize to home ...

        var map_options = { center    : latlngHome,
                            zoom      : 15,
                            mapTypeId : google.maps.MapTypeId.ROADMAP };

        $( "#map_canvas" ).ready($(function() {
          var map_canvas = document.getElementById('map_canvas');
          map = new google.maps.Map(map_canvas, map_options)

          var marker = new google.maps.Marker({
                            position  : latlngHome,
                            map       : map,
                            icon      : 'http://maps.google.com/mapfiles/kml/pal2/icon10.png',
                            title     : "Home"
                        })

           var circle = new google.maps.Circle({
                        center        : latlngHome,
                        radius        : 150,
                        map           : map,
                        strokeColor   : '#050505',
                        strokeOpacity : 0.5,
                        strokeWeight  : 2,
                        fillColor     : '#000000',
                        fillOpacity   : 0,
                      }); // end of [Circle]

           bounds.extend(latlngHome);
        }))

        $( document ).ready($(function() {
            // ******************************************************************************
            $.ajax({
              url     : "http://192.168.1.20:8080/rest/items/locationPaulPhone/state/",
              data    : {},
              success : function( data ) {
                  if ( map == null) { return; }
                  if ( data == "Uninitialized") { return; }

                  var coords = data.split(',');
                  var latlngPaul = new google.maps.LatLng(coords[0],coords[1]);

                  var marker = new google.maps.Marker({
                    position  : latlngPaul,
                    map       : map,
                    icon      : 'http://maps.google.com/mapfiles/ms/icons/blue-dot.png',
                    title     : "Paul"
                  }) // end of [Marker]

                  $.ajax({
                    url     : "http://192.168.1.20:8080/rest/items/ownTracksPaulAcc/state/",
                    data    : {},
                    success : function( data ) {
                    if ( data == "Uninitialized") { return; }
                      var accuracy = parseInt(data);
                      var circle = new google.maps.Circle({
                        center        : latlngPaul,
                        radius        : accuracy,
                        map           : map,
                        strokeColor   : '#00FF00',
                        strokeOpacity : 0.8,
                        strokeWeight  : 2,
                        fillColor     : '#00FF00',
                        fillOpacity   : 0.35,
                      }); // end of [Circle]

                      bounds.extend(latlngPaul);
                      map.fitBounds(bounds);

                    } // end of [function]
                  }) // end of [$.ajax]
                } // end of [function]
            }) // end of [$.ajax]
            // ******************************************************************************
            $.ajax({
              url     : "http://192.168.1.20:8080/rest/items/locationEmilyPhone/state/",
              data    : {},
              success : function( data ) {
                  if ( map == null) { return; }
                  if ( data == "Uninitialized") { return; }

                  var coords = data.split(',');
                  var latlngEmily = new google.maps.LatLng(coords[0],coords[1]);

                  var marker = new google.maps.Marker({
                    position  : latlngEmily,
                    map       : map,
                    icon      : 'http://maps.google.com/mapfiles/ms/icons/pink-dot.png',
                    title     : "Emily"
                  }) // end of [Marker]

                  $.ajax({
                    url     : "http://192.168.1.20:8080/rest/items/ownTracksEmilyAcc/state/",
                    data    : {},
                    success : function( data ) {
                    if ( data == "Uninitialized") { return; }
                      var accuracy = parseInt(data);
                      var circle = new google.maps.Circle({
                        center        : latlngEmily,
                        radius        : accuracy,
                        map           : map,
                        strokeColor   : '#00FF00',
                        strokeOpacity : 0.8,
                        strokeWeight  : 2,
                        fillColor     : '#00FF00',
                        fillOpacity   : 0.35,
                      }); // end of [Circle]

                      bounds.extend(latlngEmily);
                      map.fitBounds(bounds);
                    } // end of [function]
                  }) // end of [$.ajax]
                } // end of [function]
            }) // end of [$.ajax]
            // ******************************************************************************
        }))
    </script>
  </head>
  <body>
    <div id="map_canvas" class="Flexible-container" />
  </body>
</html>

I think that’s everything you need to get it working. I also have another user, Emily, viewable on my map. The setup for her in the html is retained, but I have not added her items or rule as they are identical to mine.

You must also have both the MQTT 2.0 binding, and the mqttitude 1.9 binding installed I believe.

1 Like

Oh thanks for your answer
Your configuration is quite similar to this trick tutorial:


but the only thing remaining - forgive for my silliness - that I don’t understand how to configure the Owntracks app on my android phone so that it can form a connection between the items from openhab and my phone’s location. Because I don’t see any option for me to choose what item I want to update my position information
Hope you can answer

You need to install owntracks and configure it to connect to the mqtt install you have set up at home.

It is this mqtt system that receives the owntracks published data that you have set up on your phone. In my case my Android device publishes to owntracks/paul/Paul but could be owntracks/paul/Phone or any other variation of owntracks/x/x

You then have to make sure that your OH item subscribes to this topic. You can see how I have this set up in my items. eg. ownTracksPaulRaw.

OK, I installed Owntracks app on my Android phone already
so you mean that I have to install Owntracks as a service on my PC right? Do you have the tutorial link?

You don’t install owntracks on the PC, you install a MQTT server (such as Mosquitto) and that acts as the intermediary between the Owntracks android app and the openHAB MQTT binding.

Oh yes I did have mosquitto on my raspberry pi (using sudo apt-get install lib-mosquitto), I configed the Owntracks android app in private MQTT mode and targeted the host at : raspberrypi.mshome.net, port: 8080 because this is my local IP address
What else should I do?
Will you please share elaborately your procedure of getting everything done? Thanks alot!! I hope you could show me, this would be a nice tutorial for me as well as others who are experiencing this problem

Run, run
 two newbies trying to get this sorted
 :slight_smile:

I implemented Paul’s code in OH1
 funnily enough I am getting this in my log:

2017-01-26 20:27:47.704 [WARN ] [o.u.i.items.ItemUIRegistryImpl] - Exception while formatting value '-27.31778165328067' of item GeoLoc_MaxG_Lat with format '%.3f °': java.util.IllegalFormatConversionException: f != java.lang.String

Yet I have an item elsewhere:

Number   INET_DOWN		"Download speed [%.2f Mbit/s]"

which works without issues.

My item looks like Paul’s:

Number GeoLoc_MaxG_Lat		"Max's Latitude is [%.3f °]"

but spits the warning above


Any hints appreciated


Sorry for being unspecific


config means edit the OTR configuration file with;

sudo nano /etc/default/ot-recorder

and change the following from localhost to the IP address of the computer you are running ORT; e.g. 192.168.1.5

# -----------------------------------------------------
# Address for the HTTP module to bind to (default: localhost)
#
OTR_HTTPHOST="192.168.1.5"
1 Like

Oh tks,
But I can’t get thing to work
Here is what I did:

  1. Execute these commands: (I’m using debian 8 jessie on raspberry pi 3)
curl http://repo.owntracks.org/repo.owntracks.org.gpg.key | sudo apt-key add -
echo "deb  http://repo.owntracks.org/debian jessie main" | sudo tee /etc/apt/sources.list.d/owntracks.list > /dev/null
sudo apt-get update
sudo apt-get install libsodium-dev libsodium13
sudo apt-get install ot-recorder

And then:

sudo install -m444 /usr/share/doc/ot-recorder/ot-recorder.service /etc/systemd/system/ot-recorder.service
sudo systemctl enable ot-recorder
sudo systemctl start ot-recorder

I skipped the Docker part because when I use:

apt-get install build-essential linux-headers-$(uname -r) libcurl4-openssl-dev libmosquitto-dev liblua5.2-dev libsodium-dev libconfig-dev

I got an error like this:

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-4.4.26-v7
E: Couldn't find any package by regex 'linux-headers-4.4.26-v7'

Thus I went straight to Getting started part, here, firstly I typed:

sudo /usr/sbin/ot-recorder 'owntracks/#'

the result is 
quite sad:


ot-recorder[20566]: version 0.6.9 starting with STORAGEDIR=/var/spool/owntracks/recorder/store
ot-recorder[20566]: connecting to MQTT on mymosquitto:1883 as clientID openhab without TLS
Unable to connect (15) [Lookup error.]: unknown reason.
#(@)ot-recorder.default
#
# Specify global configuration options for the OwnTracks Recorder
# and its associated utilities to override compiled-in defaults.
# Lines beginning with # are comments
# *** In libconfig versions < 1.4 a trailing semicolon is mandatory

# -----------------------------------------------------
# Storage directory
#

OTR_STORAGEDIR="/var/spool/owntracks/recorder/store"

# -----------------------------------------------------
# Address or hostname of the MQTT broker
#
OTR_HOST="mymosquitto"

# -----------------------------------------------------
# MQTT can be disabled by setting this to 0.
#

OTR_PORT=1883

# -----------------------------------------------------
# Username for the MQTT connection
#

# OTR_USER=""

# -----------------------------------------------------
# Password for the MQTT connection
#

# OTR_PASS=""

# -----------------------------------------------------
# QoS for MQTT connection
 OTR_QOS=0

# -----------------------------------------------------
# MQTT clientid (default is constant+hostname+pid)
#

OTR_CLIENTID="openhab"

# -----------------------------------------------------
# Path to PEM-encoded CA certificate file for MQTT (no default)

# OTR_CAFILE=""

# -----------------------------------------------------
# Address for the HTTP module to bind to (default: localhost)
#

OTR_HTTPHOST="raspberrypi.mshome.net"
# -----------------------------------------------------
# Port number for the HTTP module to bind to (default: 8083)
#
OTR_HTTPPORT=8083

# -----------------------------------------------------
# optional path to HTTP directory in which to store
# access log. Default is to not log access

# OTR_HTTPLOGDIR=""

# -----------------------------------------------------
# API key for reverse-geo lookups
#

OTR_GEOKEY="xxxx"

# -----------------------------------------------------
# Reverse geo precision
OTR_PRECISION=7

# -----------------------------------------------------
# Browser API key for Google maps
#
OTR_BROWSERAPIKEY="xxxx"

# -----------------------------------------------------
# List of topics for MQTT to subscribe to, blank separated in a string
#

OTR_TOPICS="owntracks/ben/Ben"

OTR_HOST is my MQTT broker’s name, I’m playing quite good with mqtt binding to turn on/off other items as well as update value to them. However I can’t transfer my phone location information to Oh2.
OTR_PORT is 1883 because I also used this port in /etc/openhab2/services/mqtt.cfg
No user and password, QTR_QoS=0. OTR_ClientID=“openhab” these 3 parameters are exactly the same in mqtt.cfg
OTR_HTTPHOST:raspberrypi.mshome.net ( raspberrypi.mshome.net IS my IP address, many guys asked me what is this but I used this all the time and I’m sure that there is no matter using this)
OTR_HTTPPORT=8083
OTR_GEOKEY=“xxxx” - this is the google map api key
OTR_PRECISION=7
OTR_BROWSERAPIKEY=“xxxx” - this is the google map api key
OTR_TOPICS=“owntracks/dong/Dong”

Items:

String		locationBenPhone  		"Ben's Location [%s]" <position>(Locations)                   	{mqtt="<[mymosquitto:owntracks/ben/Ben:state:JS(mqtt-coordinates.js)]"}
String ownTracksBenRaw "Ben Raw Data [%s]"<position>{mqtt="<[mymosquitto:owntracks/ben/Ben:state:default]"}
Number ownTracksBenLat "Bens Latitude [%.3f °]"<position>
Number ownTracksBenLon "Ben's Longitude [%.3f °]"<position>
Number ownTracksBenAcc "Ben's Accuracy [%d m]"<accuracy>
Number ownTracksBenBatt "Ben's Battery [%s %%]"		<battery>

Sitemap:

Text item=locationBenPhone  
Text item = ownTracksBenRaw 

On my android, I choose Private MQTT mode, Host: raspberrypi.mshome.net, port:8083. No identification, no security, no parameters. I allow Owntracks to know my location, it does spot out where I am, then I press the little arrow-like button on the right-corner of Owntracks app. Unfortunately, nothing happens.

As a beginner, I sincerely want to know the step-by-step configuration procedure of yours. I hope you can spend time and tell me how did you get it done specifically by writing and post in here. That would be a great help for all beginners like us, I just want to end this nightmare :v: @Max_G

only if I change these to:

val Number lat  = transform("JSONPATH", "$.lat", json)
val Number lon  = transform("JSONPATH", "$.lon", json)

can I avoid the error msg for the incorrect formatting on:

Number		ownTracksPaulLat		"Paul's Latitude [%.3f °]"

@Max_G My example is setup to work in OH2. You’ve clearly figured out some of the fixes to make it work in OH1.

I forgot to add my mqtt-coordinates.js file (located in the transformations folder). Bear in mind this will probably mean you need to install the Javascript transformation


mqtt-coordinates.js

var location = eval('(' + input + ')');
result = location.lat + "," + location.lon;

After searching I have some progress, I can see the update from my phone location GPS on terminal screen now, but one problem remaining - I receive this:

ot-recorder[15116]: version 0.6.9 starting with STORAGEDIR=/var/spool/owntracks/recorder/store
ot-recorder[15116]: connecting to MQTT on m11.cloudmqtt.com:xxxx as clientID openhab without TLS
ot-recorder[15116]: HTTP listener started on 127.0.0.1:8083
ot-recorder[15116]: Using storage at /var/spool/owntracks/recorder/store with precision 7
ot-recorder[15116]: Subscribing to owntracks/# (qos=2)
curl_easy_perform() failed: Timeout was reached
- 02:14:55 owntracks/cur1/Ben             t=u tid=do loc=xxxx,xxxx [__] revgeo failed for (xxx,xxx) (w3u4uw4)
curl_easy_perform() failed: Timeout was reached
- 02:15:11 owntracks/cur1/Ben                 t=u tid=do loc=xxx,xxx [__] revgeo failed for (xxxx,xxxx (w3u4uw4)

I’m quite confused why it said timeout was reached and revgeo failed

How can I fix that?
One last thing, my phone’s location doesn’t update unless I press the arrow-like button on the top-corner, anyway to help it automatically update my location?
@Max_G As I can see you’ve forwarded your router’s port right?

Please answer
I’ve been thinking alot.
I suppose you forwarded port on your router so that we can transmit our GPS location data from owntracks app to your raspberry pi’s right? @Max_G