Homie#

Introduction#

Homie is an MQTT convention for the IoT. homie-esp8266 is the corresponding ESP8266 framework implementation. This section tries to give a short introduction about how to publish telemetry data from a Homie-based firmware in JSON format to the MQTT bus.

Details#

  1. Use a configuration like:

    {
        "name": "slartibartfast",
        "device_id": "node-1",
        "wifi": {
            "ssid": "Network_1",
            "password": "I'm a Wi-Fi password!"
        },
        "mqtt": {
            "host": "kotori.example.org",
            "port": 1883,
            "base_topic": "mqttkit-1/testdrive/area-42/"
        }
    }
    

Note

Especially have a look at the parameters base_topic and device_id: They make up the prefix parts of an appropriate MQTT topic string. See also MQTT for general information about MQTT telemetry data publishing.

  1. Use code like:

    HomieNode jsonNode("data", "__json__");
    jsonNode.setProperty("__json__").setRetained(false).send(payload);
    

Note

This will make up the suffix part data/__json__ of an appropriate recognized MQTT topic string.

Real applications#