Trajectory Weather Labs
"Predict the surge. Control the outcome."
Trajectory Weather Labs is a professional-grade meteorological engine for Hubitat that moves beyond simple weather display into forensic analysis. By leveraging Linear Trend Extrapolation and a weighted "Forensic DNA" algorithm, it predicts severe weather events—Storms, Floods, and Freezes—up to 1 hour in advance, empowering your smart home to take preemptive action.
It transforms your local weather station (Ecowitt, Ambient, etc.) from a passive display into a tactical hazard control center.
The Inspiration
I chose Hubitat for one primary reason: 100% local control.
Like many of you, I needed a smart home that didn't depend on the internet to keep my family safe. While there are plenty of weather drivers available, I found they all suffered from the same problem: they rely on data from airports or API services 10–30 miles away.
In my area, the weather in my backyard can be drastically different from what’s happening across town. Relying on distant sensors meant my automations were often triggering too late, or for conditions that weren't actually hitting my house.
I developed Trajectory Weather Labs because I needed microclimate intelligence. I didn't just want a trigger that said, "It is raining." I needed a physics engine that could predict bad weather before it became a problem—using my data from my sensors.
The Safety Stack: NOAA + TWL
It is critical to state that while this app is fleshed out and functional, it does not replace a NOAA Weather Radio. We cannot predict what is happening 50 miles away, only the trends and history occurring right here.
We use this app as a hyper-local companion to the NOAA system:
- NOAA: Warns us of what is coming from the next county over.
- Trajectory Labs: Confirms exactly when it hits our property and how severe the local impact is.
My Use Case: We use the app’s virtual "Storm" and "Warning" switches to trigger minute-by-minute announcements on our house speakers. This keeps our family updated on exactly what is happening outside our windows in real-time, without needing to check our phones or rely on cloud services that might go down during a storm.
Key Features
1.
Forensic DNA Analysis
Unlike standard apps that trigger on a single data point (e.g., "Wind > 50mph"), Trajectory Labs employs a "molecular" approach. It decomposes every hazard into weighted risk factors that aggregate into a precise Hazard Score (0-100%).
Storm DNA: Kinetic Energy (Gusts/Wind) + Mass Loading (Rain Rate) + Electrical Surge (Lightning) + Atmospheric Potential (Dew Point/Lux).
Flood DNA: Hydraulics (Soil Saturation) + Surface Velocity (Runoff Rate).
Freeze DNA: Thermodynamics (Wet Bulb/Air Temp) + Crystal Growth (Humidity) + Advection (Wind Direction).
Why this matters: A 30mph wind alone might not be a storm. But 30mph wind + heavy rain + rapid pressure drop + lightning strikes? That is a storm. The DNA engine recognizes this compound risk.
2.
Predictive "Watch" System (1-Hour Forecast)
The system calculates the Rate of Change (RoC) for every sensor over the last 60 minutes to project future conditions.
- Linear Trend Extrapolation: Uses the formula
Future_Val = Current_Val + (Rate * 1.0hr)to predict future states. - Pre-Alert Watches: If the projected risk breaches your safety threshold, it activates a "Watch" switch (e.g.,
Pre-Storm). - Visual Indicators: The dashboard displays trends as STABLE, RISING, or HIGH RISK.
3.
Live Hazard Control Center
Provides real-time monitoring with instant relay activation for automation.
- Three Distinct Alarm Channels: Storm, Flood, and Freeze.
- Actionable Automation:
- Storm Alarm: Retract awnings, close shutters, trigger visual alerts (Red lights).
- Flood Alarm: Cut power to basement outlets, notify regarding sump pumps.
- Freeze Alarm: Activate pipe heaters, drip faucets, adjust thermostat setpoints.
- Smart Hysteresis: Features a "Latch" mechanism (default 20 mins) to prevent alarms from "flapping" on/off during temporary lulls.
4.
Regional Physics Calibration
Acknowledging that a storm in Arizona differs from one in Florida, This version introduces a Regional Physics Module that auto-calibrates based on your US State.
- Soil Hydraulics: Adjusts flood saturation models for Clay (Midwest) vs. Sand (Coastal).
- Evaporation Rates: Tunes drying times for Arid vs. Humid climates.
- Thermal Thresholds: Calibrates freeze warnings for northern vs. southern infrastructure resilience.
5.
Advanced Sensor Health & Trust
The system is self-aware of data integrity.
- Stale Data Detection: Flags sensors that stop reporting for >1 hour.
- Smart Overrides: If the Lightning sensor fails but Wind/Pressure sensors indicate a storm (DNA > 40%), the system intelligently bypasses the stale data to maintain protection.
- PAI Trust Scores: Displays a "Trust Percentage" for every hazard calculation.
The Dashboard (UI)
The app generates a sophisticated, data-rich HTML dashboard directly within the Hubitat mobile app interface.
- Emergency Protocols: Prominent red/blue banners appear only when critical safety actions are required (e.g., "SEEK SHELTER").
- Tactical Situation Report: A plain-English text summary of the current threat level (e.g., "Wind: Elevated breeze. Trends: Gusts Surging.").
- Visual Gauges: Progress bars indicate proximity to alarm triggers.
- Sparklines: Embedded mini-graphs visualize the last 50 data points for Temp, Rain, and Wind.
Installation & Setup
- Install Code: Copy the provided Groovy code into Apps Code on your Hubitat hub.
- Add App: Navigate to Apps > Add User App > Trajectory Weather Labs.
- Select Sensors:
- Primary: Your Weather Station device (supports drivers with
temperature,humidity,windSpeed,rainRate). - Optional: Dedicated Lightning Detector (e.g., Ecowitt Wittboy), Lux Sensor.
- Configure Relays: Assign virtual switches for Storm, Flood, and Freeze alarms.
- Calibrate: (Optional) Visit Regional Physics to select your state for auto-tuning.
How It Works (The Math)
The Normalization Algorithm
The system normalizes diverse sensor inputs into a unified risk score:
$$Score = \left( \frac{\sum \text{Active Weights}}{\sum \text{Total Possible Weights}} \right) \times 100$$
- Note: If a sensor (e.g., Lux) is missing, its weight is removed from the denominator, ensuring the score remains an accurate 0-100% representation based on available data.
The "Peak Latching" Logic
To avoid missing gusts between polling cycles, the system employs Peak Latching. It retains the highest wind gust or rain rate recorded in the last 60 minutes for risk calculations, maintaining alert readiness even if live readings temporarily drop.
The "Wet Bulb" Calculation
Calculates Wet Bulb Temperature to predict "Flash Freezing" risks.
- Standard Freeze: Air Temp < 32°F.
- Wet Bulb Freeze: Even if Air Temp is 36°F, low humidity can drop the Wet Bulb to 30°F. Evaporation will cool wet surfaces (like pipes) to 30°F, causing bursts despite "above freezing" air. Trajectory Labs detects this hidden danger.






