Things files with MQTT 2.4

The following is a small snippet from my demo setup, showing how you can split the broker definition from the generic thing:

first, the bridge.things file:

Bridge mqtt:broker:hotti "MQTT Broker: Hottis Mosquitto"
[
    host="my-mqtt-host",
    port=1883,
    secure="AUTO",
    username="my-username",
    password="my-password"
]

next, the clock.things file

Thing mqtt:topic:hotti:hotticlock_one  "MQTT Thing: HottiClock One"
     (mqtt:broker:hotti) @ "Living Room"
{
    Channels:
        Type string : raw "Raw"
            [
                stateTopic = "fablab02/CLOCK",
                commandTopic = "fablab02/CLOCK"
            ]
}

and lastly my items file:

String HottiClock_One_RAW "Hotticlock One RAW Data [%s]"
(gMQTT, gHottiClock)
{
    channel = "mqtt:topic:hotti:hotticlock_one:raw"
}

Hope this helps a little bit.

7 Likes