Hey Guys,
I have a flow that does a query on my energy provider and this returns an array with 120 objects in it (1/2 hour increments of pricing for electricity)
The first x (arbitrary number) of these are in the past and are differentiated by a date and time, but more easily by a value in a field of ACTUAL, whereas anything in the future is designated with FORECAST in the same field
What i would like to do is to loop through the array until i find the first object that is a FORECAST and then return the next 20 elements in the array.
Is there a way to do this with standard nodes before i sit down and try to write a function to do this ?
Here is the current flow which can be run and returns the results.
[{"id":"6028717e.571d7","type":"inject","z":"88029ce.abbab6","name":"Check Prices","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"300","topic":"","payload":"","payloadType":"date","x":230,"y":500,"wires":[["416043a5.94179c"]]},{"id":"416043a5.94179c","type":"function","z":"88029ce.abbab6","name":"set headers and change Postcode here","func":"msg.headers = {};\nmsg.headers[\"Content-Type\"] = \"application/json\";\nmsg.payload = '{ \"postcode\":\"2069\" }';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":400,"y":440,"wires":[["a2b6857.bc69078"]]},{"id":"a2b6857.bc69078","type":"http request","z":"88029ce.abbab6","name":"","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://api.amberelectric.com.au/prices/listprices","tls":"","persist":false,"proxy":"","authType":"","x":430,"y":540,"wires":[["72c15da3.67bcb4","d0ebe41a.dbc338","d0c5c476.41e9f8","9394e281.e1baa","3ebe8a6.c2cc776","fd55653d.254eb8"]]},{"id":"72c15da3.67bcb4","type":"debug","z":"88029ce.abbab6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":520,"wires":[]},{"id":"d0ebe41a.dbc338","type":"debug","z":"88029ce.abbab6","name":"Fixed Daily Charges","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.data.staticPrices.E1TOU.totalDailyPrice","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":580,"wires":[]},{"id":"d0c5c476.41e9f8","type":"debug","z":"88029ce.abbab6","name":"Peak KWH Price","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.data.staticPrices.E1TOU.networkPeakKWHPrice","targetType":"msg","statusVal":"","statusType":"auto","x":690,"y":620,"wires":[]},{"id":"3ebe8a6.c2cc776","type":"debug","z":"88029ce.abbab6","name":"Off Peak KWH Price","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.data.staticPrices.E1TOU.networkOffpeakKWHPrice","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":700,"wires":[]},{"id":"9394e281.e1baa","type":"debug","z":"88029ce.abbab6","name":"Shoulder KWH Price","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.data.staticPrices.E1TOU.networkShoulderKWHPrice","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":660,"wires":[]},{"id":"fd55653d.254eb8","type":"change","z":"88029ce.abbab6","name":"","rules":[{"t":"set","p":"ambertest","pt":"global","to":"payload.data.variablePricesAndRenewables","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":460,"wires":[[]]}]
Thanks
Craig