Hi,
I’m am trying to pass the following json strings which I get from my device:
tele/tasmota_28237D/SENSOR = {“Time”:“2024-01-28T19:42:41”,“ZbReceived”:{“0x06E2”:{“Device”:“0x06E2”,“Name”:“Sensor_1”,“Temperature”:7.33,“Endpoint”:1,“LinkQuality”:87}}}
tele/tasmota_28237D/SENSOR = {“Time”:“2024-01-28T19:43:09”,“ZbReceived”:{“0x1CAD”:{“Device”:“0x1CAD”,“Name”:“Sensor_2”,“Humidity”:55.02,“Endpoint”:1,“LinkQuality”:66}}}
My config:
[[inputs.mqtt_consumer]]
name_override = “tasmota”
servers = [“mqtt://192.168.x.x:1883”]
topics = [
“tele/tasmota_28237D/SENSOR”,
]
qos = 0
connection_timeout = “30s”
persistent_session = false
client_id = “telegraf”
data_format = “json_v2”
[[inputs.mqtt_consumer.json_v2]]
timestamp_path = “Time”
timestamp_format = “2006-01-02T15:04:05”
timestamp_timezone = “Europe/Berlin”
[[inputs.mqtt_consumer.json_v2.object]]
path = “ZbReceived”
included_keys = [“Device”, “Temperature”, “LinkQuality”]
Now I can’t get the data to be written to the influxdb via telegraph. Could any of you please help me?
Hi,
To be able to assist further it is extremely helpful if you explain what you have tried and what issue you are running into. For example, are you getting an error? Can you please share your logs?
Your JSON data looks like:
{
"Time": "2024-01-28T19:42:41",
"ZbReceived": {
"0x06E2": {
"Device": "0x06E2",
"Name": "Sensor_1",
"Temperature": 7.33,
"Endpoint": 1,
"LinkQuality": 87
}
}
}
However, your path currently is set to:
path = "ZbReceived"
Which does not look right. You instead want to get everything below the message ID, so something like:
path = "ZbReceived.*"
I would also suggest making Device a tag so you can distinguish between devices.
1 Like
Hi,
thank you for these information. I changed my configuration and it works now. Do you still see opportunities for improvement?
[[inputs.mqtt_consumer]]
servers = [“mqtt://192.168.x.x:1883”]
name_override = “tasmota”
topics = [
“tele/tasmota_28237D/+”,
]
qos = 0
connection_timeout = “30s”
persistent_session = false
client_id = “telegraf”
data_format = “json_v2”
[[inputs.mqtt_consumer.json_v2]]
timestamp_path = “Time”
timestamp_format = “2006-01-02T15:04:05”
timestamp_timezone = “Europe/Berlin”
[[inputs.mqtt_consumer.json_v2.object]]
path = “ZbReceived.*”
tags = [“Device”]
excluded_keys = [“Endpoint”,“Name”]
1 Like