Parse "GET" JSON data into a variable?


#1

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.


#2

I think it would be something like $response.results[0].value_inc_vat assuming the first result is the most recent.

Someone with more knowledge may correct me, but the above might get you started.


#3

Unfortunately the first isn’t the most recent.

However you can do this apparently with the URL

/standard-unit-rates/?period_from=' + d + 'T00:00:00'

I’m not sure how to do it, but I assume I could add that and then create the correct formatting in Webcore to request the current time maybe


#4

This thread talks about it on Home Assitant - but it’s got some decent information.

Unfortunately I can’t figure out how to apply any of it.

It looks like there might be a current_price option??


#5

It might be worth including your piston, so people can have a play with it. I cant see the link with more info?

I’ve only just got into calling a url from webcore, but think there are some interesting possibilities. I’m curious about your plans to use this info, I could see scheduling to run a washer etc or charge your car, but not sure how you could do it unless it was a smart device.


#6

I agree on posting a piston to start with, remove any private api tokens etc.


#7

I mean I don’t really have a piston that means anything yet - i’m just making a GET request to the base URL which returns everything. I don’t know how to filter those results. If I can get that working I can look at getting results put into a variable and applied to a switch easily enough but i’m stuck at the parsing stage.


#8

It may be worth looking at the api to see if you can more directly get the information you need. I’ve had a quick play, and it doesn’t seem to work as documented. I tried the following to narrow the results, but it seemed to return the full day. (count should be 48, so not sure why its returning 56589)
https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-D/standard-unit-rates/?period_from(“2020-03-24T15:00”)?period_to(“2020-03-24T18:05”)

If this worked as documented you should be able to format a request for the current hour and then return just one value.


#9

Yes that’s what i found too - I either got “enter a valid date” as an error message or it returned the full day…

Someone on the other thread posted this

curl \"https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-F/standard-unit-rates/?period_from={{ now().year }}-{{ now().month }}-{{ now().day }}T{{ now().hour }}:{% if now().minute <30 %}00{% else %}30{% endif %}&period_to={{ now().year }}-{{ now().month }}-{% if (now().hour == 23) and (now().minute >=30) %}{{ now().day+1 }}{% else %}{{ now().day }}{% endif %}T{% if (now().hour == 23) and (now().minute >=30) %}00{% elif now().minute >=30 %}{{ now().hour+1}}{% else %}{{ now().hour}}{% endif %}:{% if now().minute >=30 %}00{% else %}30{% endif %}\"

But I cannot get it to run, I just get a syntax error.


#10

I’m not sure what shell this needs running from, the now() function would need to be available/imported (didn’t work on my raspberry pi)

I don;t know if it would return the correct result as it seems to be doing what we’ve tried already. It may be worth contacting octopus to see if there’s a problem with the api. The count return value seems wrong, it should be 48


#11

Good point - i’ve sent Octopus a message to see what the deal is, not sure if it’ll get through the tech team at the minute though.


#13

Paul, i’ve found the right formatting for the API at least.

Use GET on the following and it returns one result. I guess we now need to parse “value_inc_vat” into a variable

https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-D/standard-unit-rates/?period_from=2020-03-24T15:00:00Z&period_to=2020-03-24T15:30:00Z


#14

Is this what you’re looking for?

You’ll need to change the URL to add the correctly formatted current date


#15

Yes, but next we still need to parse the result to get just the value_inc_vat back - I don’t know how to parse the JSON data into variables with WebCore


#16

In terms of usage by the way - i’m all electric where I live, no gas. So space heating, hot water all are all done on electric, plus an electric car. The idea is to turn these expensive things on when the price drops below a certain amount and off when it goes too high.

If I have every price mounted I can even do this so for instance the car won’t charge if it’s more than 5p a kwh except for if it’s below 30% charge at X amount of time. To make sure you’re never left short but you’re only paying more when you really need it. Same with hot water etc


#17

I’ve updated to put the result into a variable

If you click test, you will see the variable updated to the correct value


#18

Perfect, i’ve built it up a bit more, but i’m stuck at a junction again.

I think the best way to do is run it every hour, on the hour and every hour at 30 mins past the hour.

That way when it checks with the variables the from time will be the current time that matches the result so you only get one answer back (15:00, 15:30 etc)

But I need to create two URLS and I need to create a variable that takes the current minute and adds 30 minutes to it for the period_to part. I’m sure that’s really easy with an expression but i’m not sure how to do it.

I’ll also need to do the same with the hour and add an hour so that on the one that runs at 30 mins past the hour the period_to will give the current hour +1, so that when it checks at 15:30 the minute will be 00 (current time plus 30) and the hour will be 16 (current hour plus 1)


#19

I think this is what you need. Note lines 19 to 23 should be deleted. I just left them there as they will run when you click “test” so useful if you need to do any tweaking

You may need to check/consider/change handling of dates/times around midnight

Just reposted the piston as I noticed I was using 30 secs rather than 30 mins past the hour!


#20

Small interjection here…

I would not trigger this at “0” minutes past any hour. My logic being that pistons often fire a couple of seconds early. IE: If the trigger is at 4PM, it might actually fire at 3:59:58pm, so the hour would record incorrectly.


If you do not want to use a different minute for the trigger, an alternative to this would be to add a 5 second WAIT at the top of the piston, and THEN process the rest of the code. This will ensure that you are fully into the new hour before calculating variables, or sending web requests.


#21

I thought of that, so set the times to be 1 min & 31 past the hour.

I’d also use a global variable to hold the current cost, so other pistons could access this. This piston would just run at the specified times to fetch the current value.