Ok so i really cant seem to get owntracks set up as a presence detection to work, i know there are other topics regarding this but ive read them all with no luck.
so my set up so far is openhabian on a RPi3, i have owntracks on my phone with a single region set as home.
I have mosquitto set up on the RPi3 and so far the logs suggest that it connects to owntracks and i can receive publishes from owntracks.
I have the mqtt binding set up for local host
and I have a switch item subscribing to event publishes from mosquitto and a site map showing said item .
I believe that openhab isnt connecting to mosquitto as it doesnt show it connecting in the log and thats why my sitemap switches don’t work.
does anyone have any ideas of what im doing wrong ?
mqtt.cfg
# 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>
1497609544: Config loaded from /etc/mosquitto/mosquitto.conf.
1497609544: Opening ipv4 listen socket on port 1883.
1497609544: Opening ipv4 listen socket on port 8883.
1497609544: Opening ipv6 listen socket on port 8883.
1497609553: New connection from 192.168.1.1 on port 8883.
1497609553: Client tim/android disconnected.
1497609553: New client connected from 192.168.1.1 as tim/android (c0, k3600, u'Tim').
1497609553: Sending CONNACK to tim/android (0, 0)
You have clientID commented out but nothing assigned to it. That means your clientID is empty string or essentially no clientID. I don’t think mosquitto will allow a client to connect with an empty id.
Hi Rich,
I didn’t even notice that I commented it out . I shall give it a try and see if it works.
As far as my item syntax do you think this should work to operate a switch on the sitemap when I enter or leave a home region?
Thanks for the advice
No such luck i commented the client ID and for good measure the last will and testament as well. After restarting it still only shows the owntracks client connecting and not openhab.
Hi Rich, yes in my passwd file, I Created a user openhab and a password to match the Mqtt.cfg. I even deleted it and created it again Just in case it was wrong.
I use the ufw firewall on the raspberry pi but I’ve allowed 1883 and 8883.
I won’t be able to do this for a few days but when I can I’ll try with the firewall.
I do have th Mqtt binding installed but I not sure about the action I’ll have a look and get back to you.
Thanks
ok Rich so i turned off ufw and restarted but this had no effect. I definitley have the Mqtt binding installed and i did have the action binding install but i uninstalled and tried a restart again. No change unfortunately. However in the openhab2 log i did find this:
2017-06-20 12:00:34.176 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2017-06-20 12:00:34.178 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mosquitto'
2017-06-20 12:00:34.377 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type 'mqtt' of item 'Mobile_Tim_mqtt' could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: Configuration 'mosquitto:owntracks/Tim/Android/event:home' is not a valid inbound configuration: Configuration requires 4 or 5 parameters separated by ':'
at org.openhab.core.binding.internal.BindingConfigReaderDelegate.processBindingConfiguration(BindingConfigReaderDelegate.java:50)
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.internalDispatchBindings(GenericItemProvider.java:312)
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.dispatchBindingsPerType(GenericItemProvider.java:268)
at org.eclipse.smarthome.model.item.internal.GenericItemProvider.addBindingConfigReader(GenericItemProvider.java:102)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.8.0_131]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)[:1.8.0_131]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[:1.8.0_131]
at java.lang.reflect.Method.invoke(Method.java:498)[:1.8.0_131]
at org.apache.felix.scr.impl.inject.BaseMethod.invokeMethod(BaseMethod.java:224)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod.access$500(BaseMethod.java:39)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod$Resolved.invoke(BaseMethod.java:617)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BaseMethod.invoke(BaseMethod.java:501)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.inject.BindMethod.invoke(BindMethod.java:655)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1722)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1699)[32:org.apache.felix.scr:2.0.6]
at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeBindMethod(SingleComponentManager.java:371)[32:org.apache.felix.scr:
any ideas why it’s showing my binding as invalid?
I removed this file with no change to the problem although maybe the log i posted to Rich might help.
one thing ive noticed is that mosquitto no longer starts when i boot the raspberry up it tries but then creates an error. I can get it to start manually though with no problems.
The error states that the config on Mobile_Tim_mqtt is invalid. Look at that item and look at the mqtt readme and you should see you are missing some parameters.
this removed the error i was having however this didnt solve openhab not connecting as a client.
I decided to unistall the binding and any tmp files associated with mqtt.cfg
after i reinstalled it and it shows openhab connecting.
mosquitto version 1.4.12 (build date Thu, 25 May 2017 22:38:16 +0100) starting
1497986616: Config loaded from /etc/mosquitto/mosquitto.conf.
1497986616: Opening ipv4 listen socket on port 1883.
1497986616: Opening ipv4 listen socket on port 8883.
1497986616: Opening ipv6 listen socket on port 8883.
1497986836: New connection from 192.168.1.1 on port 8883.
1497986836: Client tim/android disconnected.
1497986836: New client connected from 192.168.1.1 as tim/android (c0, k3600, u'Tim').
1497986836: Sending CONNACK to tim/android (0, 0)
1497986836: Received SUBSCRIBE from tim/android
1497986836: owntracks/+/+ (QoS 2)
1497986836: owntracks/+/+/info (QoS 2)
1497986836: owntracks/Tim/Android/cmd (QoS 2)
1497986836: owntracks/+/+/event (QoS 2)
1497986836: owntracks/+/+/waypoint (QoS 2)
1497986836: Sending SUBACK to tim/android
1497986836: Sending PUBLISH to tim/android (d0, q1, r1, m1634, 'owntracks/Tim/Android', ... (114 bytes))
1497986836: Received PUBACK from tim/android (Mid: 1634)
1497986960: New connection from 127.0.0.1 on port 1883.
1497986960: New client connected from 127.0.0.1 as openhab.1497986960113 (c1, k60, u'openhab').
1497986960: Sending CONNACK to openhab.1497986960113 (0, 0)
1497986990: Received DISCONNECT from openhab.1497986960113
1497986990: Client openhab.1497986960113 disconnected.
1497987018: New connection from 127.0.0.1 on port 1883.
1497987018: New client connected from 127.0.0.1 as openhab.1497987018633 (c1, k60, u'openhab').
1497987018: Sending CONNACK to openhab.1497987018633 (0, 0)
The only issue i have now is that the switch doesnt change to (ON) on the sitemap what am i missing ?
thanks again Rich and Dim for all your help so far.
That’s just a typing error in the message I sent you.
So the owntracks booklet suggests that I subscribe to the topic
Tim/Android/Event and home is the region I have added in the owntracks app
as part of the event when I enter or leave that geo fence.
All I want to do is have the sitemap switch show ON when I enter the home
geofence and OFF when I leave. Is there a better way to do this ?
If I don’t show status and default in the syntax it suggests in the log that I am missing bits.
I think this is where my confusion is coming from. When I downloaded the owntracks binding before it gave me the option to define a location but I unstood this was a manual mode and I was achieving the same thing in the app by defining a location/region and what the owntracks binding docs called region mode.
Does this mean I need the owntracks binding installed and a configured with a geolocation like the region I have on the owntracks app ?
Or just installed and then change the item as you have shown to mqttitude=