pirateweather icon indicating copy to clipboard operation
pirateweather copied to clipboard

Precipitation Today

Open jazzyisj opened this issue 1 year ago • 9 comments

Precipitation accumulation is available as forecast sensors for hourly/daily, but there is no real time entity provided for precipitation today. Because the forecast sensors do not have a state_class, they cannot be used for statistics.

Possible to add an entity for precipitation today with the appropriate state_class so it can be utilized by statistics?

Also, there IS an entity for precipitation intensity, but it has not been assigned a state_class.

jazzyisj avatar Sep 08 '23 14:09 jazzyisj

This should be pretty quick! Clarification question though- when you're asking about "precipitation today", do you mean the total precipitation that fell today? Or the remaining precipitation for today? Or something else?

alexander0042 avatar Nov 14 '23 18:11 alexander0042

I am referring to the precipitation that has actually accumulated for the current day. I think precipitation in last 24 hours would probably be even more useful, but I believe precipitation accumulation is only given for the current day by most weather providers? I know my Weatherflow station resets the precipitation at midnight and Environment Canada only provides the total precipitation for the previous day. Looks like accuweather does provide last 24 hours though (as well as last hour, last 3 hours etc). I'm not sure where the data for pirateweather is coming from.

https://developer.accuweather.com/accuweather-current-conditions-api/apis/get/currentconditions/v1/%7BlocationKey%7D

Either way I think it would be a welcome addition to PirateWeather. Thanks for looking into it!

jazzyisj avatar Nov 15 '23 00:11 jazzyisj

+1 for this

jhemak avatar May 01 '24 21:05 jhemak

Been thinking a bit about this, and what each provider does is kind of all over the place. Apple Weather seems to only show the remaining precipitation, while you're rights, others show the total for the day. Unfortunately, this is where some of the "art" of putting together a weather API comes in, since there's no correct answer.

I try to think of someone opening a weather app on a phone and seeing 12 mm of precipitation on the current day when they check the weather at 8 am, after a rainy night but then being surprised because it doesn't rain during the day; so that's how I came to the current setup.

Luckily, since this started out as a Home Assistant question, there's an easy enough fix on that front. If you create a sensor in HA following this comment, it'll always show the measured + foretasted accumulation for the current day as the "day 1" (not day 0) data point, with the sum of the first 24 hourly forecasts being the trailing 24 hour precipitation. Every since the v2.0 update this has been based on observed conditions, so should be an accurate way to go about this!

alexander0042 avatar Sep 23 '24 15:09 alexander0042

Hey @alexander0042, thanks a ton for this info! I've read and re-read and must be missing something. How come you are having us look at day 1 not day 0 for the measured + forecasted accumulation for the current day? I thought current day = day 0?

@cloneofghosts, would there be a way to get this sensor in HA without an additional/separate call to the API?

jhemak avatar Sep 23 '24 23:09 jhemak

Great question! If you make a request for time=-86400, then it's asking the API for the weather 24 hours ago. So if you make the request on Tuesday at 7:00 using time=-86400, then the API returns the forecast starting from Monday at 7:00. This means that day 0 is Monday, so day 1 would be precipitation for the current day (Tuesday).

Adding a sensor that way is an extra call, which isn't ideal. For what it's worth, if you're only looking for one location and making a request every 15 minutes, then you'd still be well within the free tier limit, even with the two calls! The other option would be to use a template instead of the integration and make every request -86400, which would shorten the forecast by one day, but still work

alexander0042 avatar Sep 24 '24 13:09 alexander0042

If I were to query the API using time=-86400 right now for the current day would I see the forecasted precipitation from yesterdays NBM 2PM model run or would it be a combination of today's HRRR 0h data and yesterdays NBM 2PM model run?

cloneofghosts avatar Sep 24 '24 18:09 cloneofghosts

This was the big change in V2.0, and it was a pain and a ! You'd see merged NBM 1-hour forecasts until the current forecast time (Todays's 2 pm run), and then that from there on out. So to clarify:

Request time: 5 pm Tuesday, requesting -86400

  • Hour 0 (5 pm Monday): 1-hour forecast from the 4 pm NBM run
  • Hour 1 (6 pm Monday): 1-hour forecast from the 5 pm NBM run
  • Hour 2 (7 pm Monday): 1-hour forecast from the 6 pm NBM run ...
  • Hour 20 (2 pm Monday): 1-hour forecast from the 1 pm NBM run
  • Hour 21 (3 pm Monday): 1-hour forecast from the 2 pm NBM run
  • Hour 22 (4 pm Monday): 2-hour forecast from the 2 pm NBM run
  • Hour 23 (5 pm Monday): 3-hour forecast from the 2 pm NBM run

And so on and so forth. This provides a really nice blend of latest results with the most accurate data, while also keeping the file sizes small on the back end. Essentially, the ingest script queries 36 hours worth of 1-hour forecasts from the archive and merges then together in the operational file, producing a single time series

alexander0042 avatar Sep 24 '24 20:09 alexander0042

Ah ok that makes sense. So the solution here would be to use a template sensor to get the data for the current day?

cloneofghosts avatar Sep 24 '24 20:09 cloneofghosts

@alexander0042 Just looking through this again and I think there's been some confusion as to what @jazzyisj is looking for. They were looking for a data point which shows the total precipitation accumulation so far for the current day.

So if you queried the API at 7am the field would show the total amount of precipitation which accumulated between 12am and 7am.

The other option was to have a field which showed the total amount of precipitation which accumulated in the last 24h. Again if I were to query the API at 7am it would show the total accumulation between 7am yesterday and 7am today.

cloneofghosts avatar Oct 02 '24 20:10 cloneofghosts

@cloneofghosts - Yes, precisely what I was hoping for! Right now I'm grabbing precipitation accumulation data from my weather station, but it doesn't measure snow which I'm hoping Pirate Weather will be able to someday. (I'm super excited to see how the rain/snow/ice forecasts pan out btw!)

I am using a non_negative_sum statistics helper to convert accumulation today to accumulation in the last 24 hours (the weather station resets at midnight) and another one to break out accumulation in just the last hour.

If you're curious, this is how I use all these sensors in my weather ui.

The single Precip Accum graph breaks the day into 24 segments and uses the accum last hour sensor to visualize when and how much rain each hour in the last 24 hours. (DItto with the Precip Time graph beside it, how long it rained each hour.)

image

Precipitation detail and weekly graph. Daily precipitation is tracked in the graph. image

And some statistics stuff. image image

jazzyisj avatar Oct 03 '24 00:10 jazzyisj