From 8647f52fbc56b585bc461d9d205094e62804d2d0 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 8 Apr 2026 21:33:27 -0400 Subject: [PATCH] feat(weather): live current conditions endpoint + polling display in briefing view --- frontend/src/views/BriefingView.vue | 63 ++++++++++++++++++++++++- src/fabledassistant/routes/briefing.py | 38 +++++++++++++++ src/fabledassistant/services/weather.py | 48 +++++++++++++++++++ 3 files changed, 147 insertions(+), 2 deletions(-) diff --git a/frontend/src/views/BriefingView.vue b/frontend/src/views/BriefingView.vue index 67fe1aa..9653ecc 100644 --- a/frontend/src/views/BriefingView.vue +++ b/frontend/src/views/BriefingView.vue @@ -60,6 +60,23 @@ const isToday = computed(() => selectedConvId.value === todayConvId.value) const weatherData = ref([]) const tempUnit = ref('C') +interface CurrentConditions { + temperature: number | null; + windspeed: number | null; + description: string; + precip_next_3h: number[]; + temp_unit: string; + location: string; +} +const currentConditions = ref(null) +let currentWeatherTimer: ReturnType | null = null + +async function loadCurrentConditions() { + try { + currentConditions.value = await apiGet('/api/briefing/weather/current') + } catch { /* silent — endpoint may not have locations configured */ } +} + async function loadWeather() { try { const data = await apiGet<{ locations: WeatherData[]; temp_unit: string }>('/api/briefing/weather') @@ -90,6 +107,7 @@ async function loadAll() { getBriefingToday().catch(() => null), loadWeather(), loadNews(), + loadCurrentConditions(), ]) conversations.value = convList if (today) { @@ -198,11 +216,18 @@ useBackgroundRefresh( ) let _mounted = true -onUnmounted(() => { _mounted = false }) +onUnmounted(() => { + _mounted = false + if (currentWeatherTimer) clearInterval(currentWeatherTimer) +}) onMounted(async () => { await checkSetup() - if (!showWizard.value) await loadAll() + if (!showWizard.value) { + await loadAll() + // Poll current conditions every 30 minutes + currentWeatherTimer = setInterval(loadCurrentConditions, 30 * 60 * 1000) + } }) @@ -235,6 +260,15 @@ onMounted(async () => {
Weather
+ +
+
{{ currentConditions.temperature }}°{{ currentConditions.temp_unit }}
+
{{ currentConditions.description }}
+
+ Rain next 3h: {{ currentConditions.precip_next_3h.map((p: number) => `${p}%`).join(', ') }} +
+
+