Skip to content

Home Assistant MQTT Broker

digiblur edited this page Dec 28, 2018 · 1 revision

Home Assistant is an open-source home automation platform running on Python 3. It is also referred to as Hass.io or HassOS depending on who you talk to and how they installed, but its all one in the same, Home Assistant. I will refer to the software as HA in the rest of this document.

Home Assistant MQTT Configuration (as of 0.83)

Hass.io/HassOS users can easily install and configure the MQTT broker utilizing the add-on store. Other installation methods will need to install their own MQTT broker, through a separate MQTT docker container or installing MQTT on the system itself.

Configure an external broker

In the following configuration example for the HA configuration.yaml an external MQTT server is used with the hostname domus1:

mqtt:
  broker: <localhost, IP address or hostname of the external broker>
  port: 1883
  client_id: home-assistant-1 
  keepalive: 60
  username: HAUSERNAME1
  password: HAPASSWORD1
  protocol: 3.1
  birth_message:
    topic: "tele/hass1/LWT"
    payload: "Online"
    qos: 2
    retain: true
  will_message:
    topic: "tele/hass1/LWT"
    payload: "Offline"
    qos: 2
    retain: true

Note: A retain message is used here as another automation system outside of HA will need to know if HA is online or offline no matter when it is connected to the broker.

Configure HA by editing the file configuration.yaml to be found in configuration folder, some users utilize the Configurator add-on to modify this file. After every change to the config file, HA will need to be restarted.

In the examples shown the default Sonoff-Tasmota parameters and MQTT prefixes are used with MQTT connected. The only option I recommend turning on is "powerretain 1" (typed at the console) to keep the power states sync'd during a reboot of HA. There is also in the TIP section of this document a recommened automation that will cause all the Tasmota devices to post their power states during a reboot.