Ok here you go @smcgann99
I've created test flows based on the function in which I had my initial problem and after much confusion I'm still confused.
But first I have a few questions which do probably expose some of my lack of understanding of Node RED or Javascript.
I've said it in other forum posts but I'm 74 years old with a background in Programming and Computer languages that precedes 2004. Until less than 18months ago I knew nothing of Javascript and had never heard of Node.js or Node RED and I knew nothing of Objects or JSON,though I had done a little work in Java and C++. Everything I now know I've learned in that time. So please excuse the many holes in my knowledge.
In doing the work to define this problem I had to ask "Well what is a "Flow"? I can see a clear definition of a "Subflow" but if a flow is a Tab in the Node RED editor what do I call these nodes wired together with an Inject at one end and a Debug at the other but several of them, unconnected on the same Editor Tab and isn't Flow context really Tab Context.
And now I have to ask what is Context storage ? I'd thought of it as somewhere outside my function or node where I could hold some data from one node or flow and access it in another. I assumed I had to put my data in that place using a .set() and retrieve it using a .get() and that was the only way I could get it in and out of these places and I assumed that they were discrete. I haven't seen anywhere in discussions on Context that you can't have a Flow context variable with the same name as one in Global but you create yourself a lot of problems in doing so.
I'm running NodeRed as an Integration within Home Assistant this is within VirtualBox on Linux Mint. My everyday UI is on AVG Secure Browser on a Windows 11 Laptop
Node RED Integration is Version 13.5.3
The requirement within my project is to maintain an array of objects with Add/Change/Delete functions
My current array is held in Global as Radiators_Today and initially contains 46 elements. My original attempt was
var itemList = global.get("Radiators_Today");
.
.
.
itemList.push(msg1)
but I find that this updates the Global variable without even doing a Global.set which I found most odd. In all my programming experience if you assign the value of a new variable and then manipulate the new variable you don't usually affect the value of the original source.
I decided to see if the same effect occurred using a Flow variable. I added the code to do so, named the Flow context variable the same as the Global one but left the Global variable code in place. I found that when I updated one of the internal variables in the function the other internal variable and the Context variables themselves were also updated.
I created a new Editor Tab with the same Context Variables. When context variables in the first tab were updated the Flow Variable in the other tab was also updated reflecting the change in the Global variable.
[{"id":"0c3ae8ccf53d628d","type":"tab","label":"Test Tab 1","disabled":false,"info":"","env":[]},{"id":"13801a39d9f3c5b6","type":"inject","z":"0c3ae8ccf53d628d","name":"Flow 1 Initialise","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Lounge","payload":"[{\"Id\":\"Backbed\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0000Backbed\"},{\"Id\":\"Master1\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0000Master1\"},{\"Id\":\"Master2\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0000Master2\"},{\"Id\":\"Kitchen1\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0000Kitchen1\"},{\"Id\":\"Kitchen2\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0000Kitchen2\"},{\"Id\":\"Lounge\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"RoomTemp\":0,\"MinsDevice\":\"0000Lounge\"},{\"Id\":\"Hall\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0000Hall\"},{\"Id\":\"Bathroom\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0000Bathroom\"},{\"Id\":\"Shower\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0000Shower\"},{\"Id\":\"Lounge\",\"Hour\":0,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"RoomTemp\":0,\"MinsDevice\":\"0000Lounge\"},{\"Id\":\"Lounge\",\"Hour\":7,\"Min\":0,\"temperature\":20,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"RoomTemp\":20,\"MinsDevice\":\"0420Lounge\"},{\"Id\":\"Lounge\",\"Hour\":8,\"Min\":0,\"temperature\":20,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"RoomTemp\":20,\"MinsDevice\":\"0480Lounge\"},{\"Id\":\"Hall\",\"Hour\":8,\"Min\":0,\"temperature\":20,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0480Hall\"},{\"Id\":\"Master1\",\"Hour\":8,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0480Master1\"},{\"Id\":\"Master2\",\"Hour\":8,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0480Master2\"},{\"Id\":\"Lounge\",\"Hour\":9,\"Min\":40,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"RoomTemp\":0,\"MinsDevice\":\"0580Lounge\"},{\"Id\":\"Hall\",\"Hour\":9,\"Min\":40,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0580Hall\"},{\"Id\":\"Kitchen2\",\"Hour\":9,\"Min\":40,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0580Kitchen2\"},{\"Id\":\"Master1\",\"Hour\":9,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0590Master1\"},{\"Id\":\"Master2\",\"Hour\":9,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0590Master2\"},{\"Id\":\"Kitchen1\",\"Hour\":10,\"Min\":10,\"temperature\":22,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0610Kitchen1\"},{\"Id\":\"Kitchen1\",\"Hour\":10,\"Min\":40,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0640Kitchen1\"},{\"Id\":\"Kitchen2\",\"Hour\":10,\"Min\":40,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0640Kitchen2\"},{\"Id\":\"Kitchen1\",\"Hour\":14,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0890Kitchen1\"},{\"Id\":\"Kitchen2\",\"Hour\":14,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0890Kitchen2\"},{\"Id\":\"Lounge\",\"Hour\":15,\"Min\":30,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"RoomTemp\":23,\"MinsDevice\":\"0930Lounge\"},{\"Id\":\"Hall\",\"Hour\":15,\"Min\":30,\"temperature\":20,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0930Hall\"},{\"Id\":\"Bathroom\",\"Hour\":15,\"Min\":30,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0930Bathroom\"},{\"Id\":\"Shower\",\"Hour\":15,\"Min\":30,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0930Shower\"},{\"Id\":\"Kitchen1\",\"Hour\":15,\"Min\":40,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0940Kitchen1\"},{\"Id\":\"Kitchen2\",\"Hour\":15,\"Min\":40,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"0940Kitchen2\"},{\"Id\":\"Lounge\",\"Hour\":16,\"Min\":30,\"temperature\":23,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"RoomTemp\":23,\"MinsDevice\":\"0990Lounge\"},{\"Id\":\"Master1\",\"Hour\":19,\"Min\":0,\"temperature\":20,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1140Master1\"},{\"Id\":\"Master2\",\"Hour\":19,\"Min\":0,\"temperature\":20,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1140Master2\"},{\"Id\":\"Master1\",\"Hour\":19,\"Min\":45,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1185Master1\"},{\"Id\":\"Master2\",\"Hour\":19,\"Min\":45,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1185Master2\"},{\"Id\":\"Master1\",\"Hour\":21,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1260Master1\"},{\"Id\":\"Master2\",\"Hour\":21,\"Min\":0,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1260Master2\"},{\"Id\":\"Master1\",\"Hour\":21,\"Min\":30,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1290Master1\"},{\"Id\":\"Master2\",\"Hour\":21,\"Min\":30,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1290Master2\"},{\"Id\":\"Kitchen1\",\"Hour\":21,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1310Kitchen1\"},{\"Id\":\"Kitchen2\",\"Hour\":21,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1310Kitchen2\"},{\"Id\":\"Lounge\",\"Hour\":21,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"RoomTemp\":0,\"MinsDevice\":\"1310Lounge\"},{\"Id\":\"Hall\",\"Hour\":21,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1310Hall\"},{\"Id\":\"Bathroom\",\"Hour\":21,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1310Bathroom\"},{\"Id\":\"Shower\",\"Hour\":21,\"Min\":50,\"temperature\":0,\"Sun\":\"yes\",\"Mon\":\"yes\",\"Tue\":\"yes\",\"Wed\":\"yes\",\"Thu\":\"yes\",\"Fri\":\"yes\",\"Sat\":\"yes\",\"MinsDevice\":\"1310Shower\"}]","payloadType":"json","x":220,"y":100,"wires":[["b1faf85f15f94bbf"]]},{"id":"b1faf85f15f94bbf","type":"change","z":"0c3ae8ccf53d628d","name":"","rules":[{"t":"set","p":"Radiators_Today","pt":"global","to":"payload","tot":"msg"},{"t":"set","p":"device","pt":"flow","to":"topic","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"Radiators","tot":"str"},{"t":"set","p":"Radiators_Today","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":100,"wires":[[]]},{"id":"4d4e2b97edd4b775","type":"inject","z":"0c3ae8ccf53d628d","name":"Flow 2 Update Global & Flow","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Start\":\"1970-01-01T11:28:00.000Z\",\"temperature\":20,\"End\":null,\"All\":true,\"Sun\":false,\"Mon\":false,\"Tue\":false,\"Wed\":false,\"Thu\":false,\"Fri\":false,\"Sat\":false}","payloadType":"json","x":260,"y":180,"wires":[["ff773131d635de11"]]},{"id":"ff773131d635de11","type":"function","z":"0c3ae8ccf53d628d","name":"Flow and Global","func":"\nvar hours, minutes, seconds, milliseconds, duration;\nvar inMsg = msg.payload\nvar domain = msg.topic;\nvar id = flow.get(\"device\");\nvar itemList = global.get(\"Radiators_Today\");\nvar itemList2 = flow.get(\"Radiators_Today\");\n\nvar newItemList = []\nfor (var i =0; i <itemList.length; i++){\n newItemList[i] = itemList[i]\n}\n\nconst time = new Date(inMsg.Start)\n// this is the number of milliseconds into the day, if needed\n//const msecLocal = time.getTime() - time.getTimezoneOffset() * 60000\nconst hour = time.getHours()\nconst min = time.getMinutes()\nvar msg1 = {}\nmsg1.Id = id;\nmsg1.Hour = hour;\nmsg1.Min = min;\nmsg1.temperature = inMsg.temperature\n\nif (inMsg.All == true) {\n msg1.Sun = true\n msg1.Mon = true\n msg1.Tue = true\n msg1.Wed = true\n msg1.Thu = true\n msg1.Fri = true\n msg1.Sat = true\n} else {\n msg1.Sun = inMsg.Sun\n msg1.Mon = inMsg.Mon\n msg1.Tue = inMsg.Tue\n msg1.Wed = inMsg.Wed\n msg1.Thu = inMsg.Thu\n msg1.Fri = inMsg.Fri\n msg1.Sat = inMsg.Sat\n\n}\n\nvar mins = hour * 60 + min\nvar Mins = mins.toString()\nmsg1.MinsDevice = Mins.padStart(4, 0) + id;\nitemList.push(msg1)\nitemList2.push(msg1)\nnewItemList.push(msg1)\nnode.warn(itemList)\nnode.warn(itemList2)\nnode.warn(newItemList)\nmsg.payload = itemList\nnode.send([msg,null,null])\nmsg.payload = itemList2\nnode.send([null, msg, null])\n\nmsg.payload = newItemList\nnode.send([null,null,msg])\nreturn \n\n\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":180,"wires":[["72a4f19679f5c918"],["5b327aa4bbb68493"],["cab83d28a157c020"]]},{"id":"72a4f19679f5c918","type":"debug","z":"0c3ae8ccf53d628d","name":"Global","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":160,"wires":[]},{"id":"5b327aa4bbb68493","type":"debug","z":"0c3ae8ccf53d628d","name":"Flow","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":200,"wires":[]},{"id":"cab83d28a157c020","type":"debug","z":"0c3ae8ccf53d628d","name":"New Array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":240,"wires":[]},{"id":"56794ccf340dec0e","type":"inject","z":"0c3ae8ccf53d628d","name":"Flow 3 Update Global only","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"Start\":\"1970-01-01T11:28:00.000Z\",\"temperature\":20,\"End\":null,\"All\":true,\"Sun\":false,\"Mon\":false,\"Tue\":false,\"Wed\":false,\"Thu\":false,\"Fri\":false,\"Sat\":false}","payloadType":"json","x":270,"y":340,"wires":[["51fae1eade7ec7d6"]]},{"id":"51fae1eade7ec7d6","type":"function","z":"0c3ae8ccf53d628d","name":"Global Only","func":"\nvar hours, minutes, seconds, milliseconds, duration;\nvar inMsg = msg.payload\nvar domain = msg.topic;\nvar id = flow.get(\"device\");\nvar itemList = global.get(\"Radiators_Today\");\nvar itemList2 = flow.get(\"Radiators_Today\");\n\nvar newItemList = []\nfor (var i =0; i <itemList.length; i++){\n newItemList[i] = itemList[i]\n}\n\nconst time = new Date(inMsg.Start)\n// this is the number of milliseconds into the day, if needed\n//const msecLocal = time.getTime() - time.getTimezoneOffset() * 60000\nconst hour = time.getHours()\nconst min = time.getMinutes()\nvar msg1 = {}\nmsg1.Id = id;\nmsg1.Hour = hour;\nmsg1.Min = min;\nmsg1.temperature = inMsg.temperature\n\nif (inMsg.All == true) {\n msg1.Sun = true\n msg1.Mon = true\n msg1.Tue = true\n msg1.Wed = true\n msg1.Thu = true\n msg1.Fri = true\n msg1.Sat = true\n} else {\n msg1.Sun = inMsg.Sun\n msg1.Mon = inMsg.Mon\n msg1.Tue = inMsg.Tue\n msg1.Wed = inMsg.Wed\n msg1.Thu = inMsg.Thu\n msg1.Fri = inMsg.Fri\n msg1.Sat = inMsg.Sat\n\n}\n\nvar mins = hour * 60 + min\nvar Mins = mins.toString()\nmsg1.MinsDevice = Mins.padStart(4, 0) + id;\nitemList.push(msg1)\n//itemList2.push(msg1)\nnewItemList.push(msg1)\nnode.warn(itemList)\nnode.warn(newItemList)\nmsg.payload = itemList\nnode.send([msg,null,null])\nmsg.payload = newItemList\nnode.send([null,null,msg])\nreturn \n\n\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":340,"wires":[["6f87c56e41bb4290"],[],["7429c4373afa894c"]]},{"id":"6f87c56e41bb4290","type":"debug","z":"0c3ae8ccf53d628d","name":"Global","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":340,"wires":[]},{"id":"c8f737bd98a45d30","type":"debug","z":"0c3ae8ccf53d628d","name":"debug 53","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":700,"y":380,"wires":[]},{"id":"7429c4373afa894c","type":"debug","z":"0c3ae8ccf53d628d","name":"New Array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":420,"wires":[]}]
continued.....