Not connected to MQTT server - help please

Hi everyone,

I’m very new to Zigbee2mqtt and Hass.io; so I apologise in advance if this question is stupid, but after a week of having this error I am unsure where I am going wrong. There’s some flaws in my knowledge which I am hoping someone can plug.

I am using a Raspberry Pi 2 Model B running Raspbian Lite. I have installed Hass.io using the guide: https://github.com/home-assistant/hassio-build/tree/master/install#install-hassio
I have installed Zigbee2mqtt using the following guide: https://github.com/Koenkk/zigbee2mqtt/wiki/Running-the-bridge

When I log into Hassio and go to Hass.io -> Add-ons -> zigbee2mqtt

The following error message is constantly on repeat.

"zigbee2mqtt:error 2018-10-3 16:25:02 Not connected to MQTT server!"

So my first question is, what is the correct configuration to stop this error from occurring? I don’t quite understand what my MQTT server is.

I have already managed to pair my first device, so when I start Hass.io I receive:

  zigbee2mqtt:info 2018-10-3 17:18:56 Coordinator firmware version: '20180815'
  zigbee2mqtt:info 2018-10-3 17:18:56 Currently 1 devices are joined:
  zigbee2mqtt:info 2018-10-3 17:18:56 0x00158d0001e7932d (0x00158d0001e7932d): WXKG11LM - Xiaomi Aqara wireless switch (EndDevice)

However, when I press the button on the switch, it returns the error:

  zigbee2mqtt:error 2018-10-3 16:27:23 Cannot send message: topic: 'homeassistant/sensor/0x00158d0001e7932d/click/config', payload: '{"icon":"mdi:toggle-switch","value_template":"{{ value_json.click }}","json_attributes":["battery","voltage","action","duration"],"force_update":true,"state_topic":"zigbee2mqtt/0x00158d0001e7932d","availability_topic":"zigbee2mqtt/bridge/state","name":"0x00158d0001e7932d","unique_id":"0x00158d0001e7932d_click_zigbee2mqtt"}
  zigbee2mqtt:error 2018-10-3 16:27:23 Cannot send message: topic: 'zigbee2mqtt/0x00158d0001e7932d', payload: '{"battery":"100.00","voltage":3055,"linkquality":92,"click":"single"}

I can only assume I am getting this error because of the first MQTT error? Below are my configuration files for Zigbee2Mqtt and Hass.io.

Any help or guidance will be appreciated.

The configuration file for Zigbee2mqtt is in the folder: /opt/zigbee2mqtt/data, contents are below

# Home Assistant integration (MQTT discovery)
homeassistant: true

# allow new devices to join
permit_join: true

# MQTT settings
mqtt:
  # MQTT base topic for zigbee2mqtt MQTT messages
  base_topic: zigbee2mqtt
  # MQTT server URL
  server: 'mqtt://homeassistant'
  # MQTT server authentication, uncomment if required:
  # user: my_user
  # password: my_password

# Serial settings
serial:
  # Location of CC2531 USB sniffer
  port: /dev/ttyACM0

There is another Config in Hass.io -> Add-ons -> zigbee2mqtt


{
  "data_path": "/share/zigbee2mqtt",
  "homeassistant": true,
  "permit_join": true,
  "mqtt_base_topic": "zigbee2mqtt",
  "mqtt_server": "mqtt://homeassistant",
  "serial_port": "/dev/ttyACM0"
}

The configuration file for Hass.io which is found in: /usr/share/hassio/homeassistant, contents are below:


homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # Location required to calculate the time the sun rises and sets
  latitude: 0
  longitude: 0
  # Impacts weather/sunrise data (altitude above sea level in meters)
  elevation: 0
  # 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: UTC
  # Customization file
  customize: !include customize.yaml

# Show links to resources in log and frontend
introduction:

# Enables the frontend
frontend:

# Enables configuration UI
config:

# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   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

I am also a newbie (of 6-months), but I’ll try to help.

Here is a good description of MQTT

Basically, you need the IP address of an MQTT broker. You have options but most run their own. Me, I have the Mosquitto Broker running on a separate Raspberry Pi. I suspect that most Home Assistant users just install it from Hass.io, Add-On Store, Mosquitto Broker. Some use a public MQTT broker, but I prefer to not use any cloud services.

Here is my configuration.yaml lines:

mqtt:
broker: 192.168.1.123
port: 1883
client_id: home-assistant-1

Hope this helps…

Also, don’t ask me about ZigBee- I have zero experience with ZigBee.

Thank you very much, let me have a look at Mosquitto from the add in store now. :slight_smile:

Thanks, that’s solved my issue. For anyone else who has this issue, I have installed the Mosquitto Broker from the Hass.io Addons.

The config page on Hass.io Add-on details to:


{
“data_path”: “/share/zigbee2mqtt”,
“homeassistant”: true,
“permit_join”: true,
“mqtt_base_topic”: “zigbee2mqtt”,
“mqtt_server”: “mqtt://172.30.32.1:1883”,
“serial_port”: “/dev/ttyACM0”
}


My configuration.yalm for Zigbee2mqtt looks like this:

Home Assistant integration (MQTT discovery)

homeassistant: true

allow new devices to join

permit_join: true

MQTT settings

mqtt:

MQTT base topic for zigbee2mqtt MQTT messages

base_topic: zigbee2mqtt

MQTT server URL

server: ‘mqtt://192.168.1.123:1883’

MQTT server authentication, uncomment if required:

user: my_user

password: my_password

Serial settings

serial:

Location of CC2531 USB sniffer

port: /dev/ttyACM0

broker: core-mosquitto