Passwing Tasmota JSON Data

Hi,

I’m am trying to pass the following json which I get from Tasmota:

{
“Time”: “2022-08-19T22:05:51”,
“ATC5a8986”: {
“mac”: “a4c1385a8986”,
“Temperature”: 22.9,
“Humidity”: 63.3,
“DewPoint”: 15.5,
“Btn”: 1,
“Battery”: 81,
“RSSI”: -80
},
“ATCff2f89”: {
“mac”: “a4c138ff2f89”,
“Temperature”: 25.3,
“Humidity”: 60.2,
“DewPoint”: 17.0,
“Btn”: 1,
“Battery”: 77,
“RSSI”: -97
},
“TempUnit”: “C”
}

In my ignorance I would have hoped that this would work:

[[inputs.mqtt_consumer.topic_parsing]]
    topic = "tele/+/SENSOR/#"

[[inputs.mqtt_consumer.json_v2]]
    measurement_name = "tasmota"

    [[inputs.mqtt_consumer.json_v2.object]]
        path = "ATC*"
        tags = ["mac"]
        excluded_keys = ["Btn","Battery","RSSI"]

But I only get the first object:

tasmota,host=telegraf,mac=a4c1385a8986,topic=tele/tasmota_74E2EC/SENSOR Temperature=21.3,Humidity=61,DewPoint=13.5 1661076349976591374

The JSON is not an array which makes it difficult, is there any other way to do this but to address each object by it self ?

Thanks.

If you are only going to have two different objects, you could hard-code it as:

    data_format = "json_v2"
    [[inputs.file.json_v2]]
        [[inputs.file.json_v2.object]]
            measurement_name = "ATC5a8986"
            path = "ATC5a8986"
            tags = ["mac"]
            excluded_keys = ["Btn","Battery","RSSI"]

        [[inputs.file.json_v2.object]]
            measurement_name = "ATCff2f89"
            path = "ATCff2f89"
            tags = ["mac"]
            excluded_keys = ["Btn","Battery","RSSI"]

Which produces:

tasmota,mac=a4c1385a8986 Temperature=22.9,Humidity=63.3,DewPoint=15.5 1661178666000000000
tasmota,mac=a4c138ff2f89 Temperature=25.3,Humidity=60.2,DewPoint=17 1661178666000000000

If you have many more of those values, then I’m not sure of a clean way with our current parser. If you want to understand the GJSON syntax a bit more, you can go checkout the GJSON playground, which will show you what ATC* returns.

Thanks @jpowers,

The json is valid, but not correct, they (Tasmota) should have made the sensors an array of sensors, then it would have been possible to deal with it in a general way, but as they have made them objects in an object then I have to address each sensor individually - which also works, just not great.

The reason for my question; was if some else had dealt with this specific problem.

Thanks,
Cheers.