Own tracks on Google Map

Current post describes implementation of OwnTracks geo data and then draw they on Google Maps.

First of all long time ago I installed on my phone OwnTracks application which allows you to track your geo location and as transport it uses MQTT server. In my project I’m using my own MQTT server installed on Raspberry PI 3. Based on security reasons I implemented secured TLS protocol for MQTT server based on my certificate and used login/pass authentication from device.

Then I had created items to track data in OpenHab application, so I’ve created next lines in my Items file:

String srodionov_location_RAW { mqtt="<[mosquitto:owntracks/openhab/srodionov:state:default]" }
String srodionov_location

and added item to my persistence into my jdbc.persist file:

Items {
 Temperature* : strategy = every5Minutes
 Power_Consumption_KWh, Power_Meter, srodionov_location : strategy = everyChange
 restoreState* : strategy = restoreOnStartup

BTW, some time ago I’ve switched from rrdj persistence to jdbc(mariaDB) due the first one doesn’t have required accuracy (it able to track data only once in minute,

not less )

I also added a rule to convert RAW data received from OwnTracks to my OpenHab geo position variable.

rule "Parse srodionov location"
 Item srodionov_location_RAW changed
 val String json = (srodionov_location_RAW.state as StringType).toString
 val String type = transform("JSONPATH", "$._type", json)
 if (type == "location") 
 val String latLon = transform("JSONPATH", "$.lat", json) + "," + transform("JSONPATH", "$.lon", json)

And one last thing, I’ve created map.html file in OpenHab html folder and added this page into my SiteMap file which draw Google Map itself. Through ajax request I’m getting persisted data about my location and drawing line and markers. I added simple comb

o box to have ability watch data for last day, week and month.

Leave a Reply

Your email address will not be published.