'Telegraf json v2 parsing

I'm trying to pick out the local_temperature property from a Zigbee TRV.

Here is my section from /etc/telegraf/telegraf.conf

  [[inputs.mqtt_consumer]]
    servers = ["tcp://127.0.0.1:1883"]
    topics = [
      "zigbee2mqtt/Home/+/Radiator",
    ]
    data_format = "json_v2"
    [[inputs.mqtt_consumer.json_v2]]
      measurement_name = "temperature"
      [[inputs.mqtt_consumer.topic_parsing]]
        topic = "_/room/_"
      [[inputs.mqtt_consumer.json_v2.field]]
        path = "local_temperature"
        type = "float"

Error from /var/log/syslog

Feb 21 11:03:07 mini31 telegraf[23428]: 2022-02-21T11:03:07Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:36: "{\"battery\":97,\"boost_heating\":\"OFF\",\"boost_heating_countdown\":0,\"boost_heating_countdown_time_set\":300,\"child_lock\":\"UNLOCK\",\"current_heating_setpoint\":8,\"eco_mode\":\"OFF\",\"eco_temperature\":12,\"linkquality\":110,\"local_temperature\":17.5,\"local_temperature_calibration\":-2,\"max_temperature\":24,\"min_temperature\":8,\"position\":25,\"preset\":\"programming\",\"programming_mode\":\"09:00/19°C  12:00/13°C  14:00/19°C  17:00/8°C  06:00/8°C  12:00/8°C  14:30/8°C  17:30/8°C  06:00/8°C  12:30/8°C  14:30/8°C  18:30/8°C\",\"window\":\"CLOSED\",\"window_detection\":\"OFF\"}"

What does it even mean?



Solution 1:[1]

[[inputs.mqtt_consumer]]
  servers = ["tcp://127.0.0.1:1883"]
  topics = [
    "zigbee2mqtt/Home/+/Radiator",
  ]
  data_format = "json_v2"
  [[inputs.mqtt_consumer.json_v2]]
    measurement_name = "temperature"
    [[inputs.mqtt_consumer.topic_parsing]]
      topic = "zigbee2mqtt/Home/+/Radiator"
      tags = "_/_/room/_"
    [[inputs.mqtt_consumer.json_v2.field]]
      path = "local_temperature"
      rename = "temperature"
      type = "float"
  [[inputs.mqtt_consumer.json_v2]]
    measurement = "valve"
    [[inputs.mqtt_consumer.json_v2.field]]
      path = "position"
      rename = "valve"
      type = "float"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Richard Barraclough