It is quite frustrating how TWC handles weather forecast day by day…
For example:
- at ~3am, all the data for that night is lost…
- at ~3pm, some the data for that day is lost…
This means currently, from about 3a-7a, TWC is unable to tell us the low temperature.
(for the night still in progress)
Likewise, from 3p-11p, TWC cannot tell you the high for the current day any longer…
This is crazy to me…
To combat this, I have created a piston that is smart enough to update once per hour, whenever TWC actually has data. Yet the real beauty is that it retains any data that is still current. (and even one day in the past)
This means, with this piston running once per hour… I can make a simple query to find the Min or Max temp for today, yesterday, or tomorrow… with the confidence that the data returned from this piston will ALWAYS be for the right time-slot.
Here is the piston to update (& preserve) min/max forecasted temps…
(although this concept can be used for other forecasts as well)
I added some comments in green, and some in blue for quick reference.
Note: I capture the data into local variables
(for piston state & logging), and then afterwards, I copy them into @globals
(so other pistons can reference those dataPoints).
You can test this piston by simply importing it, but if you want the most flexibility, then 6 @globals will need to be created.
- integer
@twcHiNex
t (not set) - integer
@twcHiNow
(not set) - integer
@twcHiPrev
(not set) - integer
@twcLowNext
(not set) - integer
@twcLowNow
(not set) - integer
@twcLowPrev
(not set)
It will take a bit to populate the data (since TWC does not make previous data available) but then these @global variables
can be referenced by other pistons, to make sure we are always getting the data that we want.