Thank you @Andrei.
The first change worked well, the second I never thought through fully and would be very messy to interface with (Homeseer) .
It seems a better way would be for Node Red to send a "Start Charging" message at the times in the array and start a 30 minute timer, then send a "Stop Charging" message providing another "Start Charging" message in the array doesn't reset the timer for another 30 minutes (important to avoid sending stop charge and start charge in quick succession)
I've started to do this by saving the array to a file once a day, then reading it back every 30 minutes and trying to compare the array for any date matching now- but I am struggling.
I've explored Schedex, Bigtimer, moment, cron nodes but none seem quite right.
I think the "check now" function I have at the bottom of the diagram might work but struggling with the logic and "new" Javascript.
Does this seem the correct approach- or do you have another suggestion?
[{"id":"e7268cec.10fc4","type":"tab","label":"Electricity Cost Array - v3","disabled":false,"info":""},{"id":"b81bb405.408628","type":"inject","z":"e7268cec.10fc4","name":"","topic":"","payload":"2","payloadType":"num","repeat":"","crontab":"00 18 * * *","once":false,"onceDelay":0.1,"x":110,"y":80,"wires":[["a526f220.b0c59","5d2e495a.fe4458"]]},{"id":"396b680e.65db08","type":"json","z":"e7268cec.10fc4","name":"","property":"payload","action":"obj","pretty":false,"x":370,"y":200,"wires":[["6ad2403c.7f126","6b0b826.35dcd7c"]]},{"id":"4e4de1e1.e51eb","type":"split","z":"e7268cec.10fc4","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":630,"y":200,"wires":[["1b4ddc80.899204"]]},{"id":"6ad2403c.7f126","type":"change","z":"e7268cec.10fc4","name":"Results","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.results","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":200,"wires":[["4e4de1e1.e51eb"]]},{"id":"1b4ddc80.899204","type":"link out","z":"e7268cec.10fc4","name":"","links":["8e60f88c.14de78","1dab1119.b71d8f"],"x":755,"y":200,"wires":[]},{"id":"8a8ce1f6.9bfe1","type":"batch","z":"e7268cec.10fc4","name":"Batch 1 period","mode":"count","count":"1","overlap":"0","interval":10,"allowEmptySequence":false,"topics":[],"x":200,"y":280,"wires":[["e73de6e0.4d7d48"]]},{"id":"1dab1119.b71d8f","type":"link in","z":"e7268cec.10fc4","name":"","links":["1b4ddc80.899204"],"x":75,"y":280,"wires":[["8a8ce1f6.9bfe1"]]},{"id":"e73de6e0.4d7d48","type":"join","z":"e7268cec.10fc4","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":370,"y":280,"wires":[["78766d06.4958a4"]]},{"id":"78766d06.4958a4","type":"function","z":"e7268cec.10fc4","name":"Cost for batch","func":"function addValue(arr) {\n let add = 0;\n for (let ele of arr) {\n add = add + ele.value_inc_vat;\n }\n return add;\n}\n\nmsg.value_batch = addValue(msg.payload);\n\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":280,"wires":[["da76b813.73bab8","b3bce6c2.3cc1b8"]]},{"id":"aba7a46a.2d18b8","type":"debug","z":"e7268cec.10fc4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":910,"y":340,"wires":[]},{"id":"da76b813.73bab8","type":"change","z":"e7268cec.10fc4","name":"Transform","rules":[{"t":"set","p":"topic","pt":"msg","to":"payload[0].valid_from","tot":"msg"},{"t":"set","p":"pay.start","pt":"msg","to":"payload[0].valid_from","tot":"msg"},{"t":"set","p":"pay.time_end","pt":"msg","to":"payload[0].valid_to","tot":"msg"},{"t":"move","p":"value_batch","pt":"msg","to":"pay.value","tot":"msg"},{"t":"delete","p":"filename","pt":"msg"},{"t":"delete","p":"_event","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"pay.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":340,"wires":[["74d6a20a.9a36ac"]]},{"id":"74d6a20a.9a36ac","type":"join","z":"e7268cec.10fc4","name":"Create Array","mode":"custom","build":"array","property":"pay","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":370,"y":340,"wires":[["a7921212.bd2c7"]]},{"id":"a7921212.bd2c7","type":"function","z":"e7268cec.10fc4","name":"Best slots","func":"const cycle = msg.slots;\n\nmsg.outcome = msg.pay.sort((a,b) => a.value - b.value);\n\nfor (let c = 0; c < cycle ; c++) {\n node.send({\"topic\" : \"Lowest-\"+c, \"payload\" : msg.outcome[c].start});\n}\n","outputs":1,"noerr":0,"x":520,"y":340,"wires":[["aba7a46a.2d18b8","82677115.d7315"]]},{"id":"b3bce6c2.3cc1b8","type":"debug","z":"e7268cec.10fc4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":730,"y":280,"wires":[]},{"id":"6b0b826.35dcd7c","type":"debug","z":"e7268cec.10fc4","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":500,"y":160,"wires":[]},{"id":"a526f220.b0c59","type":"change","z":"e7268cec.10fc4","name":"","rules":[{"t":"set","p":"slots","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":100,"wires":[["37e15932.5cc506"]]},{"id":"37e15932.5cc506","type":"http request","z":"e7268cec.10fc4","name":"Get Agile Rates","method":"GET","ret":"obj","url":"https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-N/standard-unit-rates/","tls":"","x":200,"y":200,"wires":[["396b680e.65db08"]]},{"id":"82677115.d7315","type":"file","z":"e7268cec.10fc4","name":"","filename":"ChargerStart.csv","appendNewline":true,"createDir":true,"overwriteFile":"false","x":870,"y":420,"wires":[]},{"id":"1209ae05.ad1fc2","type":"file in","z":"e7268cec.10fc4","name":"ChargerStart.csv","filename":"ChargerStart.csv","format":"lines","chunk":false,"sendError":false,"x":330,"y":480,"wires":[["c14d8b20.190f48"]]},{"id":"c14d8b20.190f48","type":"debug","z":"e7268cec.10fc4","name":"FileInMon","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":540,"y":560,"wires":[]},{"id":"821a15eb.071898","type":"inject","z":"e7268cec.10fc4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"*/30 0-23 * * *","once":false,"onceDelay":0.1,"x":150,"y":480,"wires":[["1209ae05.ad1fc2"]]},{"id":"5d2e495a.fe4458","type":"file","z":"e7268cec.10fc4","name":"","filename":"ChargerStart.csv","appendNewline":true,"createDir":true,"overwriteFile":"delete","x":330,"y":60,"wires":[]},{"id":"a27db379.4db1d","type":"debug","z":"e7268cec.10fc4","name":"OPMon","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":710,"y":480,"wires":[]},{"id":"b53fdc8a.71ca8","type":"function","z":"e7268cec.10fc4","name":"Check Now","func":"var timeOn = flow.get(\"timeOn\")\nflow.set('timeOn',msg.payload);\n\nvar now = new Date();\nvar starTime = flow.get(\"startTime\", now);\nmsg.topic = (flow.get(\"startTime\") - 'timeOn');\nnode.warn(\"timeOn is \" + timeOn)\nnode.warn(\"startTime is \" + starTime)\nreturn msg;","outputs":1,"noerr":0,"x":537,"y":480,"wires":[[]]}]