Mqttitude on OH3, Will it be ported?

Will Mqttitude be ported over to OH3? I used to used it for OwnTracks, and it worked a lot better (and more reliably) than GPSTracker. I’d do it but I am just not that knowledgeable on how to do it.

I tried GPSTracker and I get erroneous postings or double checkins which really messes with my “switches”…

I also like being able to pull up my owntracks page (outside of OH3) and seeing the travel history for up to the last 30 days, which I don’t get with GPS Tracker.

So PLEASE port Mqttitude :smiley:

No, the Mqttitude project has ended support. it makes no sense for OH to include stuff that isn’t supported. Mqttitude support never really worked well anyway and Mosquito use but hard to set up. If you are using openHABian, it’s just a menu option.

For the GPS tracker add-on, which supported supports OwbTracks, the preferred interface is to use HTTP now anyway so perhaps you don’t even need MQTT at all any more.

I use mosquitto on my server to collect owntracks positions. In openhab I use the the mqtt binding to connect to mosquito and get the location informations to my openhab installation. I wrote a small rule, to convert the mqtt messages to a location object, every time a new mqtt message is received.

1 Like

@kuczerek Could you share your rule(s) and config(s), please redact as necessary?

I’m not satisfied with GPS Tracker and I also want to keep the OwnTracks Server component up and running and receiving data (GPS Tracker disables this functionality, by rerouting the messages from OwnTracks directly to OpenHAB). From my perspective, GPS Tracker is a workaround, not a solution.

Yes, of course. The documentation at owntracks concerning the installation of mosquitto is a little bit outdated, so I combined my installation out of this three websites:

https://owntracks.org/booklet/guide/broker/
Finally I got owntracks up and running with mosquitto on my linux box, client connections secured by TLS.

Now comes the openHAB part: Install the mqtt binding, create a bridge thing:

UID: mqtt:broker:MQTTBroker
label: MQTT Broker
thingTypeUID: mqtt:broker
configuration:
  lwtQos: 0
  publickeypin: true
  clientID: openhab
  keepAlive: 60
  secure: false
  certificatepin: true
  password: ThisIsASecret
  qos: 0
  reconnectTime: 60000
  port: 1883
  host: localhost
  lwtRetain: true
  username: openhab
  enableDiscovery: true

and a generic MQTT thing. In my case I configured four channels, each for every person which is using owntracks

UID: mqtt:topic:MQTTBroker:owntracks
label: Owntracks Channel
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:MQTTBroker
channels:
  - id: person1String
    channelTypeUID: mqtt:string
    label: person1 String
    description: ""
    configuration:
      stateTopic: owntracks/person1/handy
  - id: person2String
    channelTypeUID: mqtt:string
    label: person2 String
    description: null
    configuration:
      stateTopic: owntracks/person2/handy
  - id: person3String
    channelTypeUID: mqtt:string
    label: person3 String
    description: null
    configuration:
      stateTopic: owntracks/person3/handy
  - id: person4String
    channelTypeUID: mqtt:string
    label: person4 String
    description: null
    configuration:
      stateTopic: owntracks/person4/handy

Create string items and connect them to the channels. I created four of them with the names “OwntracksChannel_person1String” to “OwntracksChannel_person4String”. They will receive a JSON string from owntracks via mosquitto, each time an onwtracks client posts an update.

Create four location items for each person (maybe name them hperson1Position to hperson4Position) and leave them unconnected to any channel. They will be updated by the following rule. The rule should be triggered each time a OwntracksChannel_personXString item is updated.

'use strict';

//var log = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);
//log.info("Script is starting");

var owntrack = JSON.parse(event.itemState);

if (owntrack._type == "location") {

  switch (event.itemName) {

    case "OwntracksChannel_person1String":
      events.postUpdate("hperson1Position", owntrack.lat + ", " + owntrack.lon + ", " + owntrack.alt);
      break;
    case "OwntracksChannel_person2String":
      events.postUpdate("hperson2Position", owntrack.lat + ", " + owntrack.lon + ", " + owntrack.alt);
      break;
    case "OwntracksChannel_person3String":
      events.postUpdate("hperson3Position", owntrack.lat + ", " + owntrack.lon + ", " + owntrack.alt);
      break;
    case "OwntracksChannel_person4String":
      events.postUpdate("hperson4Position", owntrack.lat + ", " + owntrack.lon + ", " + owntrack.alt);
      break;
    default:
      //nothing
  }
}

Hope this helps. In this case owntracks is totally separated to openHAB. OpenHAB is only a client to mosquitto and collecting the location information as mqtt strings.

I apologize for the delay. I finally got time to put this is. I got the first two thing files, (actually combined to one actual file) implemented. The GUI shows everything as it should from that point. I tried getting the rules example you gave, but I can’t seem to get it in typical rule format. Any assistance would be appreciated.

HI @aarondvail ,

Hm, ok - what is your problem? The rule is a typicial Java Script rule used in OH3. What kind of rules are you using?

Cheers,
Boris.

What I’m doing wrong??

rule "own location"
when
Item iPhone_Kamil_own_string received update or Item iPhone_Andzia_own_string received update
then

var owntrack = JSON.parse(event.itemState);

if (owntrack._type == "location") {

  switch (event.itemName) {

    case "iPhone_Kamil_own_string":
      events.postUpdate("iPhone_Kamil_Location_own", owntrack.lat + ", " + owntrack.lon + ", " + owntrack.alt);
      events.postUpdate("iPhone_Kamil_BatteryLevel", owntrack.bat);
      events.postUpdate("iPhone_Kamil_LocationLastUpdate", owntrack.tst);
      events.postUpdate("iPhone_Kamil_LocationAccuracy", owntrack.acc);
      break;
    case "iPhone_Andzia_own_string":
      events.postUpdate("iPhone_Andzia_Location_own", owntrack.lat + ", " + owntrack.lon + ", " + owntrack.alt);
      events.postUpdate("iPhone_Andzia_BatteryLevel", owntrack.bat);
      events.postUpdate("iPhone_Andzia_LocationLastUpdate", owntrack.tst);
      events.postUpdate("iPhone_Andzia_LocationAccuracy", owntrack.acc);
      break;
    default:
      //nothing
  }
}

end

2022-10-24 13:04:38.807 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘own.rules’ has errors, therefore ignoring it: [13,111]: missing ‘}’ at ‘;’

[18,5]: mismatched input ‘case’ expecting ‘}’

[18,36]: mismatched input ‘:’ expecting ‘end’

You appear to be trying to use copied javascript rule code in a new DSL rule that you created. Stick with one rule language of your choice.

1 Like