Calculate current weather conditions for Home Assistant

In the attempt to be as self-hosted as possible and internet goes out frequently, I am attempting to expand the condition_template under the weather template to pull from local sensors and not from web.
I have a WeatherFlow Tempest weather station that gets all the weather information locally except condition and forecast. I don’t foresee calculating the forecast (at least not too far), but I think I can get close for judging current conditions.

Below is what I have so far, any insight is welcome:
The conditions listed are the only ones HA accepts.

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 (attempt to eliminate false reports from noise on detector)

‘hail’ sensor.wf_precipitation_type = 2

‘snowy-rainy’ sensor.wf_precipitation_type > 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) and 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.

‘cloudy’ reduced illuminance 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.

2 Likes