Open ben8622 opened 2 months ago
Conclusion: MQTT is a lightweight messaging protocol designed for IoT devices. It works in a publisher subscriber architecture and has many useful additions out of the box like scalability and security. After some digging though, it looks like most devices that connect on home assistant are not using MQTT. There's, more likely, some combination of mDNS and pre-configured integrations. MQTT does support auto discovery though through MQTT and it looks like it can tell home-assistant what it outputs/offers so it may be worth looking into. Definitely won't be apart of the MVP, but may be worth it later. Reddit post asking for this info.
Helpful Links:
MQTT stands for MQ (Message Queue) Telemetry Transport. It is the standard messaging protocol for IoT since it is an extremely lightweight way to send data from devices with relatively small footprints. Think of temperature sensors just reporting a single integer every 5 minutes. That's not even a megabyte of data a day.
MQTT is standardized by OASIS and ISO.
MQTT follows a publisher/subscriber architecture. The three main pieces being a MQTT Publisher, a MQTT Broker, and a MQTT Subscriber.
Features of MQTT:
Link to a python MQTT client library called paho-mqtt. Think the same client is created in C++ as well.
What is MQTT?
Answered in above comment
How does MQTT work?
Answered mostly in above comment
Does MQTT work better for metrics collection than setting up devices to hit a REST API I also have to create and manage?
If I spun up my own detailed architecture it could, however I don't plan on doing that any time soon so a REST API is probably much simpler. May be worth it just for the experience, but also depends how / if I want to integrate it into Home Assistant.
Does MQTT fit into home assistant better?
Not really better but it does look like MQTT will provide a way for HomeAssistant to auto discover devices and what the device puts out (metrics and actions). I think it'd be better for a large 10+ devices setup gathering metrics.
Is MQTT more reusable compared to hitting an API endpoint?
Research and figure out the following: