Pirate-Weather / pirate-weather-ha

Replacement for the default Dark Sky Home Assistant integration using Pirate Weather
https://pirateweather.net/
Apache License 2.0
369 stars 26 forks source link

Question about scan_interval #209

Closed jhemak closed 7 months ago

jhemak commented 8 months ago

Describe the issue

Regarding the comment on #88 that there's little value of a scan_interval more frequent that 15 min... is that also the case for Alerts? Or would a shorter scan_interval cause new alerts to be received in HA more quickly?

Home Assistant version

No response

Integration version

No response

Troubleshooting steps

cloneofghosts commented 8 months ago

As mentioned in the other issue all the sensors and weather are updated at the same time so a lower update interval would update everything faster.

I'm not sure how fast the alerts data is processed on the API side so I'll tag @alexander0042 and he can let you know how often alerts get intergrated. I would think it would be faster than every 15m but I can't say for sure.

alexander0042 commented 8 months ago

Great question, and should be improved in the docs.

The main reason to go faster than 15 minutes is if you want the currently to reflect the best guess at the current time, but realistically, I don't think it would make sense in the fast majority of cases. Since the currently is (linearly) interpolated from the nearest points, if the temperature was changing very quickly, you'd see more accurate currently data with a faster update interval, but that really is an edge case.

With respect to alerts, they're ingested every 15 minutes, so that's the limit there. TBH, I would rather a faster ingest, but it's surprisingly computationally expensive to do, since I have to turn all the polygons into gridded data, so gets expensive.

jhemak commented 8 months ago

Thanks guys! This is very helpful. Unfortunately, what I thought might have been an update frequency issue seems to be something else. During a recent storm, the NWS was putting out many alerts for my location -- I saw them at alerts.weather.gov, in the Weather Channel app, and in another HA integration which was getting them in what seemed almost real-time. At one point, there were 7 active alerts from NWS showing in those three places, but sensor.pirateweather_alerts showed only 1. At other times, there were lower number of active alerts from NWS, but this integration never went above 1. Could there be a bug?

jhemak commented 7 months ago

It appears that it may come down to this how the NWS API is being queried. When using GPS coordinates, as I think this API does, then it seems only zone-based alerts are included in the response. When querying, as the other integration does, with NWS Zone and County codes, then the complete set of relevant alerts is returned.

alexander0042 commented 7 months ago

Oh yea, that makes sense. Right now I'm only ingesting zone based ones, since they have GPS coordinates; however, NWS puts out a whole range of things using a number of different geocoding approaches. I didn't think there would be much my the way of differences, but let me know if this happens more frequently and I can look into ingesting them somehow

jhemak commented 7 months ago

Yes, it seems this is a frequent occurrence. For this to be a useful feature of the API/integration, it would probably be necessary to make this change. In the meantime, I am going to use the other integration to get the NWS alerts since it has all the alerts and refreshes every minute. Thanks for all your work on PW!

cloneofghosts commented 7 months ago

Thanks for opening this issue. There is an existing issue about improving the alerts in the API repository here https://github.com/Pirate-Weather/pirateweather/issues/118. There is also #211 to improve the API documentation so I'll close this issue.