Using MQTT for both internal devices and Owntracks

I have been struggling now for over a week to set up my Raspberry Pi3 installation of home-assistant to work with both local mqtt devices and password protected external Owntracks mqtt input. I have totally failed and am just on my 4th completely new installation from scratch as I seem to be able to break things faster than I can reprogram them! Can anyone offer any advice please, or point me in the direction of instructions I can understand with my ancient newbie mind? I tried doing the Docker install as suggested on the examples page of the website but couldn’t get the part where it should set up a password to work as it kept telling me that the mosquito-ext container wasn’t running. All I succeeded in doing was breaking the local mqtt switches I have connected. I have trawled web pages, videos and forums till my eyes bled but I haven’t found anything which gives a complete workable solution - some get close but then dissolve into geek-speak which I can’t understand and refer to things which I can’t find (‘bus’ for example…). Please help before the men in white coats come to take me away…

You haven’t really provided enough detail to explain why it’s not working, but what you want to do is very possible.

Configure and install mqtt and test it outside of hass (I use mqttlens - a chrome app). Ensure it requires a password.

Then configure HASS to use it. again use mqttlens to ensure you can see the messages hitting the queue.

Finally expose mqtt to the internet and configure owntracks. I highly recommend using lets encrypt (best) or encrypt the payload for owntracks.

If you list some errors, or the bits that cause you issues it would help a lot!

Thank you Rossdargan, If it makes things clearer, here are my configuration, sensors and customization files…
Configure.yaml…
‘’’
homeassistant:

Name of the location where Home Assistant is running

name: Home

Location required to calculate the time the sun rises and sets

latitude: ***********
longitude: **********

Impacts weather/sunrise data (altitude above sea level in meters)

elevation: 243

metric for Metric, imperial for Imperial

unit_system: metric

Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones

time_zone: Europe/London

customize: !include customize.yaml

Show links to resources in log and frontend

introduction:

Enables the frontend

frontend:

Enables configuration UI

config:

http:

Uncomment this to add a password (recommended!)

api_password: ******

Uncomment this if you are using SSL or running in Docker etc

base_url: *****.duckdns.org:8123

Checks for available updates

updater:

Discover some devices automatically

discovery:
ignore:
- media_player.unnamed_device

Allows you to issue voice commands from the frontend in enabled browsers

conversation:

Enables support for tracking state changes over time.

history:

Phone Tracking

device_tracker:

  • platform: owntracks
    max_gps_accuracy: 200

mqtt:
broker: 192.168.0.25
port: 1883
client_id: home-assistant-1
username: home
password: ********

light:

  • platform: hue
    host: 192.168.0.3

  • platform: mqtt_json
    name: “Strip”
    state_topic: “ian/strip”
    command_topic: “ian/strip/set”
    effect: true
    effect_list:

    • bpm
    • candy cane
    • confetti
    • cyclon rainbow
    • dots
    • fire
    • glitter
    • juggle
    • lightning
    • noise
    • police all
    • police one
    • rainbow
    • rainbow with glitter
    • ripple
    • sinelon
    • solid
    • twinkle
      brightness: true
      flash: true
      rgb: true
      optimistic: false
      qos: 0

input_slider:
strip_animation_speed:
name: Strip Animation Speed
initial: 150
min: 1
max: 150
step: 10

automation:

  • alias: “Strip Animation Speed”
    initial_state: True
    hide_entity: False
    trigger:
    • platform: state
      entity_id: input_slider.strip_animation_speed
      action:
    • service: mqtt.publish
      data_template:
      topic: “ian/strip/set”
      payload: ‘{“transition”:{{ trigger.to_state.state | int }}}’

media_player:

  • platform: panasonic_viera
    host: 192.168.0.6

View all events in a logbook

logbook:

Track the sun

sun:

Sensors and weather

sensor: !include sensors.yaml

wemo:

mysensors:
gateways:
- device: mqtt
persistence_file: ‘/home/homeassistant/.homeassistant/sonoff_1.json’
topic_in_prefix: ‘sonoff_1-out’
topic_out_prefix: ‘sonoff_1-in’
optimistic: false
persistence: true
retain: true
version: 2.0

switch:

  • platform: mqtt
    name: “Wemos D1_1 MQTT”
    command_topic: “home/D1_1/gpio/5/set”
    state_topic: “home/D1_1/D1_1_relay/state”
    payload_on: “1”
    payload_off: “0”
    qos: 0
    retain: true
    optimistic: false

panel_iframe:
router:
title: ‘Router’
url: ‘http://192.168.0.1

Text to speech

tts:
platform: google

group: !include groups.yaml
‘’’
Sensors.yaml…
‘’’

SENSORS

  • platform: systemmonitor
    resources:

    • type: disk_use_percent
      arg: /
    • type: memory_free
    • type: processor_use
    • type: last_boot
  • platform: yr
    monitored_conditions:

    • temperature
    • symbol
    • precipitation
    • windSpeed
    • pressure
    • windDirection
    • humidity
    • fog
    • cloudiness
    • lowClouds
    • dewpointTemperature
  • platform: darksky
    api_key: 4f221d6e6105370f68e4187d5d5e606d
    monitored_conditions:

    • summary
    • icon
    • temperature
    • apparent_temperature
    • humidity
    • precip_probability
    • wind_speed
    • wind_bearing
    • dew_point
    • nearest_storm_distance
  • platform: moon

  • platform: mqtt
    name: “Lounge Uplighter”
    state_topic: “home/sonoff_1/lounge_uplighter/1/power”
    ‘’’
    and customize.yaml…
    ‘’’

Weather

Sensors

sensor.dark_sky_summary:
friendly_name: Conditions
sensor.dark_sky_temperature:
friendly_name: Temperature
sensor.dark_sky_apparent_temperature:
friendly_name: Feels Like
sensor.dark_sky_humidity:
friendly_name: Humidity
sensor.dark_sky_precip:
friendly_name: Rainfall
sensor.dark_sky_precip_probability:
friendly_name: Percent Chance of Rain
sensor.dark_sky_wind_speed:
friendly_name: Wind Speed
sensor.dark_sky_wind_bearing:
friendly_name: Wind bearing
sensor.dark_sky_dewpoint:
friendly_name: Dewpoint
sensor.dark_sky_nearest_storm_distance:
friendly_name: Distance to nearest storm

Hide Duplicate Hue Lights

light.back_bedroom_2:
hidden: true
light.declans_bedroom_2:
hidden: true
light.front_bedroom_2:
hidden: true
light.hall_2:
hidden: true
light.t_v_light_2:
hidden: true
‘’’

In trying to set up Owntracks, I followed the instructions for installing Docker in the examples page on Home-assistant.io and succeeded in setting up the ‘mosquitto-int’ and ‘mosquitto-ext’ containers as it says, however, when I came to the next part which should open me a command prompt to set a password for ‘mosquitto-ext’ I kept getting error messages that the container was not running and the command exited. ‘Docker ps -a’ showed both containers but said they had stopped running and ‘docker ps’ didn’t show them at all. I could not find a way to get past this despite trying every possible looking permutation of commands from the docker help… What it did do though, was to stop communicating with the ‘light:’ in configure.yaml which was set up using Bruh’s instructions and was previously working. I wasn’t able to get communication with the ‘switch:’ item as it also said that it was unable to reach the address and, when I tried to turn these items on from the front panel both of the switch icons turned on and then off 1 second later.
The configure file gives a minor error because I put an entry under ‘discover:’ to hide an ‘unnamed_device’ which was actually my TV that it automatically discovered - the script complains that the device name isn’t on its approved list but it nevertheless does hide it… Sorry this is so long.

Sorry, the formatting didn’t work right but I hope you can make sense of it…

Yeah that formatting doesn’t help -it might be worth just cutting it down to the owntracks and mqtt bit anyway.

Try typing “docker logs mosquitto-ext”