MQTT - JRInge/ha GitHub Wiki

The MQ Telemetry Transport (MQTT) protocol allows sensors to publish data onto the network, and other nodes to subscribe to their messages. Communications go via a central broker, so that individual nodes only need to know the broker's details, not the other nodes.

HiveMQ MQTT Essentials blog, for details on MQTT protocol operation.

Install Mosquitto MQTT broker

Install on Raspberry Pi:

sudo apt install mosquitto

mosquitto should be enabled automatically to run on startup. At Apr 21, the current version on Raspberry Pi OS is v1.5.7. This only supports MQTT v3.1/3.1.1. v1.6 is needed for MQTT 5 support. v2 onwards has better security, but needs more configuration.

Announce MQTT service via Avahi

Announcing MQTT allows mDNS/DNS-SD clients to discover the location of the MQTT broker automatically, without having to have an IP address or hostname configured. On a Linux system, Avahi can be configured to do this by including the following in /etc/avahi/services/mqtt.service:

<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name replace-wildcards="yes">MQTT on %h</name>
  <service>
   <type>_mqtt._tcp</type>
   <port>1883</port>
  </service>
</service-group>
⚠️ **GitHub.com Fallback** ⚠️