OwnTrack setup in Openhab - No data in Log

I come from this thread Owntracks setup to work with OH

Owntrack is working from my iphone, I get the lat and long properly, I can see them on MQTT FX, but then I do not get any data in Openhab. In the Log I do not receive any info about the LAt LONg and so on.

I am not sure, but the mqtt sentence is not right at all…

My items:

Switch   mqttJuanPresence   "Juan [MAP(presence.map):%s]" { mqttitude="mosquitto:owntracks/openhab/iphone:home"}
Switch   mqttPositionJuanRaw  "Juan Raw Data"       { mqttittude="mosquitto:owntracks/openhab/iphone:default" }

String   mqttJuanLatitude     "Juan's Lat"
String   mqttJuanLongitude    "Juan's Lon"
String   mqttJuanAccuracy     "Juan's Accuracy"
String   mqttJuanBattery      "Juan's Battery [%s%%]"           <battery>       (Phone, MQTT, Battery)

The rules

rule "Mqtt Postion Juan"
  when
    Item mqttPositionJuanRaw received update
  then
    val String json = (mqttPositionJuanRaw.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)

      mqttJuanLatitude.postUpdate(lat)
      mqttJuanLongitude.postUpdate(lon)
      locationJuan.postUpdate(new PointType(lat + "," + lon))
      mqttJuanAccuracy.postUpdate(acc)
      mqttJuanBattery.postUpdate(batt)
      logInfo("ownTRACKS", mqttPositionJuanRaw.state.toString)

    }
  end

First I would add

rule "Mqtt Postion Juan"
  when
    Item mqttPositionJuanRaw received update
  then
    logInfo("mqttPositionJuanRaw",mqttPositionJuanRaw.state)
...

to see, if the rule was started and what the value is?

I do not receive anythinhg in OH.

But with MQTT FX it is working, I get this in the sucribe screen

{
  "_type" : "waypoints",
  "waypoints" : [ {
    "_type" : "waypoint",
    "tst" : 1529667365,
    "lat" : x.24,
    "lon" : x.321,
    "rad" : 60,
    "desc" : "city"
  } ]
}```

The mqtt-binding is istalled, the settings ok, get you any other information other mqtt in oH?
What OS, oH- and java-version do you use?

I have 15 sonoff basic and dual, working with MQTT mosquitto, one camera and other sensors, also myopenhab working fine.

I am running Openhabian in RPi 3. openjdk version “1.8.0_152”

Is not a defined item… according to your list at the top

Sorry, the list above had some error, I have updated. Before posting the thread I already changed all my items properly.

It is something with the mqtt, because I do not even get any error in the logs. Evrything works fine.

MQTT binding for raw data not mqttitude

Switch   mqttPositionJuanRaw  "Juan Raw Data"       { mqtt="mosquitto:owntracks/openhab/iphone:default" }

But I got this error:

2018-06-22 19:28:07.560 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'mqtt' of item 'mqttPositionJuanRaw' could not be parsed correctly.

org.eclipse.smarthome.model.item.BindingConfigParseException: Invalid mqtt binding configuration 'mosquitto:owntracks/openhab/iphone:default' for item mqttPositionJuanRaw

	at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:52) ~[?:?]

	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:400) ~[?:?]

	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:369) ~[?:?]

	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.processBindingConfigsFromModel(GenericItemProvider.java:229) ~[?:?]

	at org.eclipse.smarthome.model.item.internal.GenericItemProvider.modelChanged(GenericItemProvider.java:435) ~[?:?]

	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.notifyListeners(ModelRepositoryImpl.java:301) ~[?:?]

	at org.eclipse.smarthome.model.core.internal.ModelRepositoryImpl.addOrRefreshModel(ModelRepositoryImpl.java:139) ~[?:?]

	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.checkFile(FolderObserver.java:227) ~[?:?]

	at org.eclipse.smarthome.model.core.internal.folder.FolderObserver.processWatchEvent(FolderObserver.java:291) ~[?:?]

	at org.eclipse.smarthome.core.service.WatchQueueReader.lambda$3(WatchQueueReader.java:323) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]```

he forgot to add a direction :slight_smile:

Great, I got it.
I had wrong the sentence. I putted Switch instead of String :smiley:

ok, now I get data in OH.

I will test the rules. I will let you know, thanks for helping, after hours in front of code, i am blind.

Well, I get this:

==> /var/log/openhab2/events.log <==

2018-06-22 19:51:13.096 [ome.event.ItemUpdatedEvent] - Item 'mqttPositionJuanRaw' has been updated.

2018-06-22 19:51:13.152 [vent.ItemStateChangedEvent] - mqttPositionJuanRaw changed from NULL to {"batt":43,"lon":xxx.7320520877928764,"acc":10,"p":xxxx,"vel":0,"vac":4,"lat":xx.xx,"conn":"w","tst":1529689018,"alt":51,"_type":"location","tid":"NE"}

And then I get this error:

2018-06-22 19:59:00.013 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Execute script IphonePresence': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null```

Can you post your rule again as it is now, please?

Yes, the rule in order this one:

Good morning,

I made some progress. It seems that the rules are working fine. But I guess that I need to move, in order to see how change the values, beacuse Owntrack does not send mqtt if stay on the same location right?

2018-06-23 08:03:56.557 [vent.ItemStateChangedEvent] - mqttPositionJuanRaw changed from  to {"tst":1529733835,"acc":1414,"_type":"location","alt":51,"lon":xxx.7336854984647179,"vac":19,"lat":xxx.385122162777407,"batt":97,"conn":"w","tid":"NE"}

2018-06-23 08:03:56.570 [vent.ItemStateChangedEvent] - mqttJuanLatitude changed from 53.2 to 52.38512216277741

2018-06-23 08:03:56.577 [vent.ItemStateChangedEvent] - mqttJuanLongitude changed from 9.34 to 9.733685498464718

2018-06-23 08:03:56.581 [vent.ItemStateChangedEvent] - mqttJuanAccuracy changed from 10 to 1414

2018-06-23 08:03:56.586 [vent.ItemStateChangedEvent] - mqttJuanBattery changed from 24 to 97

The only thing that is not working fine is the ON/OFF switch I have for the presence. This switch does not change never.

ITEMS:

Switch   mqttJuanPresence   "Juan @ Home" { mqttitude="mosquitto:owntracks/openhab/iphone/event:home"}

SITEMAP:

Switch item=mqttJuanPresence

In ‘home’ I have other word regarding to the owntrack setup. But I do not get ON/OFF.

Hope ypu may help me with this.
Thanks.

What’s right, you use mqttitude and mqttittude?

This was already fixed yesterday.

I got this message when i see the value of the switch. But never changes

2018-06-23 09:05:01.427 [INFO ] [g.eclipse.smarthome.model.script.Pre] - NULL

Thank you hr3.

I already have output in the switch, I change:

this

Switch   mqttJuanPresence   "Juan @ Home [MAP(presence.map):%s]" <present> (gPresent)   { mqttitude="mosquitto:owntracks/openhab/iphone:home”}

by this:

Switch   mqttJuanPresence   "Juan @ Home [MAP(presence.map):%s]" <present> (gPresent)   { mqttitude="mosquitto:owntracks/openhab/iphone"}

It seems is working, at least I have output because I got this in the log:

2018-06-23 09:15:45.299 [ome.event.ItemUpdatedEvent] - Item 'mqttJuanPresence' has been updated.
2018-06-23 09:15:46.088 [vent.ItemStateChangedEvent] - mqttJuanPresence changed from NULL to OFF

but I do not understand way I have “AWAY” instead of “HOME” if the device is within the fence. I should have this switch ON.

In the transform I have:

ON=HOME
OFF=AWAY
-=-
NULL=-

From wontrack website:

“The app will publish the location additionally everytime the device leaves or enters one of the regions, and the published data contains an indication of whether the device is entering or leaving the region.”

So, I only get info everytime I leave or enter the fence. ok. So, I should move to test properly.