Pirate-Weather / pirateweather

Code and documentation for the Pirate Weather API
Apache License 2.0
668 stars 30 forks source link

Precipitation Accumulation Seems Incorrect #72

Closed cloneofghosts closed 1 year ago

cloneofghosts commented 1 year ago

I was looking at the precipitation accumulation forecast in my HA install yesterday to see what PW is forecasting for the upcoming rain on Monday and I noticed that it seems to be a lot lower than what other sites are showing. I checked the API this morning and can can confirm that it isn't a HA issue. I went and checked other sites for comparisons and here is what they show:

API Precipitation Accumulation
PirateWeather 2.0201mm
MerrySky 29mm
Open-Meteo 22.3mm
WeatherBit 25.1mm
Accuweather 30.4mm
The Weather Company ~31mm
Foreca 9.1mm
World Weather Online 39mm
AerisWeather 20mm
WeatherKit 17.5mm
Met Norway 7.7mm
The Weather Network 25-30mm

I wonder if the precipAccumulation variable is using the 1:10 liquid ratio for both rain and snow accumulation and multiplying the value in the API by 10 gives you 20.201mm which seems more in line with what other sites are showing.

Looking at the hourly forecast seems to confirm my suspicion:

        "time": 1686510000,
        "icon": "cloudy",
        "summary": "Cloudy",
        "precipIntensity": 0.0771,
        "precipProbability": 0.08,
        "precipIntensityError": 0.1764,
        "precipAccumulation": 0.0077,
alexander0042 commented 1 year ago

Good catch- I think this might be a HA integration issue actually. Precipitation accumulation is always specified in cm/ inches, so if you're calling the API directly, then the 2.02 is in cm, not mm. Intensity is always in mm/h, which is a weird difference, but that's how Dark Sky did it, so I tied to be consistent.

Are you seeing the accumulation listed in mm in the HA weather entity or a sensor entity?

cloneofghosts commented 1 year ago

Ah that would be why the accumulation seems so much lower than on the other sites and I do find it weird that the value is in cm and not mm. It might make sense to have a precipAccumulation for snow and one for the total liquid accumulation? I remember there was discussion about doing something similar for precipIntensity but I think it was never implemented.

I'm seeing accumulation listed in mm for the weather entity though I haven't tried the sensor entity but there is this issue about it not working https://github.com/alexander0042/pirate-weather-ha/issues/111

If accumulation is in cm then the API docs need to be updated accordingly since they say it's in mm (that's on me since I thought it was in mm and not cm)

alexander0042 commented 1 year ago

Yea, I'm planning on adding in a liquid one, that way I'd retain compatibility with Dark Sky, but also add in that data. The way the raw API handles it is (as of now), which is, as far as I can tell, identical to how Dark Sky did:

precipAccumulation: total precipitation in cm precipIntensity: precipitation rate in mm/h

So I'll update the docs to clarify that (apologies for not catching it)! The issue here is with the HA integration, since for some reason that has the units wrong. I think they recently changed the accumulation units, so starting there!

cloneofghosts commented 1 year ago

I hadn't seen any mention of separating the accumulation into one for liquid and one for snow anywhere so I wasn't sure if it was still planned or not. Maybe creating a GitHub project on this repo might help with things?

alexander0042 commented 1 year ago

It's been on my list since this issue: https://github.com/alexander0042/pirateweather/issues/5#issuecomment-1143748585, but pretty low priority. The good news is that the HA issue is an easy fix, so that will go out this week. Also fixing the docs now, since I should have noticed that before!

cloneofghosts commented 1 year ago

I see that you updated the docs so that is fixed. Do you want to keep this open to fix the accumulation in HA or create a HA issue instead?

cloneofghosts commented 1 year ago

Going to create a HA issue since the issue is HA related and not an API issue.