Please help! google map mqtt + owntracks on OH2?

Well, I think my set-up is fundamentally different than yours…

I use OwnTracks on iPhone, sending the positions to my rPi server running MQTT at home via port forwarding in my Internet router, then storing these positions in OwnTrackRecorder (OT-Recorder).

You seem to have a cloud service provider in between it all; meaning there could be other problems I cannot see / understand in your system.

The way I build my system with OH is: start small… and progress step by step.
E.g. I installed OH, then MQTT. Then OT on the iPhone and the OH OT binding, and made it work on the local network first (meaning, no port forwarding required).
Then I opened the port… after this worked, I installed OTR.

I have since removed mqttitude binding, and work only with MQTT in OH.

I do not believe that I am able to help you further, given our set-ups are different.

OK thanks for replying
May be I’ll backup and follow your route
Firstly, let’s make it talk within local network first.
I installed Owntracks (mqttitude binding) already. I tested 2 command: "mosquitto_sub -t “owntracks/#” on 1 screen and “mosquitto_pub -t “owntracks/ben” -m hello” on another, everything worked fine.
On Owntracks app, I chose private MQTT mode, host: 192.168.137.2 (this is my raspberry pi ip address), port:8080, no websocket. Identification: username:pi, password:(my raspberry login password), Device ID: ben, track id: be
No TLS, No parameters
I have one item which is defined as:

Switch  PresenceBen_PhoneMqttHome   "Ben @ Home"   { mqttitude="mymosquitto:owntracks/ben/event:home" }

Please instruct me, @Max_G, you’re my only hope

Hi, i want to start with MQTT and Owntracks on OH2.

I have already working owntracks on my android smartphone and working mosquitto server on my debian-server. I´m on OH2.1 Snapshot release.

But i can´t get any data inside openhab.

Can someone help me to configure my mqtt-binding and items?

Only thing in my mqtt.cfg is this:

mosquitto.url=tcp://localhost:1883

No authentication, no encryption (for testing). On my debian shell i get this output of mqtt-client:


owntracks/mosquitto/note4 {"_type":"location","tid":"e4","acc":20,"batt":21,"conn":"w","doze":false,"lat":xx.1234567,"lon":yy.1234567,"tst":1493879351}

How can i test if i get data inside openhab?

My item for testing is:

String  locationPhone  "Test Raw Data [%s]"   { mqtt="<[mosquitto:owntracks/mosquitto/note4:state:default]" }

I´ve found this example in this thread. But it doesn´t seems to work. I don´t get any values to this item (i´m showing it on my sitempa).

Hi @halloween,

I use println statement(s) during in my rules during development to see if I does what I expect. Maybe the following snippet is of help:

rule PositionPatrik
  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)
    println("MQQT: " + 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)

with kind regards,
Patrik

2 Likes

I am also trying this but get this error:

[ERROR] [.script.engine.ScriptExecutionThread] - Rule 'MqttPostionParseCraig': Could not initialize class com.jayway.jsonpath.internal.DefaultsImpl

My mqqt works as I get

[vent.ItemStateChangedEvent] - mqttPositionCraigRaw changed from {"_type":"location","tid":"CL","acc":22,"batt":83,"conn":"w","lat":xx.xxxxx,"lon":-yy.yyyyy,"t":"u","tst":1507125675} to {"_type":"location","tid":"CL","acc":26,"batt":74,"conn":"w","lat":xx.xxxxx,"lon":-yy.yyyyyy,"t":"u","tst":1507127788}

I just can’t parse it with JSON. I do have the transformation installed

Craig

Dunno. installed JavaScript transformation as well and it stated working…

Hi, did you manage to make it work? I am in the same problem and would need help …

Hi Antonio,

what problem do you have exactly? Make sure that you have the JSONPATH transform package installed …

with kind regards,
Patrik

Hi, i have this setup and if i connect locally to the sitemap or habpanel its working perfectly, even in the android app.
however remotely, via openhab cloud its not working at all. is this how it suppose to be or am i doing something wrong here?

regards
Matt