I recently worked on creating a piston based on the Octopus Agile Electricity API here - Parse "GET" JSON data into a variable?
Linked that and key terms above just in case anyone is research and can come across these threads.
In that original question I managed to achieve what I wanted at the time, which was to parse the data from the Octopus API and put it into a global variable which gave the current price of electricity.
On the back of that I was going to build pistons to turn things on/off at different thresholds.
The problem with this is that the prices vary quite a lot - one day you might not get any 30 minute slots under 4.5p, other days you might get minus prices that you really want to take advantage of.
When you have something like your hot water tank relying on it you want it to run for 6 hours a day, but you want it to run at the cheapest 6 hours of the day. Those hours don’t need to be consecutive it can turn on/off any anytime.
We spoke a little in the thread at how to do this but it would seem to be a good idea to get the new data for the next 24 hours and process it. The only guarantee is that 4pm to 7pm is the most expensive (very expensive) so it would be worth working out the average for the 24 hour period excluding these hours and perhaps turning it into percentages to get the average.
That way you could create a variable which is a percentage rather than a set price - and when the price is below certain percentages for that day you know you’d always be using the cheapest 20% of electricity available (be that 6p per kWh or -2p per kWh)
However i’m not sure if it’s possible to process that in webcore alone. The API when requesting the rates for the next 24 hours returns this
{
"count": 57067,
"next": "https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-D/standard-unit-rates/?page=2",
"previous": null,
"results": [
{
"value_exc_vat": 6.42,
"value_inc_vat": 6.741,
"valid_from": "2020-04-03T21:30:00Z",
"valid_to": "2020-04-03T22:00:00Z"
},
{
"value_exc_vat": 7.48,
"value_inc_vat": 7.854,
"valid_from": "2020-04-03T21:00:00Z",
"valid_to": "2020-04-03T21:30:00Z"
},
{
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-04-03T20:30:00Z",
"valid_to": "2020-04-03T21:00:00Z"
},
{
"value_exc_vat": 7.04,
"value_inc_vat": 7.392,
"valid_from": "2020-04-03T20:00:00Z",
"valid_to": "2020-04-03T20:30:00Z"
},
{
"value_exc_vat": 8.16,
"value_inc_vat": 8.568,
"valid_from": "2020-04-03T19:30:00Z",
"valid_to": "2020-04-03T20:00:00Z"
},
{
"value_exc_vat": 9.68,
"value_inc_vat": 10.164,
"valid_from": "2020-04-03T19:00:00Z",
"valid_to": "2020-04-03T19:30:00Z"
},
{
"value_exc_vat": 9.68,
"value_inc_vat": 10.164,
"valid_from": "2020-04-03T18:30:00Z",
"valid_to": "2020-04-03T19:00:00Z"
},
{
"value_exc_vat": 9.33,
"value_inc_vat": 9.7965,
"valid_from": "2020-04-03T18:00:00Z",
"valid_to": "2020-04-03T18:30:00Z"
},
{
"value_exc_vat": 22.86,
"value_inc_vat": 24.003,
"valid_from": "2020-04-03T17:30:00Z",
"valid_to": "2020-04-03T18:00:00Z"
},
{
"value_exc_vat": 21.8,
"value_inc_vat": 22.89,
"valid_from": "2020-04-03T17:00:00Z",
"valid_to": "2020-04-03T17:30:00Z"
},
{
"value_exc_vat": 22.0,
"value_inc_vat": 23.1,
"valid_from": "2020-04-03T16:30:00Z",
"valid_to": "2020-04-03T17:00:00Z"
},
{
"value_exc_vat": 20.04,
"value_inc_vat": 21.042,
"valid_from": "2020-04-03T16:00:00Z",
"valid_to": "2020-04-03T16:30:00Z"
},
{
"value_exc_vat": 18.96,
"value_inc_vat": 19.908,
"valid_from": "2020-04-03T15:30:00Z",
"valid_to": "2020-04-03T16:00:00Z"
},
{
"value_exc_vat": 16.92,
"value_inc_vat": 17.766,
"valid_from": "2020-04-03T15:00:00Z",
"valid_to": "2020-04-03T15:30:00Z"
},
{
"value_exc_vat": 4.4,
"value_inc_vat": 4.62,
"valid_from": "2020-04-03T14:30:00Z",
"valid_to": "2020-04-03T15:00:00Z"
},
{
"value_exc_vat": 3.96,
"value_inc_vat": 4.158,
"valid_from": "2020-04-03T14:00:00Z",
"valid_to": "2020-04-03T14:30:00Z"
},
{
"value_exc_vat": 4.4,
"value_inc_vat": 4.62,
"valid_from": "2020-04-03T13:30:00Z",
"valid_to": "2020-04-03T14:00:00Z"
},
{
"value_exc_vat": 5.61,
"value_inc_vat": 5.8905,
"valid_from": "2020-04-03T13:00:00Z",
"valid_to": "2020-04-03T13:30:00Z"
},
{
"value_exc_vat": 5.94,
"value_inc_vat": 6.237,
"valid_from": "2020-04-03T12:30:00Z",
"valid_to": "2020-04-03T13:00:00Z"
},
{
"value_exc_vat": 7.04,
"value_inc_vat": 7.392,
"valid_from": "2020-04-03T12:00:00Z",
"valid_to": "2020-04-03T12:30:00Z"
},
{
"value_exc_vat": 7.04,
"value_inc_vat": 7.392,
"valid_from": "2020-04-03T11:30:00Z",
"valid_to": "2020-04-03T12:00:00Z"
},
{
"value_exc_vat": 7.04,
"value_inc_vat": 7.392,
"valid_from": "2020-04-03T11:00:00Z",
"valid_to": "2020-04-03T11:30:00Z"
},
{
"value_exc_vat": 6.16,
"value_inc_vat": 6.468,
"valid_from": "2020-04-03T10:30:00Z",
"valid_to": "2020-04-03T11:00:00Z"
},
{
"value_exc_vat": 6.18,
"value_inc_vat": 6.489,
"valid_from": "2020-04-03T10:00:00Z",
"valid_to": "2020-04-03T10:30:00Z"
},
{
"value_exc_vat": 5.1,
"value_inc_vat": 5.355,
"valid_from": "2020-04-03T09:30:00Z",
"valid_to": "2020-04-03T10:00:00Z"
},
{
"value_exc_vat": 6.18,
"value_inc_vat": 6.489,
"valid_from": "2020-04-03T09:00:00Z",
"valid_to": "2020-04-03T09:30:00Z"
},
{
"value_exc_vat": 6.16,
"value_inc_vat": 6.468,
"valid_from": "2020-04-03T08:30:00Z",
"valid_to": "2020-04-03T09:00:00Z"
},
{
"value_exc_vat": 6.95,
"value_inc_vat": 7.2975,
"valid_from": "2020-04-03T08:00:00Z",
"valid_to": "2020-04-03T08:30:00Z"
},
{
"value_exc_vat": 6.18,
"value_inc_vat": 6.489,
"valid_from": "2020-04-03T07:30:00Z",
"valid_to": "2020-04-03T08:00:00Z"
},
{
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-04-03T07:00:00Z",
"valid_to": "2020-04-03T07:30:00Z"
},
{
"value_exc_vat": 6.05,
"value_inc_vat": 6.3525,
"valid_from": "2020-04-03T06:30:00Z",
"valid_to": "2020-04-03T07:00:00Z"
},
{
"value_exc_vat": 4.84,
"value_inc_vat": 5.082,
"valid_from": "2020-04-03T06:00:00Z",
"valid_to": "2020-04-03T06:30:00Z"
},
{
"value_exc_vat": 6.49,
"value_inc_vat": 6.8145,
"valid_from": "2020-04-03T05:30:00Z",
"valid_to": "2020-04-03T06:00:00Z"
},
{
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-04-03T05:00:00Z",
"valid_to": "2020-04-03T05:30:00Z"
},
{
"value_exc_vat": 7.04,
"value_inc_vat": 7.392,
"valid_from": "2020-04-03T04:30:00Z",
"valid_to": "2020-04-03T05:00:00Z"
},
{
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-04-03T04:00:00Z",
"valid_to": "2020-04-03T04:30:00Z"
},
{
"value_exc_vat": 6.01,
"value_inc_vat": 6.3105,
"valid_from": "2020-04-03T03:30:00Z",
"valid_to": "2020-04-03T04:00:00Z"
},
{
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-04-03T03:00:00Z",
"valid_to": "2020-04-03T03:30:00Z"
},
{
"value_exc_vat": 6.58,
"value_inc_vat": 6.909,
"valid_from": "2020-04-03T02:30:00Z",
"valid_to": "2020-04-03T03:00:00Z"
},
{
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-04-03T02:00:00Z",
"valid_to": "2020-04-03T02:30:00Z"
},
{
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-04-03T01:30:00Z",
"valid_to": "2020-04-03T02:00:00Z"
},
{
"value_exc_vat": 6.78,
"value_inc_vat": 7.119,
"valid_from": "2020-04-03T01:00:00Z",
"valid_to": "2020-04-03T01:30:00Z"
},
{
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-04-03T00:30:00Z",
"valid_to": "2020-04-03T01:00:00Z"
},
{
"value_exc_vat": 6.4,
"value_inc_vat": 6.72,
"valid_from": "2020-04-03T00:00:00Z",
"valid_to": "2020-04-03T00:30:00Z"
},
{
"value_exc_vat": 6.16,
"value_inc_vat": 6.468,
"valid_from": "2020-04-02T23:30:00Z",
"valid_to": "2020-04-03T00:00:00Z"
},
{
"value_exc_vat": 6.18,
"value_inc_vat": 6.489,
"valid_from": "2020-04-02T23:00:00Z",
"valid_to": "2020-04-02T23:30:00Z"
},
{
"value_exc_vat": 6.31,
"value_inc_vat": 6.6255,
"valid_from": "2020-04-02T22:30:00Z",
"valid_to": "2020-04-02T23:00:00Z"
},
{
"value_exc_vat": 7.66,
"value_inc_vat": 8.043,
"valid_from": "2020-04-02T22:00:00Z",
"valid_to": "2020-04-02T22:30:00Z"
},
{
"value_exc_vat": 6.16,
"value_inc_vat": 6.468,
"valid_from": "2020-04-02T21:30:00Z",
"valid_to": "2020-04-02T22:00:00Z"
},
{
"value_exc_vat": 7.26,
"value_inc_vat": 7.623,
"valid_from": "2020-04-02T21:00:00Z",
"valid_to": "2020-04-02T21:30:00Z"
},
{
"value_exc_vat": 6.84,
"value_inc_vat": 7.182,
"valid_from": "2020-04-02T20:30:00Z",
"valid_to": "2020-04-02T21:00:00Z"
},
{
"value_exc_vat": 8.38,
"value_inc_vat": 8.799,
"valid_from": "2020-04-02T20:00:00Z",
"valid_to": "2020-04-02T20:30:00Z"
},
{
"value_exc_vat": 7.7,
"value_inc_vat": 8.085,
"valid_from": "2020-04-02T19:30:00Z",
"valid_to": "2020-04-02T20:00:00Z"
},
{
"value_exc_vat": 8.8,
"value_inc_vat": 9.24,
"valid_from": "2020-04-02T19:00:00Z",
"valid_to": "2020-04-02T19:30:00Z"
},
{
"value_exc_vat": 8.27,
"value_inc_vat": 8.6835,
"valid_from": "2020-04-02T18:30:00Z",
"valid_to": "2020-04-02T19:00:00Z"
},
{
"value_exc_vat": 7.92,
"value_inc_vat": 8.316,
"valid_from": "2020-04-02T18:00:00Z",
"valid_to": "2020-04-02T18:30:00Z"
},
{
"value_exc_vat": 20.48,
"value_inc_vat": 21.504,
"valid_from": "2020-04-02T17:30:00Z",
"valid_to": "2020-04-02T18:00:00Z"
},
{
"value_exc_vat": 20.26,
"value_inc_vat": 21.273,
"valid_from": "2020-04-02T17:00:00Z",
"valid_to": "2020-04-02T17:30:00Z"
},
{
"value_exc_vat": 20.06,
"value_inc_vat": 21.063,
"valid_from": "2020-04-02T16:30:00Z",
"valid_to": "2020-04-02T17:00:00Z"
},
{
"value_exc_vat": 19.6,
"value_inc_vat": 20.58,
"valid_from": "2020-04-02T16:00:00Z",
"valid_to": "2020-04-02T16:30:00Z"
},
{
"value_exc_vat": 18.5,
"value_inc_vat": 19.425,
"valid_from": "2020-04-02T15:30:00Z",
"valid_to": "2020-04-02T16:00:00Z"
},
{
"value_exc_vat": 17.51,
"value_inc_vat": 18.3855,
"valid_from": "2020-04-02T15:00:00Z",
"valid_to": "2020-04-02T15:30:00Z"
},
{
"value_exc_vat": 3.08,
"value_inc_vat": 3.234,
"valid_from": "2020-04-02T14:30:00Z",
"valid_to": "2020-04-02T15:00:00Z"
},
{
"value_exc_vat": 2.42,
"value_inc_vat": 2.541,
"valid_from": "2020-04-02T14:00:00Z",
"valid_to": "2020-04-02T14:30:00Z"
},
{
"value_exc_vat": 3.08,
"value_inc_vat": 3.234,
"valid_from": "2020-04-02T13:30:00Z",
"valid_to": "2020-04-02T14:00:00Z"
},
{
"value_exc_vat": 3.17,
"value_inc_vat": 3.3285,
"valid_from": "2020-04-02T13:00:00Z",
"valid_to": "2020-04-02T13:30:00Z"
},
{
"value_exc_vat": 3.96,
"value_inc_vat": 4.158,
"valid_from": "2020-04-02T12:30:00Z",
"valid_to": "2020-04-02T13:00:00Z"
},
{
"value_exc_vat": 5.15,
"value_inc_vat": 5.4075,
"valid_from": "2020-04-02T12:00:00Z",
"valid_to": "2020-04-02T12:30:00Z"
},
{
"value_exc_vat": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-04-02T11:30:00Z",
"valid_to": "2020-04-02T12:00:00Z"
},
{
"value_exc_vat": 6.01,
"value_inc_vat": 6.3105,
"valid_from": "2020-04-02T11:00:00Z",
"valid_to": "2020-04-02T11:30:00Z"
},
{
"value_exc_vat": 5.17,
"value_inc_vat": 5.4285,
"valid_from": "2020-04-02T10:30:00Z",
"valid_to": "2020-04-02T11:00:00Z"
},
{
"value_exc_vat": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-04-02T10:00:00Z",
"valid_to": "2020-04-02T10:30:00Z"
},
{
"value_exc_vat": 5.17,
"value_inc_vat": 5.4285,
"valid_from": "2020-04-02T09:30:00Z",
"valid_to": "2020-04-02T10:00:00Z"
},
{
"value_exc_vat": 5.94,
"value_inc_vat": 6.237,
"valid_from": "2020-04-02T09:00:00Z",
"valid_to": "2020-04-02T09:30:00Z"
},
{
"value_exc_vat": 6.27,
"value_inc_vat": 6.5835,
"valid_from": "2020-04-02T08:30:00Z",
"valid_to": "2020-04-02T09:00:00Z"
},
{
"value_exc_vat": 7.04,
"value_inc_vat": 7.392,
"valid_from": "2020-04-02T08:00:00Z",
"valid_to": "2020-04-02T08:30:00Z"
},
{
"value_exc_vat": 7.0,
"value_inc_vat": 7.35,
"valid_from": "2020-04-02T07:30:00Z",
"valid_to": "2020-04-02T08:00:00Z"
},
{
"value_exc_vat": 7.7,
"value_inc_vat": 8.085,
"valid_from": "2020-04-02T07:00:00Z",
"valid_to": "2020-04-02T07:30:00Z"
},
{
"value_exc_vat": 7.04,
"value_inc_vat": 7.392,
"valid_from": "2020-04-02T06:30:00Z",
"valid_to": "2020-04-02T07:00:00Z"
},
{
"value_exc_vat": 5.06,
"value_inc_vat": 5.313,
"valid_from": "2020-04-02T06:00:00Z",
"valid_to": "2020-04-02T06:30:00Z"
},
{
"value_exc_vat": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-04-02T05:30:00Z",
"valid_to": "2020-04-02T06:00:00Z"
},
{
"value_exc_vat": 4.62,
"value_inc_vat": 4.851,
"valid_from": "2020-04-02T05:00:00Z",
"valid_to": "2020-04-02T05:30:00Z"
},
{
"value_exc_vat": 5.06,
"value_inc_vat": 5.313,
"valid_from": "2020-04-02T04:30:00Z",
"valid_to": "2020-04-02T05:00:00Z"
},
{
"value_exc_vat": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-04-02T04:00:00Z",
"valid_to": "2020-04-02T04:30:00Z"
},
{
"value_exc_vat": 4.95,
"value_inc_vat": 5.1975,
"valid_from": "2020-04-02T03:30:00Z",
"valid_to": "2020-04-02T04:00:00Z"
},
{
"value_exc_vat": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-04-02T03:00:00Z",
"valid_to": "2020-04-02T03:30:00Z"
},
{
"value_exc_vat": 4.07,
"value_inc_vat": 4.2735,
"valid_from": "2020-04-02T02:30:00Z",
"valid_to": "2020-04-02T03:00:00Z"
},
{
"value_exc_vat": 4.6,
"value_inc_vat": 4.83,
"valid_from": "2020-04-02T02:00:00Z",
"valid_to": "2020-04-02T02:30:00Z"
},
{
"value_exc_vat": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-04-02T01:30:00Z",
"valid_to": "2020-04-02T02:00:00Z"
},
{
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-04-02T01:00:00Z",
"valid_to": "2020-04-02T01:30:00Z"
},
{
"value_exc_vat": 5.57,
"value_inc_vat": 5.8485,
"valid_from": "2020-04-02T00:30:00Z",
"valid_to": "2020-04-02T01:00:00Z"
},
{
"value_exc_vat": 4.64,
"value_inc_vat": 4.872,
"valid_from": "2020-04-02T00:00:00Z",
"valid_to": "2020-04-02T00:30:00Z"
},
{
"value_exc_vat": 4.62,
"value_inc_vat": 4.851,
"valid_from": "2020-04-01T23:30:00Z",
"valid_to": "2020-04-02T00:00:00Z"
},
{
"value_exc_vat": 4.95,
"value_inc_vat": 5.1975,
"valid_from": "2020-04-01T23:00:00Z",
"valid_to": "2020-04-01T23:30:00Z"
},
{
"value_exc_vat": 5.72,
"value_inc_vat": 6.006,
"valid_from": "2020-04-01T22:30:00Z",
"valid_to": "2020-04-01T23:00:00Z"
},
{
"value_exc_vat": 7.48,
"value_inc_vat": 7.854,
"valid_from": "2020-04-01T22:00:00Z",
"valid_to": "2020-04-01T22:30:00Z"
},
{
"value_exc_vat": 6.16,
"value_inc_vat": 6.468,
"valid_from": "2020-04-01T21:30:00Z",
"valid_to": "2020-04-01T22:00:00Z"
},
{
"value_exc_vat": 7.48,
"value_inc_vat": 7.854,
"valid_from": "2020-04-01T21:00:00Z",
"valid_to": "2020-04-01T21:30:00Z"
},
{
"value_exc_vat": 6.16,
"value_inc_vat": 6.468,
"valid_from": "2020-04-01T20:30:00Z",
"valid_to": "2020-04-01T21:00:00Z"
},
{
"value_exc_vat": 7.26,
"value_inc_vat": 7.623,
"valid_from": "2020-04-01T20:00:00Z",
"valid_to": "2020-04-01T20:30:00Z"
}
]
}
Does anyone know if something like the above would be possible at all, or is it worth using something externally (like a Python script or something maybe?) to process the data, or any other better ways to make us of it