/* Station tab: live readings from the personal weather station, in the former /conditions look. app.js calls renderStationTab(device) whenever new station data arrives. */ (() => { 'use strict'; const root = document.getElementById('station-live'); if (!root) return; const cardinal = (deg) => (deg == null ? '—' : ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'][Math.round(+deg / 22.5) % 16]); const metric = () => typeof state !== 'undefined' && state.units !== 'us'; const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : null); const fTemp = (f) => (num(f) == null ? '—' : String(Math.round(metric() ? (f - 32) * 5 / 9 : f))); const fSpeed = (m) => (num(m) == null ? '—' : String(Math.round(metric() ? m * 1.60934 : m))); const fRain = (i) => (num(i) == null ? '—' : metric() ? (i * 25.4).toFixed(1) : i.toFixed(2)); const fPres = (i) => (num(i) == null ? '—' : metric() ? String(Math.round(i * 33.8639)) : i.toFixed(2)); const units = () => ({ t: metric() ? '°C' : '°F', s: metric() ? 'km/h' : 'mph', r: metric() ? 'mm' : 'in', p: metric() ? 'hPa' : 'inHg' }); function tempColor(f) { if (f == null) return 'var(--sl-text)'; if (f <= 32) return '#93c5fd'; if (f <= 50) return '#60a5fa'; if (f <= 65) return 'var(--sl-text)'; if (f <= 80) return '#f59e0b'; if (f <= 90) return '#f97316'; return '#ef4444'; } function uvInfo(uv) { if (uv == null) return ['', 'var(--sl-text)']; if (uv < 3) return ['Low', '#4ade80']; if (uv < 6) return ['Moderate', '#facc15']; if (uv < 8) return ['High', '#f97316']; if (uv < 11) return ['Very High', '#ef4444']; return ['Extreme', '#d946ef']; } function conditionText(d) { if (!d) return '—'; if (d.rainratein > 0.05) return '🌧 Raining'; const s = d.solarradiation; if (s != null) { if (s > 700) return '☀️ Sunny'; if (s > 250) return '🌤 Partly Cloudy'; if (s > 60) return '⛅ Mostly Cloudy'; if (s > 5) return '☁️ Overcast'; } return '🌙 Night'; } const SHELL = `
This station is a personal weather station: real instruments on the owner's property that measure the weather right here, right now. These numbers are measurements, not a forecast or a computer model.
What it measures
How it fits with the rest of the app
History, records and charts, plus a side-by-side with the official National Weather Service station, are on the Station Dashboard (sign-in required).