pynws
pynws copied to clipboard
Add ability to extract time data from forecast and forecast hourly
Thinking ahead to home-assistant features, we should think about exposing the time properties for forecasts.
In the station I use, these are the relevant properties we can consider:
{
"generatedAt": "2024-07-12T01:54:55+00:00",
"updateTime": "2024-07-11T22:56:35+00:00",
"validTimes": "2024-07-11T16:00:00+00:00/P7DT12H",
}
I suppose updateTime
is the relevant one, since that is when the data was updated. But, I'm happy to implement the below logic for the other ones as well.
The way I see it working is making two new properties in SimpleNWS
: _forecast_updated_time
and _forecast_hourly_updated_time
, which will get populated with the above updateTime
within get_gridpoints_forecast()
and get_gridpoints_forecast_hourly()
. Then, we can add public accessors for the properties. This shouldn't break existing behavior. Let me know if this makes sense.
I'm happy to make a PR.