From 0f8f5b08f38139209ebc34a048e2ab7a8dbf789e Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Thu, 8 Oct 2026 21:26:07 +0200 Subject: [PATCH 1/2] fix(telegraf): keep full decision text in sample config The /decision topic was consumed by the catch-all "house/batcontrol/+" input, which uses the "value" parser. That parser splits the payload on whitespace and keeps only the last token, so a decision such as "Charge from Grid 1250 W - usable energy is below the reserve" reached InfluxDB as decision="reserve". The MQTT payload itself is correct (other consumers such as iobroker show the full line). Drop the decision topic from the catch-all input via tagdrop and add a dedicated consumer that parses it with grok (%{GREEDYDATA}), so the whole sentence is stored as measurement batcontrol-decision. Also add a commented-out json_v2 consumer for /decision/attributes, which exposes the stable reason code as a tag and the mode as an int field. Verified against telegraf 1.31 with a local mosquitto: the full sentence is written once, no truncated duplicate, other topics unchanged. Co-Authored-By: Claude Opus 5 --- config/telegraf.sample.conf | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/config/telegraf.sample.conf b/config/telegraf.sample.conf index 3251f13e..219a8bba 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. Both fields +# are null until the first decision with a decisive step, hence optional. +#[[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"] From 3ab85b0cfc04911b3be82f48fd186a6c574aa601 Mon Sep 17 00:00:00 2001 From: Matthias Strubel Date: Fri, 9 Oct 2026 07:54:25 +0200 Subject: [PATCH 2/2] Update comments for optional fields in telegraf config Clarify optional fields in configuration comments. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- config/telegraf.sample.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/telegraf.sample.conf b/config/telegraf.sample.conf index 219a8bba..0f376783 100644 --- a/config/telegraf.sample.conf +++ b/config/telegraf.sample.conf @@ -39,8 +39,8 @@ data_format = "grok" grok_patterns = ["%{GREEDYDATA:decision}"] -# Optional: the machine readable side of the same status change. Both fields -# are null until the first decision with a decisive step, hence optional. +# 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 = [