I have a Shelly H&T that publishes MQTT messages like this:
shelly/htg3-bathroom/status/devicepower:0 {"id": 0,"battery":{"V":6.22, "percent":100},"external":{"present":false}}
shelly/htg3-bathroom/status/humidity:0 {"id": 0,"rh":42.6}
shelly/htg3-bathroom/status/temperature:0 {"id": 0,"tC":18.0, "tF":64.3}
I would like to store those in InfluxDB, with one row containing all those values. Below is the config I’m currently using. However, when sending it to a file output I get separate rows for each value:
gen3_ht,dbname=shellies,host=piefke,shelly_name=htg3-bathroom battery_voltage=6.22 1706054192325945773
gen3_ht,dbname=shellies,host=piefke,shelly_name=htg3-bathroom battery_percent=100 1706054192325945773
gen3_ht,dbname=shellies,host=piefke,shelly_name=htg3-bathroom humidity=42.6 1706054192338387778
gen3_ht,dbname=shellies,host=piefke,shelly_name=htg3-bathroom temperature=18 1706054192346695739
But I’d expect something like this:
gen3_ht,dbname=shellies,host=piefke,shelly_name=htg3-bathroom battery_voltage=6.22,battery_percent=100,humidity=42.6,temperature=18 1706054192325945773
Am I doing something wrong? Here’s my config:
[[inputs.mqtt_consumer]]
alias = 'shelly-gen3-ht'
name_override = 'gen3_ht'
servers = ['tcp://127.0.0.1:1883']
topics = [
'shelly/htg3-bathroom/status/devicepower:0',
'shelly/htg3-bathroom/status/temperature:0',
'shelly/htg3-bathroom/status/humidity:0',
]
topic_tag = ''
username = 'telegraf'
password = 'XXX'
data_format = 'json_v2'
[[inputs.mqtt_consumer.json_v2]]
[[inputs.mqtt_consumer.json_v2.field]]
path = 'tC'
rename = 'temperature'
optional = true
[[inputs.mqtt_consumer.json_v2.field]]
path = 'rh'
rename = 'humidity'
optional = true
[[inputs.mqtt_consumer.json_v2.field]]
path = 'battery.V'
rename = 'battery_voltage'
optional = true
[[inputs.mqtt_consumer.json_v2.field]]
path = 'battery.percent'
rename = 'battery_percent'
optional = true
[[inputs.mqtt_consumer.topic_parsing]]
topic = 'shelly/+/status/+'
tags = '_/shelly_name/_/_'
[inputs.mqtt_consumer.tags]
dbname = 'shellies'
[[processors.unpivot]]
namepass = ['gen3_ht']
order = 1
[[processors.pivot]]
namepass = ['gen3_ht']
order = 2
tag_key = 'name'
value_key = 'value'