In this article i wrote that this substituted a python script with addtional processing tasks. One of the task was the transmission of the data into MQTT to provide other systems with this kind of information (it was a small epaper display used as a remote display in my home, i have now solved this differently).
However it’s quite easy to enable Telegraf to distribute the data via MQTT. You have to put the following statements in a file (for example mqtt_output.conf
in /etc/telegraf/telegraf.d
[[outputs.mqtt]]
servers = ["localhost:1883"]
topic_prefix = "telegraf/cmi"
batch = true
data_format = "json"
[outputs.mqtt.tagpass]
sourcedevice = ["cmi"]
It’s an addtional output like the InfluxDB output i’m using to store the data. However in this case it’s limited to measurements with the tag sourcedevice
equal to cmi
. As you may remember, i configured the input from the CMI in way, that sets sourcedevice=cmi
and so i’m using this tag now to limit the MQTT transmisssion to CMI data only.
Let’s check this the MQTT server.
$ mosquitto_sub -v -t telegraf/#
telegraf/cmi/server/http {"metrics":[{"fields":{"Heizkreispumpe":1,"Heizungsaussentemperatur":33.6,"Kesselanforderung":1,"Vorlauftemperatur":54.7,"Warmwasserladepumpe":0,"Warmwasserspeicher":53,"pufferspeicheroben":75.9,"pufferspeicherunten":75.9},"name":"http","tags":{"cminode":"node 31","host":"server","sourcedevice":"cmi","url":"http://<ip>/INCLUDE/api.cgi?jsonnode=31\u0026jsonparam=I,O,Na"},"timestamp":1613745181}]}
telegraf/cmi/server/http {"metrics":[{"fields":{"Heizkreispumpe":1,"Heizungsaussentemperatur":33.6,"Kesselanforderung":1,"Vorlauftemperatur":54.7,"Warmwasserladepumpe":0,"Warmwasserspeicher":53.1,"pufferspeicheroben":75.9,"pufferspeicherunten":75.9},"name":"http","tags":{"cminode":"node 31","host":"server","sourcedevice":"cmi","url":"http://<ip>/INCLUDE/api.cgi?jsonnode=31\u0026jsonparam=I,O,Na"},"timestamp":1613745241}]}