hi,
I am assigning the content of a flow-variable to a new variable.
it looks like, on changing in the new variable, the content of the flow variable is also changed without any flow.set in between.
I think I have no logic error, I do not get where I change the flow variable
attached 4 flows to demonstrate.
the part which will change is the active from true to false:
[{"id":"7596cb0ce1eff1ce","type":"function","z":"df7c9eb28d26a1c2","name":"setflowvar","func":"var existingtimeplan = JSON.parse('[{\"Active\":false,\"Power\":0,\"ScheduleType\":\"CHARGE_MAX\",\"TimeTable\":{\"Start\":\"00:00\",\"End\":\"00:01\"},\"Weekdays\":{\"Mon\":true,\"Tue\":true,\"Wed\":true,\"Thu\":true,\"Fri\":true,\"Sat\":true,\"Sun\":true}},{\"Active\":false,\"Power\":0,\"ScheduleType\":\"CHARGE_MAX\",\"TimeTable\":{\"Start\":\"00:01\",\"End\":\"00:02\"},\"Weekdays\":{\"Mon\":true,\"Tue\":true,\"Wed\":true,\"Thu\":true,\"Fri\":true,\"Sat\":true,\"Sun\":true}},{\"Active\":true,\"Power\":500,\"ScheduleType\":\"CHARGE_MAX\",\"TimeTable\":{\"Start\":\"06:00\",\"End\":\"12:00\"},\"Weekdays\":{\"Mon\":true,\"Tue\":true,\"Wed\":true,\"Thu\":true,\"Fri\":true,\"Sat\":true,\"Sun\":true}},{\"Active\":true,\"Power\":2000,\"ScheduleType\":\"CHARGE_MAX\",\"TimeTable\":{\"Start\":\"12:00\",\"End\":\"17:00\"},\"Weekdays\":{\"Mon\":true,\"Tue\":true,\"Wed\":true,\"Thu\":true,\"Fri\":true,\"Sat\":true,\"Sun\":true}},{\"Active\":false,\"Power\":10000,\"ScheduleType\":\"CHARGE_MAX\",\"TimeTable\":{\"Start\":\"19:00\",\"End\":\"22:00\"},\"Weekdays\":{\"Mon\":true,\"Tue\":true,\"Wed\":true,\"Thu\":true,\"Fri\":true,\"Sat\":true,\"Sun\":true}},{\"Active\":false,\"Power\":9000,\"ScheduleType\":\"DISCHARGE_MIN\",\"TimeTable\":{\"Start\":\"17:00\",\"End\":\"23:00\"},\"Weekdays\":{\"Mon\":true,\"Tue\":true,\"Wed\":true,\"Thu\":true,\"Fri\":true,\"Sat\":true,\"Sun\":true}},{\"Active\":false,\"Power\":2000,\"ScheduleType\":\"DISCHARGE_MIN\",\"TimeTable\":{\"Start\":\"19:00\",\"End\":\"23:00\"},\"Weekdays\":{\"Mon\":true,\"Tue\":true,\"Wed\":true,\"Thu\":true,\"Fri\":true,\"Sat\":true,\"Sun\":true}}]')\n\nflow.set('existing', existingtimeplan)\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":540,"wires":[[]]},{"id":"77bcbd1029343d15","type":"inject","z":"df7c9eb28d26a1c2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":520,"y":500,"wires":[["7596cb0ce1eff1ce"]]},{"id":"64d068f710b094de","type":"function","z":"df7c9eb28d26a1c2","name":"useflowvar","func":"var mytimeplanentry = {\n 'Active': true,\n 'Power': 2000,\n 'ScheduleType': \"CHARGE_MAX\",\n 'TimeTable': {\n 'End': \"20:00\",\n 'Start': \"06:00\"\n },\n 'Weekdays': {\n 'Fri': true,\n 'Mon': true,\n 'Sat': true,\n 'Sun': true,\n 'Thu': true,\n 'Tue': true,\n 'Wed': true\n }\n};\nvar newtimeplan = []\nnewtimeplan.push(mytimeplanentry) // first add mytimeplanentry\nvar storedtimeplan = flow.get('existing')\nfor (var timeplans in storedtimeplan) {\n //Deactivate all Plans and put them behind mytimeplanentry\n storedtimeplan[timeplans]['Active'] = false;\n newtimeplan.push(storedtimeplan[timeplans])\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":540,"wires":[[]]},{"id":"7629b19851eac8c9","type":"inject","z":"df7c9eb28d26a1c2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":700,"y":500,"wires":[["64d068f710b094de"]]}]