Configuration.yaml and MQTT problems

I am trying to get my configuration.yaml file to load properly and have spent most of yesterday editing and all my additions seem to produce errors. I am hoping someone here can point me in the correct direction.

My Home assistant front page produces these errors:

Invalid config
The following components and platforms could not be set up:


Please check your config

My configuration.yaml file contains:

  # Name of the location where Home Assistant is running
  name: HOME
  # Location required to calculate the time the sun rises and sets
  latitude: 51.40
  longitude: -0.34
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 10
  # metric for Metric, imperial for Imperial
  unit_system: metric
  # Pick yours from here:
  time_zone: Europe/London

# Show links to resources in log and frontend

# Enables the frontend

# Enables configuration UI

  # Uncomment this to add a password (recommended!)
  # api_password: PASSWORD
  # Uncomment this if you are using SSL or running in Docker etc
  # base_url:

# Checks for available updates
# Note: This component will send some information about your system to
# the developers to assist with development of Home Assistant.
# For more information, please see:
  # Optional, allows Home Assistant developers to focus on popular components.
  # include_used_components: true

# Discover some devices automatically

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

# Enables support for tracking state changes over time.

# View all events in a logbook

# Track the sun

# Weather Prediction
  platform: yr

# Text to speech
  platform: google

group: !include groups.yaml
automation: !include automations.yaml
    port: 1152
    client_id: home-assistant-1
    keepalive: 60
    username: ****
    password: ***
  - platform: mqtt
    name: "socket"
    command_topic: "cmnd/sonoff/power"
    state_topic: "stat/sonoff/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true 
  - platform: owntracks

And my log shows:

2017-07-23 11:40:01 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/”, line 187, in _async_setup_component
result = yield from component.async_setup(hass, processed_config)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/”, line 380, in async_setup
success = yield from[DATA_MQTT].async_connect()
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/”, line 490, in async_connect
self._mqttc.connect,, self.port, self.keepalive)
File “/usr/lib/python3.4/asyncio/”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/deps/paho/mqtt/”, line 760, in connect
return self.reconnect()
File “/home/homeassistant/.homeassistant/deps/paho/mqtt/”, line 887, in reconnect
sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
File “/usr/lib/python3.4/”, line 509, in create_connection
raise err
File “/usr/lib/python3.4/”, line 500, in create_connection
ConnectionRefusedError: [Errno 111] Connection refused
2017-07-23 11:40:21 WARNING (MainThread) [homeassistant.setup] Setup of sensor is taking over 10 seconds.
2017-07-23 11:40:21 WARNING (MainThread) [homeassistant.setup] Setup of group is taking over 10 seconds.
2017-07-23 11:40:21 ERROR (MainThread) [homeassistant.components.device_tracker] Unable to load /home/homeassistant/.homeassistant/known_devices.yaml: Config file not found: /home/homeassistant/.homeassistant/known_devices.yaml
2017-07-23 11:40:21 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of switch.mqtt. Setup failed for dependencies: mqtt
2017-07-23 11:40:21 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform switch.mqtt: Could not setup all dependencies.
2017-07-23 11:40:21 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of device_tracker.owntracks. Setup failed for dependencies: mqtt
2017-07-23 11:40:21 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform device_tracker.owntracks: Could not setup all dependencies.

I am pretty new to setting up home automation and Yaml files
so any help would be greatly appreciated.

Thanks in anticipation

Try to use 2 spaces in front of mqtt data…

Like this:

instead of -

    port: 1152
    client_id: home-assistant-1
    keepalive: 60
    username: ****
    password: ***

Use -

  port: 1152
  client_id: home-assistant-1
  keepalive: 60
  username: ****
  password: ***

Gil :slight_smile:

1 Like

There seem to be an (intermittent?) problem with the m21 cloudmqtt host on 1152. Here is trying to connect to it compared to another of their hosts.

pi@raspberrypi:~ $ telnet 1152
telnet: Unable to connect to remote host: Connection refused

pi@raspberrypi:~ $ telnet 24938
Connected to
Escape character is '^]'.

The clue was in the log you posted.

Thank you for that, that is very helpful ,not quite sure what I can do about it though

Guess your options are to wait, or ping the cloudmqqt folks. Maybe recreate your account and hope you get another host/port that works assigned - or set up a MQTT broker elsewhere e.g. by following this guide:

That setup will have the upside that you will also – optionally – get remote access to the HA front end and you don’t depend on CloudMQTT.
Downside is you now have a few more services to maintain. To minimize the effort to keep DuckDNS, Let’s Encrypt and Mosquitto up to date I would install them as Add-ons in a deployment.

Thanks again I am following the instruction link you forwarded and we will see how we get on.
You wouldn’t by any chance know how you automatically start cron on reboot, duckdns tells you up until then and then assumes you have a GUI for that bit instead of using Putty,
Thanks again

You’re welcome :slight_smile:

Sorry, the last bit was not clear to me. Are you asking about this section about setup via sudo crontab -e? At that point when I ssh (or “Putty”) into my Raspberry I see this:

pi@raspberrypi:~ $ sudo crontab -e
no crontab for root - using an empty one

Select an editor.  To change later, run 'select-editor'.
  1. /bin/ed
  2. /bin/nano        <---- easiest
  3. /usr/bin/vim.tiny

Choose 1-3 [2]:

If I then choose 2 I see:

  GNU nano 2.2.6                     File: /tmp/crontab.0Q89oZ/crontab                                                  
# Edit this file to introduce tasks to be run by cron.
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
# For more information see the manual pages of crontab(5) and cron(8)
# m h  dom mon dow   command

^G Get Help         ^O WriteOut         ^R Read File        ^Y Prev Page        ^K Cut Text         ^C Cur Pos
^X Exit             ^J Justify          ^W Where Is         ^V Next Page        ^U UnCut Text       ^T To Spell

At that screen simply paste the two lines after all the # commented instruction lines press Ctrl-X and answer Y to save.

*/5 * * * * ~/duckdns/ >/dev/null 2>&1
40 11,23 * * * ~/certbot/certbot-auto renew --quiet --no-self-upgrade >> ~/certbot/certbot_renew.log

Hope that was what you were asking about?

Edit: Oh – and I assuming right that you are on a Raspberry Pi too?

Yes I had basically done that though I hadn’t included the second line which I have now.
I was referring to setting up duckdns where it says to:

The final task for Raspbmc is to make the cron autostart on reboot for Raspbian you don't need to do this
first we simply manualy start the crontab

sudo service cron start

Then to automatically start cron on reboot, in Raspmbc you check the option in the Programs Raspbmc menu in XBMC"

I was wondering if there is anything I needed to set up to automatically run this on startup but I think probably it will run on startup as in Raspbian.
I have managed to get things to boot up cleanly now and without errors by changing to mosquito running locally. so that is good and my switch is now being seen by homeassistant but not yet functioning properly but i will sort that out hopefully.
Thanks again

Ah, now I see buried a few link-clicks away from there at the end of the DuckDNS instructions for a Pi. Must admit I haven’t actually yet followed those instructions myself :blush:

Yeah, I’d think that cron autostart setup only is something you have to do for a Raspbmc distribution with a XBMC user interface. Looks like pi and raspbmc share the same description. Checking it with sudo service cron status on my Rasbian based Pi cron seems to be already running.

Great to hear you’ve gotten thus far & good luck on the final bits!

Thanks again
And now I have a switch functioning so things are definitely looking up.
Thanks again you were a great help.

It should actually be contab -e as the pi user. No sudo. I’ve updated the steps.

1 Like