Hi,
I’m looking to use the UK Octopus Agile electricity tariff which gives a different wholesale price for electricity every half an hour throughout the day.
There is an API and I can pull in the details (API details but it’s a large amount of JSON data return.
What I wanted to do ultimately is have a virtual dimmer switch - the piston would check the price every half an hour and update the dimmer switch with the latest value (rounding up 5.7p to 6 for instance) and setting that in the dimmer. Then I can use the dimmer to trigger turning other things on/off depending on price.
The data currently pulls in like this
{
"count": 56589,
"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": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-03-24T22:30:00Z",
"valid_to": "2020-03-24T23:00:00Z"
}, {
"value_exc_vat": 6.03,
"value_inc_vat": 6.3315,
"valid_from": "2020-03-24T22:00:00Z",
"valid_to": "2020-03-24T22:30:00Z"
}, {
"value_exc_vat": 5.32,
"value_inc_vat": 5.586,
"valid_from": "2020-03-24T21:30:00Z",
"valid_to": "2020-03-24T22:00:00Z"
}, {
"value_exc_vat": 7.26,
"value_inc_vat": 7.623,
"valid_from": "2020-03-24T21:00:00Z",
"valid_to": "2020-03-24T21:30:00Z"
}, {
"value_exc_vat": 6.25,
"value_inc_vat": 6.5625,
"valid_from": "2020-03-24T20:30:00Z",
"valid_to": "2020-03-24T21:00:00Z"
}, {
"value_exc_vat": 7.48,
"value_inc_vat": 7.854,
"valid_from": "2020-03-24T20:00:00Z",
"valid_to": "2020-03-24T20:30:00Z"
}, {
"value_exc_vat": 8.47,
"value_inc_vat": 8.8935,
"valid_from": "2020-03-24T19:30:00Z",
"valid_to": "2020-03-24T20:00:00Z"
}, {
"value_exc_vat": 10.34,
"value_inc_vat": 10.857,
"valid_from": "2020-03-24T19:00:00Z",
"valid_to": "2020-03-24T19:30:00Z"
}, {
"value_exc_vat": 22.42,
"value_inc_vat": 23.541,
"valid_from": "2020-03-24T18:30:00Z",
"valid_to": "2020-03-24T19:00:00Z"
}, {
"value_exc_vat": 21.45,
"value_inc_vat": 22.5225,
"valid_from": "2020-03-24T18:00:00Z",
"valid_to": "2020-03-24T18:30:00Z"
}, {
"value_exc_vat": 20.48,
"value_inc_vat": 21.504,
"valid_from": "2020-03-24T17:30:00Z",
"valid_to": "2020-03-24T18:00:00Z"
}, {
"value_exc_vat": 20.18,
"value_inc_vat": 21.189,
"valid_from": "2020-03-24T17:00:00Z",
"valid_to": "2020-03-24T17:30:00Z"
}, {
"value_exc_vat": 18.92,
"value_inc_vat": 19.866,
"valid_from": "2020-03-24T16:30:00Z",
"valid_to": "2020-03-24T17:00:00Z"
}, {
"value_exc_vat": 18.83,
"value_inc_vat": 19.7715,
"valid_from": "2020-03-24T16:00:00Z",
"valid_to": "2020-03-24T16:30:00Z"
}, {
"value_exc_vat": 6.32,
"value_inc_vat": 6.636,
"valid_from": "2020-03-24T15:30:00Z",
"valid_to": "2020-03-24T16:00:00Z"
}, {
"value_exc_vat": 5.72,
"value_inc_vat": 6.006,
"valid_from": "2020-03-24T15:00:00Z",
"valid_to": "2020-03-24T15:30:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-24T14:30:00Z",
"valid_to": "2020-03-24T15:00:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-24T14:00:00Z",
"valid_to": "2020-03-24T14:30:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-24T13:30:00Z",
"valid_to": "2020-03-24T14:00:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-24T13:00:00Z",
"valid_to": "2020-03-24T13:30:00Z"
}, {
"value_exc_vat": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-03-24T12:30:00Z",
"valid_to": "2020-03-24T13:00:00Z"
}, {
"value_exc_vat": 5.72,
"value_inc_vat": 6.006,
"valid_from": "2020-03-24T12:00:00Z",
"valid_to": "2020-03-24T12:30:00Z"
}, {
"value_exc_vat": 5.63,
"value_inc_vat": 5.9115,
"valid_from": "2020-03-24T11:30:00Z",
"valid_to": "2020-03-24T12:00:00Z"
}, {
"value_exc_vat": 5.72,
"value_inc_vat": 6.006,
"valid_from": "2020-03-24T11:00:00Z",
"valid_to": "2020-03-24T11:30:00Z"
}, {
"value_exc_vat": 5.28,
"value_inc_vat": 5.544,
"valid_from": "2020-03-24T10:30:00Z",
"valid_to": "2020-03-24T11:00:00Z"
}, {
"value_exc_vat": 6.14,
"value_inc_vat": 6.447,
"valid_from": "2020-03-24T10:00:00Z",
"valid_to": "2020-03-24T10:30:00Z"
}, {
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-03-24T09:30:00Z",
"valid_to": "2020-03-24T10:00:00Z"
}, {
"value_exc_vat": 7.7,
"value_inc_vat": 8.085,
"valid_from": "2020-03-24T09:00:00Z",
"valid_to": "2020-03-24T09:30:00Z"
}, {
"value_exc_vat": 6.89,
"value_inc_vat": 7.2345,
"valid_from": "2020-03-24T08:30:00Z",
"valid_to": "2020-03-24T09:00:00Z"
}, {
"value_exc_vat": 7.48,
"value_inc_vat": 7.854,
"valid_from": "2020-03-24T08:00:00Z",
"valid_to": "2020-03-24T08:30:00Z"
}, {
"value_exc_vat": 7.48,
"value_inc_vat": 7.854,
"valid_from": "2020-03-24T07:30:00Z",
"valid_to": "2020-03-24T08:00:00Z"
}, {
"value_exc_vat": 6.82,
"value_inc_vat": 7.161,
"valid_from": "2020-03-24T07:00:00Z",
"valid_to": "2020-03-24T07:30:00Z"
}, {
"value_exc_vat": 6.16,
"value_inc_vat": 6.468,
"valid_from": "2020-03-24T06:30:00Z",
"valid_to": "2020-03-24T07:00:00Z"
}, {
"value_exc_vat": 6.51,
"value_inc_vat": 6.8355,
"valid_from": "2020-03-24T06:00:00Z",
"valid_to": "2020-03-24T06:30:00Z"
}, {
"value_exc_vat": 4.4,
"value_inc_vat": 4.62,
"valid_from": "2020-03-24T05:30:00Z",
"valid_to": "2020-03-24T06:00:00Z"
}, {
"value_exc_vat": 3.7,
"value_inc_vat": 3.885,
"valid_from": "2020-03-24T05:00:00Z",
"valid_to": "2020-03-24T05:30:00Z"
}, {
"value_exc_vat": 3.96,
"value_inc_vat": 4.158,
"valid_from": "2020-03-24T04:30:00Z",
"valid_to": "2020-03-24T05:00:00Z"
}, {
"value_exc_vat": 3.7,
"value_inc_vat": 3.885,
"valid_from": "2020-03-24T04:00:00Z",
"valid_to": "2020-03-24T04:30:00Z"
}, {
"value_exc_vat": 3.52,
"value_inc_vat": 3.696,
"valid_from": "2020-03-24T03:30:00Z",
"valid_to": "2020-03-24T04:00:00Z"
}, {
"value_exc_vat": 3.92,
"value_inc_vat": 4.116,
"valid_from": "2020-03-24T03:00:00Z",
"valid_to": "2020-03-24T03:30:00Z"
}, {
"value_exc_vat": 4.36,
"value_inc_vat": 4.578,
"valid_from": "2020-03-24T02:30:00Z",
"valid_to": "2020-03-24T03:00:00Z"
}, {
"value_exc_vat": 4.62,
"value_inc_vat": 4.851,
"valid_from": "2020-03-24T02:00:00Z",
"valid_to": "2020-03-24T02:30:00Z"
}, {
"value_exc_vat": 4.14,
"value_inc_vat": 4.347,
"valid_from": "2020-03-24T01:30:00Z",
"valid_to": "2020-03-24T02:00:00Z"
}, {
"value_exc_vat": 4.95,
"value_inc_vat": 5.1975,
"valid_from": "2020-03-24T01:00:00Z",
"valid_to": "2020-03-24T01:30:00Z"
}, {
"value_exc_vat": 5.17,
"value_inc_vat": 5.4285,
"valid_from": "2020-03-24T00:30:00Z",
"valid_to": "2020-03-24T01:00:00Z"
}, {
"value_exc_vat": 4.33,
"value_inc_vat": 4.5465,
"valid_from": "2020-03-24T00:00:00Z",
"valid_to": "2020-03-24T00:30:00Z"
}, {
"value_exc_vat": 5.17,
"value_inc_vat": 5.4285,
"valid_from": "2020-03-23T23:30:00Z",
"valid_to": "2020-03-24T00:00:00Z"
}, {
"value_exc_vat": 5.17,
"value_inc_vat": 5.4285,
"valid_from": "2020-03-23T23:00:00Z",
"valid_to": "2020-03-23T23:30:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-23T22:30:00Z",
"valid_to": "2020-03-23T23:00:00Z"
}, {
"value_exc_vat": 7.74,
"value_inc_vat": 8.127,
"valid_from": "2020-03-23T22:00:00Z",
"valid_to": "2020-03-23T22:30:00Z"
}, {
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-03-23T21:30:00Z",
"valid_to": "2020-03-23T22:00:00Z"
}, {
"value_exc_vat": 7.35,
"value_inc_vat": 7.7175,
"valid_from": "2020-03-23T21:00:00Z",
"valid_to": "2020-03-23T21:30:00Z"
}, {
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-03-23T20:30:00Z",
"valid_to": "2020-03-23T21:00:00Z"
}, {
"value_exc_vat": 7.26,
"value_inc_vat": 7.623,
"valid_from": "2020-03-23T20:00:00Z",
"valid_to": "2020-03-23T20:30:00Z"
}, {
"value_exc_vat": 8.45,
"value_inc_vat": 8.8725,
"valid_from": "2020-03-23T19:30:00Z",
"valid_to": "2020-03-23T20:00:00Z"
}, {
"value_exc_vat": 10.74,
"value_inc_vat": 11.277,
"valid_from": "2020-03-23T19:00:00Z",
"valid_to": "2020-03-23T19:30:00Z"
}, {
"value_exc_vat": 23.12,
"value_inc_vat": 24.276,
"valid_from": "2020-03-23T18:30:00Z",
"valid_to": "2020-03-23T19:00:00Z"
}, {
"value_exc_vat": 22.15,
"value_inc_vat": 23.2575,
"valid_from": "2020-03-23T18:00:00Z",
"valid_to": "2020-03-23T18:30:00Z"
}, {
"value_exc_vat": 21.32,
"value_inc_vat": 22.386,
"valid_from": "2020-03-23T17:30:00Z",
"valid_to": "2020-03-23T18:00:00Z"
}, {
"value_exc_vat": 20.17,
"value_inc_vat": 21.1785,
"valid_from": "2020-03-23T17:00:00Z",
"valid_to": "2020-03-23T17:30:00Z"
}, {
"value_exc_vat": 20.26,
"value_inc_vat": 21.273,
"valid_from": "2020-03-23T16:30:00Z",
"valid_to": "2020-03-23T17:00:00Z"
}, {
"value_exc_vat": 19.16,
"value_inc_vat": 20.118,
"valid_from": "2020-03-23T16:00:00Z",
"valid_to": "2020-03-23T16:30:00Z"
}, {
"value_exc_vat": 5.68,
"value_inc_vat": 5.964,
"valid_from": "2020-03-23T15:30:00Z",
"valid_to": "2020-03-23T16:00:00Z"
}, {
"value_exc_vat": 4.4,
"value_inc_vat": 4.62,
"valid_from": "2020-03-23T15:00:00Z",
"valid_to": "2020-03-23T15:30:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-23T14:30:00Z",
"valid_to": "2020-03-23T15:00:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-23T14:00:00Z",
"valid_to": "2020-03-23T14:30:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-23T13:30:00Z",
"valid_to": "2020-03-23T14:00:00Z"
}, {
"value_exc_vat": 6.53,
"value_inc_vat": 6.8565,
"valid_from": "2020-03-23T13:00:00Z",
"valid_to": "2020-03-23T13:30:00Z"
}, {
"value_exc_vat": 6.01,
"value_inc_vat": 6.3105,
"valid_from": "2020-03-23T12:30:00Z",
"valid_to": "2020-03-23T13:00:00Z"
}, {
"value_exc_vat": 7.04,
"value_inc_vat": 7.392,
"valid_from": "2020-03-23T12:00:00Z",
"valid_to": "2020-03-23T12:30:00Z"
}, {
"value_exc_vat": 5.94,
"value_inc_vat": 6.237,
"valid_from": "2020-03-23T11:30:00Z",
"valid_to": "2020-03-23T12:00:00Z"
}, {
"value_exc_vat": 6.05,
"value_inc_vat": 6.3525,
"valid_from": "2020-03-23T11:00:00Z",
"valid_to": "2020-03-23T11:30:00Z"
}, {
"value_exc_vat": 5.94,
"value_inc_vat": 6.237,
"valid_from": "2020-03-23T10:30:00Z",
"valid_to": "2020-03-23T11:00:00Z"
}, {
"value_exc_vat": 6.6,
"value_inc_vat": 6.93,
"valid_from": "2020-03-23T10:00:00Z",
"valid_to": "2020-03-23T10:30:00Z"
}, {
"value_exc_vat": 7.48,
"value_inc_vat": 7.854,
"valid_from": "2020-03-23T09:30:00Z",
"valid_to": "2020-03-23T10:00:00Z"
}, {
"value_exc_vat": 8.25,
"value_inc_vat": 8.6625,
"valid_from": "2020-03-23T09:00:00Z",
"valid_to": "2020-03-23T09:30:00Z"
}, {
"value_exc_vat": 8.47,
"value_inc_vat": 8.8935,
"valid_from": "2020-03-23T08:30:00Z",
"valid_to": "2020-03-23T09:00:00Z"
}, {
"value_exc_vat": 8.73,
"value_inc_vat": 9.1665,
"valid_from": "2020-03-23T08:00:00Z",
"valid_to": "2020-03-23T08:30:00Z"
}, {
"value_exc_vat": 9.68,
"value_inc_vat": 10.164,
"valid_from": "2020-03-23T07:30:00Z",
"valid_to": "2020-03-23T08:00:00Z"
}, {
"value_exc_vat": 8.76,
"value_inc_vat": 9.198,
"valid_from": "2020-03-23T07:00:00Z",
"valid_to": "2020-03-23T07:30:00Z"
}, {
"value_exc_vat": 8.91,
"value_inc_vat": 9.3555,
"valid_from": "2020-03-23T06:30:00Z",
"valid_to": "2020-03-23T07:00:00Z"
}, {
"value_exc_vat": 8.47,
"value_inc_vat": 8.8935,
"valid_from": "2020-03-23T06:00:00Z",
"valid_to": "2020-03-23T06:30:00Z"
}, {
"value_exc_vat": 5.94,
"value_inc_vat": 6.237,
"valid_from": "2020-03-23T05:30:00Z",
"valid_to": "2020-03-23T06:00:00Z"
}, {
"value_exc_vat": 5.5,
"value_inc_vat": 5.775,
"valid_from": "2020-03-23T05:00:00Z",
"valid_to": "2020-03-23T05:30:00Z"
}, {
"value_exc_vat": 6.38,
"value_inc_vat": 6.699,
"valid_from": "2020-03-23T04:30:00Z",
"valid_to": "2020-03-23T05:00:00Z"
}, {
"value_exc_vat": 6.38,
"value_inc_vat": 6.699,
"valid_from": "2020-03-23T04:00:00Z",
"valid_to": "2020-03-23T04:30:00Z"
}, {
"value_exc_vat": 6.38,
"value_inc_vat": 6.699,
"valid_from": "2020-03-23T03:30:00Z",
"valid_to": "2020-03-23T04:00:00Z"
}, {
"value_exc_vat": 7.48,
"value_inc_vat": 7.854,
"valid_from": "2020-03-23T03:00:00Z",
"valid_to": "2020-03-23T03:30:00Z"
}, {
"value_exc_vat": 6.38,
"value_inc_vat": 6.699,
"valid_from": "2020-03-23T02:30:00Z",
"valid_to": "2020-03-23T03:00:00Z"
},
Quite tricky as it lists every price and from what I can see there’s no way to just pull in the current price.
Can anyone suggest the best way to parse this information to achieve what I want do? It gets updated once every 24 hours, so you can always see ahead if that helps and makes more sense than trying to pull in the latest information every half an hour.