South MQTT

The foglamp-south-mqtt-readings plugin allows to create an MQTT subscriber service. MQTT Subscriber reads messages from topics on the MQTT broker.

To create a south service you, as with any other south plugin

  • Select South from the left hand menu bar

  • Click on the + icon in the top right

  • Choose mqtt-readings from the plugin selection list

  • Name your service

  • Click on Next

  • Configure the plugin

    mqtt-sub

    • MQTT Broker host: Hostname or IP address of the broker to connect to.

    • MQTT Broker Port: The network port of the broker.

    • Username: Username for broker authentication.

    • Password: Password for broker authentication.

    • Keep Alive Interval: Maximum period in seconds allowed between communications with the broker. If no other messages are being exchanged, this controls the rate at which the client will send ping messages to the broker.

    • Topic To Subscribe: The subscription topic to subscribe to receive messages.

    • QoS Level: The desired quality of service level for the subscription.

    • Asset Name: Name of Asset.

    • Datapoint Name: Datapoint name to be used in the reading object only for a primitive value, published to the topic

  • Click Next

  • Enable your service and click Done

Message Payload

The content of the message payload published to the topic, to which the service is configured to subscribe, should be parsable to a JSON object, Integer, Float or String.

e.g. ‘{“humidity”: 93.29, “temp”: 16.82}’, ‘100’, ‘90.9’, ‘STRING’

$ mosquitto_pub -h localhost -t "Room1/conditions" -m '{"humidity": 93.29, "temp": 16.82}'
$ mosquitto_pub -h localhost -t "Room1/conditions" -m '100'
$ mosquitto_pub -h localhost -t "Room1/conditions" -m '90.9'
$ mosquitto_pub -h localhost -t "Room1/conditions" -m 'STRING'

The mosquitto_pub client utility comes with the mosquitto package, and a great tool for conducting quick tests and troubleshooting. https://mosquitto.org/man/mosquitto_pub-1.html

See Also

foglamp-south-mqtt_sparkplug - A FogLAMP south plugin that implements the Sparkplug API over MQTT