My Smart Home

A Weather-Based Migraine Early-Warning System in Home Assistant

A Home Assistant migraine risk score built from my own weather station - pressure swings, humidity, UV and air quality - that warns us before one hits.

On this page
  1. Before the how: this isn’t medical advice
  2. Why a weather station in the yard, and not an app
  3. Remembering the last three hours without a database
  4. Scoring the risk
  5. The alerts
  6. Tuning it to a person
  7. The one cloud dependency, stated plainly
  8. Was it worth building

My wife and I both get migraines, and after a while we noticed they tracked the weather - a barometric pressure drop before a storm would show up as a headache a few hours later. There’s real research behind that link, but the weather apps are useless for it. They’ll tell you the pressure right now; they won’t tell you it’s about to fall off a cliff in the next three hours. So I built the thing I actually wanted: a Home Assistant setup that watches my own weather station and gives us a heads-up before a bad day, instead of during it.

Before the how: this isn’t medical advice

I want to be clear up front. This doesn’t diagnose anything and it isn’t a treatment. It’s a correlation machine tuned to two people in one house. Weather is one migraine trigger among many, and yours might not track pressure at all. All this does is give an earlier heads-up to take preventive medication sooner, which is a conversation to have with an actual doctor. Don’t take a number on a dashboard as anything more than that.

With that said, here’s how it works.

Why a weather station in the yard, and not an app

The reason a cloud weather API doesn’t cut it: it reports the nearest airport, often on a delay, and it smooths out exactly the fast, local pressure changes I care about. A WeatherFlow Tempest sitting in the yard gives Home Assistant real local pressure every minute over my own network. When a front is moving through, that difference is the whole game - I need to see the barometer start falling, not read yesterday’s average.

The Tempest covers pressure, temperature, humidity, wind, UV, and lightning. The one thing it doesn’t do is particulates, so outdoor PM2.5 comes from the free WAQI integration - which also publishes a humidity figure for my city, and that’s the one I feed the score - with the IKEA ALPSTUGA handling indoor air quality. The ALPSTUGA speaks Matter over Thread, so it needs a Thread border router somewhere on the network - the guide to the best Thread border routers covers what already counts as one in most houses. And if you want something more accurate indoors than a cheap IKEA box, the roundup of air quality sensors for Home Assistant has the local-first options.

Remembering the last three hours without a database

The core signal is the change over three hours, not the current reading. Home Assistant doesn’t hand you “pressure three hours ago” without digging through the history database, and I didn’t want a heavy query running every few minutes.

So I keep a rolling list of readings in a plain text helper. Every 15 minutes an automation prepends the current pressure and trims the list to 12 entries. Twelve readings at 15 minutes apart means the last one is about three hours old, so the three-hour change is just the newest value minus the oldest:

input_number.migraine_pressure_change_3h =
  current pressure  -  the 12th entry in the buffer

It’s cheap, it survives a restart, and it does the same job for temperature and humidity. That ring-buffer-in-a-text-helper trick is the one piece of this I’m actually a little proud of.

Scoring the risk

Every five minutes a second automation reads those three-hour changes plus the live sensors and adds up a risk score from 0 to 10. A falling barometer carries the most weight, and a drop counts for more than a rise, because that is the classic trigger:

SignalConditionPoints
Pressure change (inHg / 3h)falling more than 0.10+4
falling 0.06 to 0.10+3
falling 0.04 to 0.06+2
falling 0.02 to 0.04+1
rising more than 0.08+2
rising 0.04 to 0.08+1
Temperature swing (°F / 3h)more than 14+3
10 to 14+2
6 to 10+1
Humidity swing (% / 3h)more than 20+2
12 to 20+1
Wind gustover 20 mph+1
UV indexover 6+1
PM2.5over 25 µg/m³+1
Lightning30+ strikes in 1h, or 60+ in 3h+1

The total is capped at 10 and turned into a plain label - Low, Moderate, High, or Critical. It also writes a short plain-English “why” string, so an alert reads “Pressure dropping fast, UV high” instead of a bare number. That part matters more than it sounds: a 7/10 with no reason attached is easy to ignore.

The alerts

The score drives a handful of notifications, tuned so they don’t cry wolf:

  • 7 AM forecast - a morning summary to the phone: risk level, the pressure trend, temperature, humidity, UV, and the contributing factors. Enough to decide whether it’s a “take something with breakfast” day.
  • Pressure drop warning - fires when pressure falls more than 0.04 inHg over three hours: “consider preventive medication.”
  • Rapid pressure drop - the loud one, at more than 0.08 inHg over three hours: “take it now.”
  • Storm front building - when the overall score climbs past 4, with the factor breakdown attached.
  • Temperature swing - a jump of more than 10°F in three hours, up or down.
  • High UV and poor air quality - separate nudges when UV goes over 7 or outdoor PM2.5 goes over 35.

Those same Tempest, lightning, UV, and air-quality entities also feed the weather block on the Echo Show 8 I reflashed into a Home Assistant display, so the numbers behind an alert are already on the kitchen counter.

Tuning it to a person

The thresholds above aren’t gospel - they’re where I landed after watching it for a few weeks. My first version was too quiet and missed a couple of real days, so I lowered the pressure and temperature cutoffs; the config is literally marked “aggressive” now. If you build your own, plan to do the same: keep a rough log of actual migraine days against what the score was doing, and move the numbers until the alerts line up with reality for whoever you’re building it for.

The one cloud dependency, stated plainly

Everything runs on my own hardware except one piece: the outdoor PM2.5 and the humidity trend come from WAQI, a free online air-quality feed, because the Tempest doesn’t measure particulates. Indoor air quality falls back to the local IKEA monitor if I want it fully in-house. I’d rather that one input were local too, but a free public feed for my city is a fair trade for now, and the pressure signal - the part that predicts things - never leaves the network.

Was it worth building

It’s not a cure and it doesn’t catch everything. But a text that says “pressure’s about to drop, take something now” a few hours ahead has made some bad days meaningfully less bad, and it turned a vague “the weather’s off today” into something we can act on early. For a weekend of templating and a weather station I already wanted, that’s a trade I’d make again.

If you want to try it, the shape is small: three automations that keep the rolling buffers, one that computes the score every five minutes, and a handful of notification automations on top. The hardware in the box at the top is all it really needs.

Keep going

All articles →
Article

Best Zigbee sensors for Home Assistant

Local-first Zigbee sensor picks that integrate cleanly with Home Assistant, including motion, contact, leak, presence, and air-quality options.

Read article →
Article

Best Zigbee temperature humidity sensors ranked

The best Zigbee temperature and humidity sensors for Home Assistant, ranked for accuracy, value, and fully local operation via ZHA or Zigbee2MQTT.

Read article →
Article

Best air quality sensors for Home Assistant

CO2, PM2.5 and VOC with no cloud account: AirGradient ONE overall, Apollo AIR-1 for ESPHome, IKEA ALPSTUGA for the money. What each one actually measures.

Read article →
New guides and product notes, no inbox required. Follow via RSS →