I finally have my SMETS1 smart meter linked to a device which lets me monitor it myself. I got a Hildebrand CAD which supports local MQTT which was really easy to get set up. I then use telegraf to pull the power reading from MQTT and add them to my influxdb which I then query from grafana. The problem was I sometimes get a value of -8388.608 kW from the meter and this messed up my graphs unless I removed the value from the database. It was always -8388.608 so it seems like the SMETS1 meter was just sending invalid data to the CAD.
To filter the values out automatically in telegraf so I didn't have to keep removing them from the database I used the json_v2 data_format and set the GJSON path to only return data if the power value is greater than -8000.

[[inputs.mqtt_consumer]]
  servers = ["tcp://192.168.1.5:1883"]
  topics = ["glow/+/SENSOR/electricitymeter"]
  username = "telegraf"
  password = "password"

  data_format = "json_v2"
  [[inputs.mqtt_consumer.json_v2]]
    [[inputs.mqtt_consumer.json_v2.object]]
      path = "[@this].#(electricitymeter.power.value > -8000).@this"

Since I only wanted this filter applied to the electricity meter readings, I needed to separate that from the other readings from the CAD. So I needed to also add another entry for the gas meter and IHD status which return the unfiltered JSON.

[[inputs.mqtt_consumer]]
  servers = ["tcp://192.168.1.5:1883"]
  topics = ["glow/+/SENSOR/gasmeter", "glow/+/STATE"]
  username = "telegraf"
  password = "password"

  data_format = "json_v2"
  [[inputs.mqtt_consumer.json_v2]]
    [[inputs.mqtt_consumer.json_v2.object]]
      path = "@this"

Previous Post Next Post