diff --git a/config/telegraf.sample.conf b/config/telegraf.sample.conf index 3251f13e..0f376783 100644 --- a/config/telegraf.sample.conf +++ b/config/telegraf.sample.conf @@ -22,6 +22,41 @@ topic = "+/batcontrol/+" measurement = "_/measurement/_" tags = "_/_/pivot_field" + # The "value" parser keeps only the last whitespace separated token of a + # payload, so free text like /decision would arrive truncated. It is + # handled by the dedicated consumer below instead. + [inputs.mqtt_consumer.tagdrop] + pivot_field = ["decision"] + +# /decision is a full sentence ("Charge from Grid 1250 W - ..."), so it needs +# a parser that takes the payload as a whole instead of the "value" parser. +[[inputs.mqtt_consumer]] + servers = ["tcp://mqtt:1883"] + topics = [ + "house/batcontrol/decision" + ] + name_override = "batcontrol-decision" + data_format = "grok" + grok_patterns = ["%{GREEDYDATA:decision}"] + +# Optional: the machine readable side of the same status change. "reason" is +# null until the first decision with a decisive step, hence optional ("mode" is always an int). +#[[inputs.mqtt_consumer]] +# servers = ["tcp://mqtt:1883"] +# topics = [ +# "house/batcontrol/decision/attributes" +# ] +# name_override = "batcontrol-decision" +# data_format = "json_v2" +# [[inputs.mqtt_consumer.json_v2]] +# [[inputs.mqtt_consumer.json_v2.tag]] +# path = "decided_by.reason" +# rename = "reason" +# optional = true +# [[inputs.mqtt_consumer.json_v2.field]] +# path = "mode" +# type = "int" +# optional = true [[inputs.mqtt_consumer]] servers = ["tcp://mqtt:1883"]