Reformat json and remove array structure

Hi, I need some help with this.
My Shelly 3EM with Tasmota sends status messages like this:

{
	"Time": "2022-12-14T17:40:07",
	"ENERGY": {
		"Value1": 11,
		"Value2": 12,
		"Value3": 13,
		"Power": [
			1693,
			168,
			14
		],
		"Frequency": [
			50,
			50,
			50
		],
		"Voltage": [
			234,
			234,
			237
		],
		"Value4": 14
	}
}

I would like to send this to an InfluxDB and for this to remove the arrays. I think I need something like this:

	"ENERGY": {
		"Value1": 11,
		"Value2": 12,
		"Value3": 13,
		"Power_A": 1693,
		"Power_B": 168,
		"Power_C": 14,
		"Frequency_A": 50,
		"Frequency_B": 50,
		"Frequency_C": 50,
		"Voltage_A": 234,
		"Voltage_B": 234,
		"Voltage_C": 237,
		"Value4": 14
	}

How can this be done?
Thanks!

The simplest option would be to run it through a template node to format the output
e.g.

[{"id":"8af8b10a92587694","type":"inject","z":"da8a6ef0b3c9a5c8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{ \t\"Time\": \"2022-12-14T17:40:07\", \t\"ENERGY\": { \t\t\"Value1\": 11, \t\t\"Value2\": 12, \t\t\"Value3\": 13, \t\t\"Power\": [ \t\t\t1693, \t\t\t168, \t\t\t14 \t\t], \t\t\"Frequency\": [ \t\t\t50, \t\t\t50, \t\t\t50 \t\t], \t\t\"Voltage\": [ \t\t\t234, \t\t\t234, \t\t\t237 \t\t], \t\t\"Value4\": 14 \t} }","payloadType":"json","x":330,"y":340,"wires":[["6b6a0f9a71d9a31b"]]},{"id":"6b6a0f9a71d9a31b","type":"template","z":"da8a6ef0b3c9a5c8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n\t\"ENERGY\": {\n\t\t\"Value1\": {{payload.ENERGY.Value1}},\n\t\t\"Value2\": {{payload.ENERGY.Value2}},\n\t\t\"Value3\": {{payload.ENERGY.Value3}},\n\t\t\"Power_A\": {{payload.ENERGY.Power.0}},\n\t\t\"Power_B\": {{payload.ENERGY.Power.1}},\n\t\t\"Power_C\": {{payload.ENERGY.Power.2}},\n\t\t\"Frequency_A\": {{payload.ENERGY.Frequency.0}},\n\t\t\"Frequency_B\": {{payload.ENERGY.Frequency.1}},\n\t\t\"Frequency_C\": {{payload.ENERGY.Frequency.2}},\n\t\t\"Voltage_A\": {{payload.ENERGY.Voltage.0}},\n\t\t\"Voltage_B\": {{payload.ENERGY.Voltage.1}},\n\t\t\"Voltage_C\": {{payload.ENERGY.Voltage.2}},\n\t\t\"Value4\": {{payload.ENERGY.Value4}}\n\t}\n}","output":"json","x":520,"y":340,"wires":[["e5e60a2f2d3ff4cc"]]},{"id":"e5e60a2f2d3ff4cc","type":"debug","z":"da8a6ef0b3c9a5c8","name":"debug 114","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":710,"y":380,"wires":[]}]

That did the trick, thank you.
I wasn't aware of the template node :ok_hand:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.