I don’t know much about the new OH2 world, but based on what Kai has said, and what I know about Owntracks/MQTT it sounds like you would define a broker thing which would include the hostname, username, password etc, and one extra property, the base topic. Once you have the base topic you can then do a simple wildcard subscription (e.g. /basetopic/+/+) to get a dynamic list of device things. And from there create your static channels per device.
So in theory to setup the Owntracks binding all you would have to do is define the broker thing and everything else would be auto-created.
NOTE: the binding would only be able to auto-detect the devices if they are publishing retained messages, otherwise it would have to wait until a device publishes a location AFTER the binding is subscribed to the base topic.
I am still trying to understand OSGI, so please allow me a few stupid questions
I believe that I should use the MqttService from that bundle. How do I obtain a reference to a service from another bundle? In spring based containers, I would use some kind of wiring (annotation or XML based), but with OSGI, I have no idea even where to start reading.
I tried “References → Workspace” in Eclipse, but that did not find any references except the logger object inside the class itself
Hi Hakan,
When I started th WeMo binding, a good starting point fo me was to have a look into the hue binding.
You could also have a look into the OH2 Sonos Binding where you can find references to the io.transport.upnp bundle.
I don’t suppose this has had any more action on it? I’m not capable of picking up the reigns and doing it myself i’m afraid, but will put my hand up to say that it would be appreciated.
If you’re not worried about the native OH2 build with auto discovery etc, you can use the 1.9 build in OH2 in the same way as we did for openHAB 1.8. I have been using it for some time without any issues.
You don’t need anything in the openhab.cfg file unless you want to identify home/set up geofences etc - I don’t do these in Owntracks and do my processing within openHAB and so haven’t tried any of the config file entries. For simple receiving of location messages, it should work out of the box assuming your mqtt binding is working correctly.
Hi folks,
Anyone had luck with using 1.9 binding in OH2? Also, why 1.x version is not included in OH2 as legacy binding, are there any reasons for that?
I have problems gettting my owntracks again (it used to run one week ago).
I just upgraded to the latest snapshot and obviously there is no connection from my mosquitto to OH2 any more.
Please see also:
I have installed:
binding-mqttitude1
binding-mqtt
action.mqtt
Mosquitto is running fine and my smartphone is connected to it
You will need to go through a process of elimination to find out what the issue is. Certainly the binding seems to work for myself and others I know using the latest snapshot.
Some things to look at:
Subscribe to the owntracks/# (remember to use the -v argument as well to see a more verbose response) the topic on your mqtt broker and make sure that you are seeing actual messages
If all is coming through as expected, check your bindings on openHAB using the Karaf console. Use list | grep -i mqtt and make sure that you are seeing only the bindings you expect (i.e. openHAB has not loaded multiple versions of a binding). On my system, it is showing:
openhab> list | grep -i mqtt
201 | Active | 80 | 1.9.0.201612240210 | openHAB MQTT Binding
202 | Active | 80 | 1.9.0.201612240210 | openHAB Mqttitude Binding
209 | Active | 80 | 1.9.0.201612240210 | openHAB MQTT Transport Bundle
If the bindings are ok, then use an item that receives ALL the owntracks related mqtt messages (and not just the ones for your individual phone/entry/exit etc). E.g. your item could be defined as:
String Owntracks_Location_Raw "Owntracks Location raw location" (Owntracks) { mqtt="<[mosquitto:owntracks/#:state:default"}
I have seen similar behaviour, though i didn’t. Find an explicit explanation. I have Solved Those problems by deleting the. Mqtt-eventbus folder in tmp. In OH2. Temperaturen is in the etc. Folder, White in OH1 it is in the /tmp folder from root. Especially after changing mqtt sektens Thisted has helped. Also remedier to restart your oh…
Hope That helps … …
No, I don’t think it is required for owntracks. I have never installed the mqtt Action.
Not sure what else to suggest then, as the latest snapshot is working fine here. Only other thing to try is to remove the bindings and then reinstall them?