Telegraf + Mosquitto + Tasmota and JSON

Hello!

So, my google-fu is letting me down…

I’ve got an Ubuntu 16.04LTS running Telegraf 1.11.1-1, Mosquitto 1.4.8-1ubuntu0.16.04.7 and influxdb 0.10.0+dfsg1-1

I have a bunch of Tasmota-devices publishing sensor data to the Mosquitto, and all is well.

The sensors publish to the topic “tele/DEVICENAME/SENSOR” (Where devicename is unique per device)

The published payload is a JSON string like this

{“Time”:“2019-07-06T14:38:26”,“AM2301”:{“Temperature”:16.4,“Humidity”:70.7},“TempUnit”:“C”}

Great. Now i want Telegraf to grab this and do something useful. But, Despite having used telegraf previously for a variety of things, this is the first time i am trying the specific combination of MQTT and JSON… I’ve tried “all sort of things” but can not get telegraf to process the data and send to influx.

When i gave up last night, this was my telegraf.conf, and this (like everything else i have tried) gave me nothing in influx or my debug file. If i enable the “normal” system inputs, those gets inserted in influx nicely.

Sooo, could someone point me in the right direction?

root@server01:~# cat /etc/telegraf/telegraf.conf | grep ‘[1]*[[2]#;]’
[global_tags]
[agent]
interval = “10s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “0s”
flush_interval = “10s”
flush_jitter = “0s”
precision = “”
hostname = “”
omit_hostname = false
[[outputs.influxdb]]
urls = [“http://127.0.0.1:8086”]
database = “telegraf”
username = “telegraf”
password = “REDACTED”
[[outputs.file]]
files = [“stdout”, “/tmp/metrics.out”]
rotation_interval = “7d”
data_format = “influx”
[[inputs.mqtt_consumer]]
servers = [“tcp://localhost:1883”]
qos = 2
topics = [
“tele/+/SENSOR”
]
persistent_session = false
username = “telegraf”
password = “REDACTED”
data_format = “json”
json_time_key = “time”
json_time_format =“2006-01-02T15:04:05Z07:00”

Looking at the Mosquitto-log, it appears like Telegraf is listening. But what more do i need? Again, the above snipped is just one of many MANY iterations I have tried.

1562420926: Received SUBSCRIBE from Telegraf-Consumer-6iION
1562420926: tele/+/SENSOR (QoS 2)
1562420926: Telegraf-Consumer-6iION 2 tele/+/SENSOR
1562420926: Sending SUBACK to Telegraf-Consumer-6iION
1562420927: Received PINGREQ from DVES_546F12
1562420927: Sending PINGRESP to DVES_546F12
1562420931: Received PINGREQ from DVES_54713E
1562420931: Sending PINGRESP to DVES_54713E
1562420932: Received PUBLISH from DVES_54713E (d0, q0, r0, m0, ‘tele/Klimatsensor_Street01Lagt/STATE’, … (245 bytes))
1562420932: Sending PUBLISH to 87724fa6eb5a4d84b4ccc47806c3ba4b (d0, q0, r0, m0, ‘tele/Klimatsensor_Street01Lagt/STATE’, … (245 bytes))
1562420932: Received PUBLISH from DVES_54713E (d0, q0, r0, m0, ‘tele/Klimatsensor_Street01Lagt/SENSOR’, … (91 bytes))
1562420932: Sending PUBLISH to 87724fa6eb5a4d84b4ccc47806c3ba4b (d0, q0, r0, m0, ‘tele/Klimatsensor_Street01Lagt/SENSOR’, … (91 bytes))
1562420932: Sending PUBLISH to Telegraf-Consumer-6iION (d0, q0, r0, m0, ‘tele/Klimatsensor_Street01Lagt/SENSOR’, … (91 bytes))
1562420937: Received PINGREQ from DVES_546F12
1562420937: Sending PINGRESP to DVES_546F12
1562420941: Received PINGREQ from DVES_54713E


  1. [:blank:] ↩︎

  2. :blank: ↩︎

Yeah… So… time isnt the same as Time Sigh

Hi @janjoh welcome to the community ,

indeed , case sensitivity :slight_smile:

best regards