Local/offline/self-hosted weather forecast?

I’m curious if anyone else has found a solution for providing a simple weather forecast without the internet? There are a number of locally-accessed weather stations (WeatherFlow, Ecowiit, anything weewx, etc) that do an awesome job of tracking current conditions. But there doesn’t seem to be any option for forecasting using all that local data.

The most promising option I can find is the Zambretti method, which seems to be used by the pywws library. I’m tempted to write my own component to leverage this, but curious if anyone else has gone down this path?

Particularly with services like Dark Sky and WUnderground getting bought and eventually mothballed, it seems like there would be interest in having something self-hosted.

2 Likes

Its not really possible.
Forecasting is done on supercomputers running several simulations on models that include both data on current, past and historical dconditions.
The result are several different forecasts that experts then look at and choose the one they believe most in or just sums all or several of them up and present that as the final forecast.

Right, I’m not talking about long-term forecasts or anything like that. I really just mean the basics within a 12-24hr window, which is seems like Zambretti can kind of do, given a sensor that tracks barometric pressure over time. I will give it a crack and see how awful the results are :slight_smile: .

Barometric pressure will give you an indication on the wind, but things like rain will be alot harder.
You need to know the amount of water in the air, the temperature and topografi that the wind will push and has pushed the air over just to the name a few.

Where we’re located there can be severe enough weather that a “kind of” forecast probably isn’t anything I’d want to see as it would give a false sense of security. On the flip side where we used to live the weather was typically on the order of “tomorrow will basically be like today was”. Not sure what you’re trying to accomplish with local forecasting but I’d be curious to see how it stacks up against more traditional forecast models that know what pressure, humidity and radar looks like hundreds of miles away.

I’m just trying to figure out if it’s going to rain in the next hour or eight, really. I live in a valley in Seattle which has a fairly distinct microclimate. Despite all the super impressive models, radar, reams of data, and compute capacity available, I’ve never found a service that can accurately predict near-immediate rain. Dark Sky gets it right more than most, but only does so ~50% of the time.

I don’t blame them, because it’s so niche. That’s why I’m wondering if plugging personal data into an equation, instead of aggregating data from all over and building a model, may actually be better. The quality bar is pretty low :slight_smile: . In any case I think the algorithm I linked above is not super hard to implement, so I’ll give it a shot, and probably be disappointed!

Looking forward to hear the result.
I am living in a place where the weather is hard to predict too.
You look out the window and its raining, so you pick up your umbrella and open the door just to realize that its sunshine now. You then decide the umbrella is annoying to carry and turn around and put it inside the door. Then you turn around again and see that it is now snowing.

1 Like

I completely understand and hope you didn’t take my comment as discouraging as that wasn’t the intent. We’re in central Texas where it’s common to say that if you don’t like the weather, just wait five minutes. :slight_smile: We’re no strangers to sudden and unexpected weather changes, sometimes scary or even dangerous, aside from perhaps an algorithm that detects localized barometric pressure drops over a short time period, I’m not sure what more could be done but I fully admit that I’m not familiar with the algorithm/model you’ve referenced. I’m curious to see how it pans out and hope it’s good news as it sounds like several of us here could benefit.

This is a great topic. (Coming from the country that inspired the song "Four Seasons in One Day ")

I’ve been working on this, but still have a ways to go. I have a Tempest weather station and am working on current weather conditions based solely on info from my station.

Establishing order of checks (priority):
‘lightning-rainy’ 10 < (sensor.wf_lightning_count_3_hours < 450 (attempt to eliminate false reports from noise on detector) & sensor.wf_precipitation_type > 0

‘lightning’ 3 hour lightning count 10 < (sensor.wf_lightning_count_3_hours < 450 (attempt to eliminate false reports from noise on detector) & sensor.wf_precipitation_type > 0

‘hail’ sensor.wf_precipitation_type = 2

‘snowy-rainy’ sensor.wf_precipitation_type > 0, sensor.wf_temperature = 32F / 0C

‘snowy’ — snowy is a guess since there is no ‘sensor’ that detects snow
(temperature in C) sensor.wf_temperature < 1.44 - 0.08 * sensor.wf_humidity)
(temperature in F) sensor.wf_temperature < 34.29 - 0.14 * sensor.wf_humidity)
and
sensor.wf_temperature < 40F / 4.44C
and
sensor.wf_illuminance < 1000 if sun angle > 0

‘pouring’ sensor.wf_rain_rate > 0.31 in/hr (7.8 mm/hr) or sensor.wf_precipitation_type = 3

‘rainy’ sensor.wf_precipitation_type = 1

‘windy-variant’ Wind Speed > 25mph (11.17 m/s) & cloudy

‘windy’ Wind Speed > 25mph (11.17 m/s)

‘fog’ Fog is likely when:
Air Temperature - Dew Point < 4.5F (2.5C)
Relative Humidity > 95%
Wind Speed (above) > 5 knots / 5.7 mph / 2.57 m/s
Wind Speed (below) < 10 knots / 11.5 mph / 5.14 m/s
Clear skies overnight (???) maybe from Pressure
'> -40F (typically >14F)
*** near seawater >70% Relative Humidity and wind speed <10 knots (5.14 m/s)could cause fog (might skip this caveat for now)
Need more conditions for fog, it looks like this might throw a lot of false fog.
There is some trends for heating/cooling but most would not have a derivative sensor for air temperature.
Cooler air temp than ground temp, determine if daily temp max (24hr) is greater than current temp (more to come)
–Use visibility calculation as condition

‘cloudy’ reduced luminescence with a steady tread

‘partlycloudy’ trend of alternating lower and higher lux

‘clear-night’ sun angle < 0 and no other events

‘sunny’ no other events and sun angle > 0 (minimum of 10,000 lux)

‘exceptional --?? (looked at some weather cards and does not seem to be used)

Need to look at more data and adjust for latitude and time of day.
0.0001 lux – Moonless, overcast night sky.
0.002 lux – Moonless clear night sky with airglow.
0.27–1.0 lux – Full moon on a clear night.
3.4 lux – Dark limit of civil twilight under a clear sky.
100 lux – Very dark overcast day.
400 lux – Sunrise or sunset on a clear day.
1000 lux – Overcast day
10000–25000 lux – Full daylight (not direct sun).
32000–100000 lux – Direct sunlight.

WeatherFlow has great local forecast data especially if you have a Tempest. I, as stated above, am working on local conditions; not exactly a forecast but useful for me.

The hyperlocal forecast for my house generated by WeatherFlow has always been way more accurate than any other weather service. The more PWS (Personal Weather Stations) out there the more data available for predictions and trends. I was completely surprised on how spot on my forecast have become. I also am in the Puget Sound.

Also, check out Windy:
Windy.com

I have a WeatherFlow as well, though I use the local (as in, local network, not cloud) integration which does note include forecast data.

I’ve had this little project backburnered for a minute but have done quite a bit of info gathering on how to implement it. Hoping to get to it during some downtime between holidays.

There is actually a Python implementation already, which I just need to change the data inputs on, and I think it could work nicely as a custom component: pywws/forecast.py at 31519ade415545e9cd711237b98aad33d070c1f9 · jim-easterbrook/pywws · GitHub.

Take a look at this WeatherFlow to MQTT for HA integration:
https://github.com/briis/hass-weatherflow2mqtt

This is where I am ‘eventually’ adding the local forecast.

I have a binary sensor that tells you if the condition is ideal for snow. This is done using weather stations that give you an estimate of the cloud base, and your station height. I do my calculations in PHP right now, but it could probably be done in Jinja.

The aviation formula is this:

Sorry it’s in PHP, I might sit down and try and convert it to work in Jinja eventually.

$DALR = 0.3;
$SALR = 0.15;
$FreezingLine = GetFreezingLine();
$EstSnowHeight = $FreezingLine - 500;

function GetFreezingLine () {
global $CurrentTemp;
global $CurrentDewP;
global $DALR;
global $SALR;
$CurrAlt = 0;
$CurrT = $CurrentTemp;

do {
// Current Temp is Over Dew Point
// +25 feet to height;
$CurrAlt = $CurrAlt + 25;
$CurrT = round((float) $CurrT - ($DALR / 4),5);
// Subtract  $DALR / 4 from temp

} while ($CurrT > $CurrentDewP && $CurrT > -0.0);
if ($CurrT < 0.1) { 
  // ********* Freezing Point Reached *************** 
}
else { 
// ********* Dew Point Reached ***************
}

do {
// +50 feet to height
$CurrAlt = $CurrAlt + 25;
$CurrT = (float) $CurrT - ($SALR / 4);
// Subtract $SALR / 4 from Temp
} while ( $CurrT > -0.0);

return ($CurrAlt);
}

That roughly provides the height of the snow line.

2 Likes

Yah I am a big fan of briis’ components. That one I believe still requires internet to pull the forecast values, though they are usually pretty good for me.

Might be worth just creating a PR to that repo and adding a Zembretti field using the existing DB.

This is interesting. What are DALR and SALR? Or how do you define them and would they change based on your location?

@mobile.andrew.jones
I also would like the definition of your variables. This could prove to be handy.

@zacs
I have added a few sensors to briis repo for WeatherFlow; I have been ‘working’ on a completly local forecast for this integration. In my case, for to use the estimated local weather condition when internet is down; I can do some forecast based on pressure trends and still looking into other signs of weather.

It’s a long time, since I wrote this function - but I know they don’t change. They are to do with the lapse rate, which means that we start by subtracting (0.3 / 4) from the temperature (in celcius) every 25ft until we get to the point that the temperature is BELOW the dew point, and then after that point, and then because the air is drier after that point we subtract (0.15 / 4) from the temperature for every 25ft until we reach 0C.

That gets us the freezing line, and the snow line is roughly 500ft lower than the freezing line.

DALR = dry adiabatic lapse rate
SALR = saturated (or wet) adiabatic lapse rate

( The / 4 by the way is because the original formula is per 1000ft, which when a group of us on the weather forum were working with the formula, we worked it down to 100ft. And then of course the /4 is to take that down to 25ft steps)

Snow and Freezing height vs Temperature and Dewpoint

Could you post the code for those options?
I assume the Snow Formula is what you posted above, I would like to see your sleet and the others if you don’t mind.