MQTT Could not setup Dependencies

Hello.

I have been tearing my hair out about this issue! The issue I am having is MQTT is not working. Specifically I get a warning in the Home Assistant web interface saying.

The following components and platforms could not be set up:
mqtt
light.mqtt
switch.mqtt
Please check your config

I know my config is correct as it was working before. This issue arose when I installed open z wave and a Z- Stick but before that it was working fine. My home assistant log says the following.

2017-06-15 21:21:38 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/setup.py", 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/__init__.py", line 380, in async_setup
    success = yield from hass.data[DATA_MQTT].async_connect()
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/mqtt/__init__.py", line 490, in async_connect
    self._mqttc.connect, self.broker, self.port, self.keepalive)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/homeassistant/.homeassistant/deps/paho/mqtt/client.py", line 700, in connect
    return self.reconnect()
  File "/home/homeassistant/.homeassistant/deps/paho/mqtt/client.py", line 822, in reconnect
    sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0))
  File "/usr/lib/python3.4/socket.py", line 509, in create_connection
    raise err
  File "/usr/lib/python3.4/socket.py", line 500, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of switch.mqtt. Setup failed for dependencies: mqtt
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform switch.mqtt: Could not setup all dependencies.
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of light.mqtt. Setup failed for dependencies: mqtt
2017-06-15 21:21:54 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform light.mqtt: Could not setup all dependencies.

If anyone can help me with this I would greatly appreciate it :slight_smile:

Riley.

Connection issue…wrong broker address, port, etc.

I have on HA system 0.57 that I set up manualy based on Debian Stretch external mqtt running fine, but it wouldn’t update. So I set up a second 0.60 based on HASSBIAN, installed the mqtt broker with the provided script. Check config says ok, but after restarting HA I get the obove error. I am shure Broker address port are corect. the only changes I made to the default script was adding mqtt.

Thanks for any hint

Rainer

Post your config as Please check your config usually indicates there is something wrong with it :wink:

homeassistant:

Name of the location where Home Assistant is running

name: Home

Location required to calculate the time the sun rises and sets

latitude: 49.4798
longitude: 11.0604

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

elevation: 317

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/Berlin

Customization file

customize: !include customize.yaml

Show links to resources in log and frontend

introduction:

Enables the frontend

frontend:

Enables configuration UI

config:

http:

Secrets are defined in the file secrets.yaml

api_password: !secret http_password

Uncomment this if you are using SSL/TLS, running in Docker container, etc.

base_url: example.duckdns.org:8123

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:

https://home-assistant.io/blog/2016/10/25/explaining-the-updater/

updater:

Optional, allows Home Assistant developers to focus on popular components.

include_used_components: true

Discover some devices automatically

discovery:

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

conversation:

Enables support for tracking state changes over time

history:

View all events in a logbook

logbook:

Enables a map showing the location of tracked devices

map:

Track the sun

sun:

Weather prediction

sensor:

  • platform: yr

Text to speech

#tts:

- platform: google

Cloud

#cloud:

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

mqtt:
broker: locahost
port: 1883
protocol: 3.1

username: username

password: password

sensor 1:

  • platform: mqtt
    state_topic: “home/test/sensor1”
    name: “Sensor 1 Temperatur”
    unit_of_measurement: “°C”
    value_template: “{{ value_json.temperature }}”
  • platform: mqtt
    state_topic: “home/test/sensor1”
    name: “Sensor 1 Luftfeuchtigkeit”
    unit_of_measurement: “%”
    value_template: “{{ value_json.humidity }}”

here it is, its just the basic sample,
mosquitto is running fine. I can subscrbe and publish via command line. 2 thing I changed old setup was on pi 2a new on pi 3a, check config green
Error “Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies.”
Thanks for help
Rainer

P.S. perhaps this helps2017-12-26 18:33:51 ERROR (MainThread) [homeassistant.setup] Error during setup of component mqtt Traceback (most recent call last): File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/setup.py", line 190, in _async_setup_component result = yield from component.async_setup(hass, processed_config) File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/__init__.py", line 387, in async_setup success = yield from hass.data[DATA_MQTT].async_connect() File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/mqtt/__init__.py", line 498, in async_connect self._mqttc.connect, self.broker, self.port, self.keepalive) File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__ yield self # This tells Task to wait for completion. File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup future.result() File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result raise self._exception File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run result = self.fn(*self.args, **self.kwargs) File "/srv/homeassistant/lib/python3.5/site-packages/paho/mqtt/client.py", line 768, in connect return self.reconnect() File "/srv/homeassistant/lib/python3.5/site-packages/paho/mqtt/client.py", line 895, in reconnect sock = socket.create_connection((self._host, self._port), source_address=(self._bind_address, 0)) File "/usr/lib/python3.5/socket.py", line 694, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/usr/lib/python3.5/socket.py", line 733, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known 2017-12-26 18:33:53 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt 2017-12-26 18:33:53 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies. 2017-12-26 18:33:53 ERROR (MainThread) [homeassistant.setup] Unable to setup dependencies of sensor.mqtt. Setup failed for dependencies: mqtt 2017-12-26 18:33:53 ERROR (MainThread) [homeassistant.setup] Unable to prepare setup for platform sensor.mqtt: Could not setup all dependencies. 2017-12-26 18:39:43 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

Wow… seriously… Check the blue box on top of this topic and edit your post so we can actually read it.

homeassistant:
name: Home
latitude: 49.4798
longitude: 11.0604
elevation: 317
unit_system: metric
time_zone: Europe/Berlin
customize: !include customize.yaml
introduction:
frontend:
config:
http:
discovery:
conversation:
history:
logbook:
map:
sun:
sensor:

  • platform: yr
    group: !include groups.yaml
    automation: !include automations.yaml
    script: !include scripts.yaml
    mqtt:
    broker: locahost
    port: 1883
    protocol: 3.1
    sensor 1:
  • platform: mqtt
    state_topic: “home/test/sensor1”
    name: “Sensor 1 Temperatur”
    unit_of_measurement: “°C”
    value_template: “{{ value_json.temperature }}”
  • platform: mqtt
    state_topic: “home/test/sensor1”
    name: “Sensor 1 Luftfeuchtigkeit”
    unit_of_measurement: “%”
    value_template: “{{ value_json.humidity }}”

better?
remember check_config returns no errors

Rainer

Slightly better, but you should use codeblock if you post your code. This keeps the formatting which is essential. Use the ` sign 3 times on an empty line before and after the code or use the < / > button.

Is mosquitto starting automatically? There have been some issues installing it but I think it was fixed in the latest hassbian image. Are you 100% sure it’s running properly. Don’t you use a username / password?

I’ quite shure mosquitto runs fine I habe a password file but anonymous_login true i can subscripe and publish from the command line without username and passowrd. in configuration.yam the 2 spaces indent is double checked. did quite a lot with the 0.57 installation, mostly worked, I am a beginner in HA but not a novice. I’am working in IT,PC Microcontrollers RASPI Arduino and programming since many years. That should not mean I am perfect, at least not at HA.

Thanks

Rainer

See if MQTT is running.

The way I do this is by using MQTTBox (https://chrome.google.com/webstore/detail/mqttbox/kaajoficamnjijhkeomgfljpicifbkaf?utm_source=chrome-app-launcher-info-dialog)

I connect to my Pi’s IP at port 1883 and see if it connects. If it does MQTT is working then try subscribing to one of your sensors listed above to see if you can read the data. If MQTTBox cant connect to your MQTT server then it is not running.

If it wont connect SSH into your Pi and run this command. Then try to reconnect using MQTTBox.

sudo systemctl start mosquitto.service 

Hope this helps.

Change:
broker: locahost

into
broker: localhost

1 Like

Sorry but it was not the typo, tried with 127.0.0.1 and correct writing too. Thanks for the help.
In the meantime I did a complete new manual setup (latest Rasbian and following https://home-assistant.io/docs/installation/raspberry-pi/ )on my R2 everything works fine as it should. Hope update will work too

Happy new Year
Rainer