OpenHabian owntracks and mosquitto

Personally, I don’t use the owntracks binding (I have another presence detection solution in OH2 with Unifi) but i think that you should install it and define a geofence for it (independent of your region settings in the OT mobile app)
Then, you can use the home:event thingy

1 Like

Thanks for the advice Dim I’ve seen a few posts from a topic similar to this and it seems that other people have had success with installing the owntracks Binding but leaving it blank and only setting regions in the owntracks app itself.
I shall give this a try and hopefully it works. The main thing was that openhab wouldn’t connect as a client but uninstalling, erasing tmp files and reinstalling Binding seemed to fix the problem.

I’m intrigued by your mention of unifi but thats a different topic I suppose.

Thanks again for your help

1 Like

Ok so for anyone who has been struggling like i have to set up Owntracks, mosquitto and openhab on a raspberry pi this is what I did.
Follow this guide from the Owntrack booklet to set up the broker
http://owntracks.org/booklet/guide/broker/

Install the Mqtt and Mqttitude binding and configure the Mqtt binding as such

# Define your MQTT broker connections here for use in the MQTT Binding or MQTT
# Persistence bundles. Replace <broker> with an ID you choose.
#

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
mosquitto.url=tcp://localhost:1883

# Optional. Client id (max 23 chars) to use when connecting to the broker.
# If not provided a default one is generated.
#mosquitto.clientId=

# Optional. User id to authenticate with the broker.
mosquitto.user=openhab

# Optional. Password to authenticate with the broker.
mosquitto.pwd=*********

# Optional. Set the quality of service level for sending messages to this broker.
# Possible values are 0 (Deliver at most once),1 (Deliver at least once) or 2
# (Deliver exactly once). Defaults to 0.
mosquitto.qos=1

# Optional. True or false. Defines if the broker should retain the messages sent to
# it. Defaults to false.
mosquitto.retain=true

# Optional. True or false. Defines if messages are published asynchronously or
# synchronously. Defaults to true.
mosquitto.async=false

# Optional. Defines the last will and testament that is sent when this client goes offline
# Format: topic:message:qos:retained <br/>
mosquitto.lwt=<last will definition>

leave the mqttitude binding config empty is your using region mode and setting your regions in the owntracks app .

create an item in openhab with the syntax

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

create a sitemap for you item and voila!
this should get you started

openhab wasnt connecting as a client to mosquitto at first but unistalling the mqtt binding and deleting tmp files related to the mqtt binding , before reinstalling the binding worked for me.

2 Likes