Hi.
I am trying to save a thermostat mode to a flow variable using the msg.topic but it does not work as expected.
Flow:
Result:
How can i save it based on the MQTT adress without getting all those array enteries as well?
This is my example flow:
[{"id":"d8f143e9.eb063","type":"function","z":"82add03.b9a433","name":"","func":"//Get adress and build flow variable name \nvar address = msg.topic.split(\"/\")[2];\nvar newname = \"hdl.fh.\" + address + \".textmode\"\n\n//Save msg to flow variable\nflow.set (newname, msg.payload)\n\n//Debug\nmsg.address = address\nmsg.newname = newname\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":360,"y":120,"wires":[["ca252047.e559a"]]},{"id":"ca252047.e559a","type":"debug","z":"82add03.b9a433","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":120,"wires":[]},{"id":"dbbd3792.f6fd88","type":"inject","z":"82add03.b9a433","name":"Test input msg: Normal","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"hdl/fh/1.106/textmode/set","payload":"normal","payloadType":"str","x":140,"y":80,"wires":[["d8f143e9.eb063","2bfddbe0.c8dea4"]]},{"id":"de39039.e93a9","type":"inject","z":"82add03.b9a433","name":"Test input msg: Day","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"hdl/fh/1.106/textmode/set","payload":"day","payloadType":"str","x":130,"y":140,"wires":[["d8f143e9.eb063","2bfddbe0.c8dea4"]]},{"id":"2bfddbe0.c8dea4","type":"debug","z":"82add03.b9a433","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":350,"y":200,"wires":[]}]