How can I recreate this message structure in an inject node?

{
	"payload": {
		"brightness": 35,
		"color_temp": 360,
		"state": "ON",
		"transition": 2
	},
	"wled": "99",
	"holiday": "none",
	"level": 35,
	"statemsg": "off",
	"garage": 1,
	"kitchen": "99",
	"lutron": 100,
	"_msgid": "1536b9b1d908639d",
	"_event": "node:e6bc18b574cd6107-28cd8355d3d338bd"
}

For testing, I would like to recreate the message structure above. Trying to send that first object without a key throws an error. How do I structure this so that doesn't happen?

{
	{
		"brightness": 35,
		"color_temp": 360,
		"state": "ON",
		"transition": 2
	},
	"wled": "99",
	"holiday": "none",
	"level": 35,
	"statemsg": "off",
	"garage": 1,
	"kitchen": "99",
	"lutron": 100,
	"_msgid": "1536b9b1d908639d",
	"_event": "node:e6bc18b574cd6107-28cd8355d3d338bd"
}

You can not do it in a single rule, you would need 10 rules one for payload, then one for wled, then one for holiday, etc.

Probably easier to have an inject followed by a function node containing

return {
	"payload": {
		"brightness": 35,
		"color_temp": 360,
		"state": "ON",
		"transition": 2
	},
	"wled": "99",
	"holiday": "none",
	"level": 35,
	"statemsg": "off",
	"garage": 1,
	"kitchen": "99",
	"lutron": 100,
	"_msgid": "1536b9b1d908639d",
	"_event": "node:e6bc18b574cd6107-28cd8355d3d338bd"
}
1 Like

Thanks, so simple. I didn't even think to use a function node.

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