Thanks, The flow I have is below I cheated with ChatGPT.
I have flows for below zero and 1-8 concurrent slots but not 'pick & mix'. I don't have an EV or battery BTW.
[
{
"id": "4edd8a32df48bde5",
"type": "http request",
"z": "fb5d1b09bd1d48f7",
"name": "Fetch Octopus Agile Rates",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://api.octopus.energy/v1/products/AGILE-FLEX-22-11-25/electricity-tariffs/E-1R-AGILE-FLEX-22-11-25-L/standard-unit-rates/",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 160,
"y": 160,
"wires": [
[
"27b594f07da3e4b0"
]
]
},
{
"id": "27b594f07da3e4b0",
"type": "function",
"z": "fb5d1b09bd1d48f7",
"name": "Extract, Filter, and Sort Rates",
"func": "let rates = msg.payload.results;\n\n// Get today's date in ISO format (YYYY-MM-DD)\nlet today = new Date().toISOString().split('T')[0];\n\n// Filter rates to include only today's data\nlet todayRates = rates.filter(item => {\n return item.valid_from.startsWith(today);\n});\n\n// Extract date, time, and rate information\nlet extractedRates = todayRates.map(item => {\n return {\n start: item.valid_from,\n end: item.valid_to,\n price: item.value_inc_vat\n };\n});\n\n// Sort by price ascending\nextractedRates.sort((a, b) => a.price - b.price);\n\n// Select the cheapest 8 slots\nlet cheapestSlots = extractedRates.slice(0, 8);\n\nmsg.payload = { cheapestSlots };\nreturn msg;",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 160,
"y": 200,
"wires": [
[
"6eb0647a1423c752",
"e5339d3b84a35d3f",
"3a221bf4d367eed1",
"7a881d4cdf467081",
"4db46119da30f8bc",
"7cbfefd0ac2f9c78",
"0f54e1e4ca44e6d0",
"4e9571b3c493f61e",
"58da76b61fb8ba05"
]
]
},
{
"id": "a7d8e3db27d611a8",
"type": "inject",
"z": "fb5d1b09bd1d48f7",
"name": "Fetch Data",
"props": [],
"repeat": "",
"crontab": "00 00 * * *",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 110,
"y": 120,
"wires": [
[
"4edd8a32df48bde5"
]
]
}
]