From 3e84f46a85748da40584d19be45a98dd21bdf3fd Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 27 Aug 2016 13:33:43 +0200 Subject: [PATCH] Add content from #820 --- .../owntracks_two_mqtt_broker.markdown | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 source/_cookbook/owntracks_two_mqtt_broker.markdown diff --git a/source/_cookbook/owntracks_two_mqtt_broker.markdown b/source/_cookbook/owntracks_two_mqtt_broker.markdown new file mode 100644 index 00000000000..c4be879045f --- /dev/null +++ b/source/_cookbook/owntracks_two_mqtt_broker.markdown @@ -0,0 +1,106 @@ +--- +layout: page +title: "OwnTracks with two MQTT brokers" +description: "Setting up OwnTracks with 2 MQTT brokers bridged for use with the MQTT bridge for SmartThings." +date: 2016-08-27 10:05 +sidebar: true +comments: false +sharing: true +footer: true +ha_category: Infrastructure +--- + +I ([surge919](https://github.com/surge919)) successfully tied in [OwnTracks](http://owntracks.org/) to Home Assistant and [SmartThings](https://www.smartthings.com/) while using authentication for external access. The MQTT bridge doesn't support authentication so I set up 2 MQTT instances. + +Here are the steps I performed. Hopefully it saves someone else some time. + +It seems to be working pretty well but if anyone sees something incorrect in my configuration, please let me know. This is my first real interaction with MQTT. + +Here's a summary of my setup: + +Two Docker instances for MQTT + +- 1 for internal use (the MQTT bridge for SmartThings - no authentication) +- 1 for external use (for OwnTracks - with authentication) + +All Docker configuration files are on my NAS so the Docker containers can be destroyed without affecting my actual configuration files. + +#### Docker setup for the mosquitto internal instance. No authentication for use with the MQTT bridge. + +```bash +$ docker run -ti -p 1883:1883 \ + -v /volume1/data/mosquitto-int/config:/mqtt/config:ro \ + -v /volume1/data/mosquitto-int/log:/mqtt/log \ + -v /volume1/data/mosquitto-int/data/:/mqtt/data/ \ + --name mosquitto-int -d toke/mosquitto +``` + +#### Docker setup for the mosquitto external instance. With authentication for use with Owntracks. + +```bash +$ docker run -ti -p 1884:1883 \ + -v /volume1/data/mosquitto-ext/config:/mqtt/config:ro \ + -v /volume1/data/mosquitto-ext/log:/mqtt/log \ + -v /volume1/data/mosquitto-ext/data/:/mqtt/data/ \ + -v /volume1/data/mosquitto-ext/etc:/etc/mosquitto \ + --name mosquitto-ext -d toke/mosquitto +``` + +Here are the config files: + +`/volume1/data/mosquitto-int/config/mosquitto.conf` + +```bash +connection mosquitto-ext +persistence_file mosquitto.db +try_private true +address 10.0.0.20:1884 +start_type automatic +sername test +password test +notifications true +topic owntracks/# in +log_type all +log_dest file /mqtt/log/mqtt.log +log_facility 5 +``` + +`/volume1/data/mosquitto-ext/config/mosquitto.conf` + +```bash +connection mosquitto-int +persistence_file mosquitto.db +try_private true +address 10.0.0.20:1883 +start_type automatic +username test +password test +notifications true +topic owntracks/# out +log_type all +log_dest file /mqtt/log/mqtt.log +log_facility 5 +allow_anonymous false +password_file /etc/mosquitto/pwfile +``` + +Create a password for `mosquitto-ext` + +```bash +$ docker exec -it mosquitto-ext /bin/bash +$ cd /etc/mosquitto/ +$ mosquitto_passwd -c /etc/mosquitto/pwfile +``` + +### OwnTracks settings for Android + +```bash +Preferences / Connection / Mode - Private MQTT + +Fill out + Host + Identification + Security: TLS disabled +``` + +